1// Recalculate cart content functionality without page reload 2 3// NOTE: `$('.ty-btn--recalculate-cart').click();` used for sending AJAX request 4// and dynamically update page content 5 6(function (_, $) { 7 var delay = { 8 qty: 500, 9 inputs: 500 10 }; 11 12 // Check that we are on the cart page and recalculate button exist 13 if (!$('[name=checkout_form]').length && !$('.ty-btn--recalculate-cart').length) { 14 return; 15 } 16 17 // Slight delay (before ajax recalculate) 18 // for the case when the quantity of product changes 19 $(_.doc).on( 20 'click', 21 '.ty-cart-content__qty .cm-increase, .ty-cart-content__qty .cm-decrease', 22 $.debounce(recalculate.bind(undefined), delay.qty) 23 ); 24 25 $(_.doc).on( 26 'change', 27 '#cart_items .cm-cart-contents-updatable-field, .ty-cart-content__qty .cm-amount', 28 $.debounce(recalculate.bind(undefined), delay.inputs) 29 ); 30 31 // Ajax recalculate when product's option changed 32 $.ceEvent('on', 'ce.product_option_changed_post', recalculate.bind(undefined)); 33 34 function recalculate() { 35 $('.ty-btn--recalculate-cart').click(); 36 } 37 38})(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.