1// Recalculate cart content functionality without page reload 2// NOTE: `$('.ty-btn--recalculate-cart').click();` used for sending AJAX request 3// and dynamically update page content 4(function (_, $) { 5 var delay = { 6 qty: 500, 7 inputs: 500 8 }; // Check that we are on the cart page and recalculate button exist 9 10 if (!$('[name=checkout_form]').length && !$('.ty-btn--recalculate-cart').length) { 11 return; 12 } // Slight delay (before ajax recalculate) 13 // for the case when the quantity of product changes 14 15 16 $(_.doc).on('click', '.ty-cart-content__qty .cm-increase, .ty-cart-content__qty .cm-decrease', $.debounce(recalculate, delay.qty)); 17 $(_.doc).on('change', '#cart_items .cm-cart-contents-updatable-field, .ty-cart-content__qty .cm-amount', $.debounce(recalculate, delay.inputs)); 18 $(_.doc).on('keydown', '.ty-cart-content__qty .cm-amount', function (e) { 19 if (e.keyCode === 13) { 20 e.preventDefault(); 21 $(this).blur(); 22 } 23 }); // Ajax recalculate when product's option changed 24 25 $.ceEvent('on', 'ce.product_option_changed_post', recalculate); 26 27 function recalculate(objId, id, optionId, updateIds, formData, data, params, self) { 28 var $this; // self is passed from the options picker 29 30 if (self && self.id) { 31 $this = $('#' + self.id); 32 } else { 33 $this = $(this); 34 } 35 36 var $cartBtn = $('.ty-btn--recalculate-cart', $this.closest('form')); 37 38 if (!$cartBtn.length) { 39 $cartBtn = $('.ty-btn--recalculate-cart'); 40 } 41 42 $cartBtn.click(); 43 } 44})(Tygh, Tygh.$);
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.