$(document).ready(function () { $('.productList ul li').each(function () { if ($('.productDesc a', this).length == 0) { var title = $.trim($(this).find('h3').text()); $('.productAddToCart', this) .clone() .attr({ 'id': '', 'class': '', 'title': title }) .appendTo($('.productDesc', this)) .hide(); } }); formValidationHok(); moveLargeBasketNextButton(); hideDeliveryCostsWhenEmpty(); orderProcessHideNewAddress(); staffel(); }); function moveLargeBasketNextButton() { $('.largeCart.shoppingBasket .cartNext').insertBefore($('.largeCart.shoppingBasket .cartUpdate')); } function hideDeliveryCostsWhenEmpty() { var shippingTotals = $('.largeCart .shippingTotals'), price = shippingTotals.find('.price'), html = price.text(); if (price.length > 0) { if (html.indexOf("0,00") != -1) { shippingTotals.hide(); } else{ shippingTotals.show(); } } } function orderProcessHideNewAddress() { var form = $('.newAddress .addressform').hide(), radio = $('.newAddress input[type="radio"]'), otherRadio = $('.address input[type="radio"]'); radio.on('change', function () { if ($(this).is(':checked') && !form.is(':visible')) { form.slideDown(400); } else { form.slideUp(400); } }).trigger('change'); otherRadio.not(radio).on('change', function () { radio.trigger('change'); }); } function formValidationHok() { $('.customForm_Button a, .nextStep a, .productDetailsContainer .articleProperties .propertyField.action0 .button a, .popupTable .buttons a, .SurveyContainer .Buttons input[type=submit]').click(function () { highlightErrors(); }); window.setTimeout(function () { highlightErrors(); }, 100); } function highlightErrors() { $('div.customForm_Row div.error, div.customForm_RowCheck div.error, div#ChangePassword div.customForm_Row div.input, div#ResetPassword div.customForm_Row div.input, .sectionitemblock .question .error').each(function () { var row = $(this).closest('.customForm_Row, .customForm_RowCheck, .sectionitemblock'), triggerError = 0; $(this).find('span').each(function () { if ($(this).css('visibility') == 'visible' && $(this).css('display') != 'none') { console.log($(this).closest('.customForm_Row, .customForm_RowCheck, .sectionitemblock').attr('class')); triggerError++; } }); if (triggerError == 0) { row.removeClass('customForm_Error'); if (row.parent().hasClass('sectionitemlist')) { $('.sectionitemblock.customForm_Error .textbox').parent().prev('.sectionitemblock').removeClass('customForm_Error'); } } else { row.addClass('customForm_Error'); if (row.parent().hasClass('sectionitemlist')) { $('.sectionitemblock.customForm_Error .textbox').parent().prev('.sectionitemblock').addClass('customForm_Error'); } } }); } function staffel(){ var element = $('.staffelProperties'), add = element.find('.buttonPlus'), substract = element.find('.buttonMin'), input = $('.productCount'); add.on('click keydown', function(event){ if(event.type == 'click' || event.which == 13 || event.which == 32){ var row = parseInt($(this).closest('.option').attr('class').replace(/\D/gi, ''), 10), x = parseInt(element.find('.property' + row).find('.count').text(), 10); modifyCount(x); event.preventDefault(); } }); substract.on('click keydown', function(event){ if(event.type == 'click' || event.which == 13 || event.which == 32){ var row = parseInt($(this).closest('.option').attr('class').replace(/\D/gi, ''), 10), x = parseInt(element.find('.property' + row).find('.count').text(), 10); modifyCount(0 - x); event.preventDefault(); } }); function modifyCount(amount){ var currentAmount = parseInt(input.val(), 10); if(currentAmount != 1){ amount = currentAmount + amount; } if(amount > 0){ input.val(amount); } else { input.val(1); } } }