for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
(function($) {
/**
* Needed to replace the fancy select
*/
$(document).ready(function() {
var placeHolder = $('#b2bselect-placeholder'),
customerTxt = placeHolder.find('.customer').html(),
companyTxt = placeHolder.find('.company').html();
placeHolder.after(buildSelectTemplate(customerTxt, companyTxt)).remove();
$('body').delegate('#b2bselect', 'change', function(event) {
var $el = $(event.currentTarget);
if ($el.find(":selected").hasClass('is-b2b')) {
$(event.currentTarget).parents('form').submit();
}
});
function buildSelectTemplate(customerTxt, companyTxt) {
return '<select id="b2bselect" class="klarna-style b2b-select">' +
'<option>' + customerTxt + '</option>' +
'<option class="is-b2b">' + companyTxt + '</option>' +
'</select>'
})(jQuery);