1/* KCV3_CART.JS */ 2// Remove listener 3var cartUpdateQuantity = null; 4 5$(document).ready( function($){ 6 7 $('body').delegate('.cartremove', 'click', function(e){ 8 e.preventDefault(); 9 10 var that = $(this); 11 var productId = that.parent().parent().data('product-id'); 12 13 // Ajax function, state change 14 $.get('ajax.php?action=ajax&ajaxfunc=remove_from_cart&products_id=' + productId, function(response){ 15 reloadCart(); 16 }); 17 }); 18 19 $('body').delegate('.inputQuantity', 'blur', function(e){ 20 var that = $(this); 21 var productId = that.parent().parent().parent().data('product-id'); 22 var qty = that.val(); 23 24 that.parent().find('.update-quantity').addClass('dnone'); 25 26 updateProductQuantity(productId, qty); 27 }); 28 29 $('body').delegate('.inputQuantity', 'keydown', function(e){ 30 31 var that = $(this); 32 var productId = that.parent().parent().parent().data('product-id'); 33 var qty = that.val(); 34 35 if (e.keyCode == '13'){ 36 e.preventDefault(); 37 38 updateProductQuantity(productId, qty); 39 } 40 }); 41 42 $('body').delegate('.recurringinput', 'change', function(e){ 43 var that = $(this); 44 var productId = $($(this)).data('product'); 45 var interval = that.val(); 46 updateProductInterval(productId, interval) 47 }); 48 49 $('body').delegate('.form-check-input.discount-code', 'change', function(e){ 50 var that = $(this); 51 52 if (that.is(':checked')){ 53 $('.discount-panel').show(); 54 } else { 55 $('.discount-panel').hide(); 56 } 57 }); 58 59 $('body').delegate('.form-check-input.attach-comment', 'change', function(e){ 60 var that = $(this); 61 62 if (that.is(':checked')){ 63 $('#comment_area').show(); 64 } else { 65 $('#comment_area').hide(); 66 } 67 }); 68 69 $('body').delegate('#remove_dicount_code', 'click', function(e){ 70 e.preventDefault(); 71 72 $.post('/ajax.php?ajaxfunc=detach_discount_code', function(data){ 73 location.reload(); 74 }); 75 }); 76 77 function updateProductQuantity(id, qty){ 78 const data = { 79 id: id, 80 qty: qty 81 }; 82 83 $.post('ajax.php?ajaxfunc=update_cart_mobile', data, function(data) { 84 reloadCart(); 85 }); 86 } 87 function updateProductInterval(id, interval){ 88 $.post('ajax.php?ajaxfunc=update_cart_interval&id='+id+'&interval='+interval, function(data) { 89 console.log(data) 90 reloadCart(); 91 });; 92 } 93 94 $('body').delegate('.update-quantity', 'click', function(e){ 95 e.preventDefault(); 96 clearTimeout(cartUpdateQuantity); 97 98 var that = $(this); 99 var qtyInput = that.parent().find('input'); 100 var qtyInputValue = qtyInput.val(); 101 var modifier = that.data('modify'); 102 103 if (modifier == 'increase'){ 104 qtyInputValue++; 105 } else if (modifier == 'decrease') { 106 if (qtyInputValue > 0) qtyInputValue--; 107 } 108 109 qtyInput.val(qtyInputValue); 110 111 cartUpdateQuantity = setTimeout( function(){ 112 console.log("TEST"); 113 qtyInput.trigger('blur'); 114 }, 1200); 115 }); 116 }); 117 118 119 $(function(){ 120 $('body').delegate('#discount_center_code', 'blur', function(){ 121 if ($('#discount_center_code').val() == '') { 122 123 return false; 124 } else { 125 // $('#add_discount_center_code').click(); 126 } 127 }); 128 129 var timeFixer = null; 130 131 $('#add_discount_center_code').unbind(); 132 $('#add_discount_center_code').undelegate(); 133 $('#add_discount_center_code').unbind('click'); 134 $('#add_discount_center_code').undelegate('click'); 135 $('body').delegate('#add_discount_center_code', 'click', function(e){ 136 e.preventDefault(); 137 clearTimeout(timeFixer); 138 139 timeFixer = setTimeout( function(){ 140 if ($('#discount_center_code').val() == '') { 141 return false; 142 } 143 144 // Remove old classes 145 $('#discount_center_status').removeClass('notification-error, notification-success') 146 147 // Try to add discount code 148 $.getJSON('ajax.php?ajaxfunc=add_discount_code', { discount_code: $('#discount_center_code').val() }, function(data){
149 // Code was not valid 150 if (data.code_valid == false) { 151 $('#discount_center_form').fadeOut(500, function(){ 152 // Make sure we really hide the form (old jquery in checkout...) 153 if ($('#discount_center_form').is(':visible')) { 154 $('#discount_center_form').css('display', 'none'); 155 } 156 157 // Look for specific error messages from ajax.php 158 error_message = data.error_message; 159 160 // Show error message, hide after 6 seconds 161 $('#discount_center_status').addClass('notification-error').text(error_message).fadeIn(500); 162 setTimeout('hide_discount_center_status("false")', 3000); 163 }); 164 } else if (data.code_valid == true) { 165 // Make sure we really hide the form (old jquery in checkout...) 166 if ($('#discount_center_form').is(':visible')) { 167 $('#discount_center_form').css('display', 'none'); 168 } 169 170 // Code was valid, show success message and reload page after a second 171 $('#discount_center_form').fadeOut(500, function(){ 172 data_message = data.message; 173 $('#discount_center_status').addClass('notification-success').text(data.success_message).fadeIn(500); 174 setTimeout('hide_discount_center_status("true", data_message)', 1000); 175 }); 176 } 177 }); 178 }, 200); 179 }); 180}); 181 182function reloadCart(){ 183 // Hooking onto some existing function 184 if (typeof themeSpecificCartReload === 'function'){ 185 themeSpecificCartReload(); 186 } else { 187 // Just in case, previous one is not defined 188 location.reload(); 189 } 190}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.