| Conditions | 1 |
| Paths | 1 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 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); |