Completed
Push — master ( 48107f...eccdf7 )
by Mario
04:35
created

  A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 9.4285
1
(function($) {
2
    /**
3
     * Needed to replace the fancy select
4
     */
5
    $(document).ready(function() {
6
        var placeHolder = $('#b2bselect-placeholder'),
7
            customerTxt = placeHolder.find('.customer').html(),
8
            companyTxt = placeHolder.find('.company').html();
9
10
        placeHolder.after(buildSelectTemplate(customerTxt, companyTxt)).remove();
11
12
        $('body').delegate('#b2bselect', 'change', function(event) {
13
            var $el = $(event.currentTarget);
14
15
            if ($el.find(":selected").hasClass('is-b2b')) {
16
                $(event.currentTarget).parents('form').submit();
17
            }
18
        });
19
    });
20
21
    function buildSelectTemplate(customerTxt, companyTxt) {
22
        return '<select id="b2bselect" class="klarna-style b2b-select">' +
23
            '<option>' + customerTxt + '</option>' +
24
            '<option class="is-b2b">' + companyTxt + '</option>' +
25
        '</select>'
26
    }
27
})(jQuery);