1cart = (function ($) { 2 var pub = { 3 init: function () { 4 tocartButton(); 5 deleteButton(); 6 quantityButton(); 7 updateCartItems(); 8 }, 9 getCsrfToken: function () { 10 return $('meta[name=csrf-token]').attr('content'); 11 } 12 }; 13 14 function tocartButton() { 15 $(document).on("beforeSubmit", "form#incart-form, form#incart-form-modal", function () { 16 var form = $(this); 17 if (form.find('.has-error').length) { 18 return false; 19 } 20 $.ajax({ 21 url : form.attr('action'), 22 method : 'post', 23 data : form.serialize(), 24 success: function (response) { 25 OpenModal(response, 'inline'); 26 } 27 }); 28 return false; 29 }); 30 } 31 32 function deleteButton() { 33 /* CART */ 34 $(document).on('click', '.cart-products__item-remove', function (e) { 35 var self = $(this); 36 $.ajax({ 37 url: '/ajax/cart/delete', 38 async: false, 39 method: 'delete', 40 data: { 41 _csrf: pub.getCsrfToken(), 42 id: self.attr('data-id') 43 }, 44 success: function (response) { 45 setCartPrice(response.price); 46 setCartQnt(response.qnt); 47 updateCartItems(response.cartItems); 48 49 // GTM 50 var $track_data = self.parents('.cart-products__item').find('.track-data'); 51 if ($track_data.length) { 52 try { 53 var track_data = JSON.parse($track_data.attr('data-info')); 54 (dataLayer = window.dataLayer || []).push({ 55 'ecommerce': { 56 'remove': { 57 'products': [track_data] 58 } 59 }, 60 'event': 'GAEventEC', 61 'eCategory':'eEC', 62 'eAction':'remove', 63 'eLabel':'', 64 'eNI':'0' 65 }); 66 } catch (e) { 67 console.log($track_data.attr('data-info')); 68 } 69 } 70 } 71 }); 72 }); 73 } 74 75 function quantityButton() { 76 $(document).on('touchspin.on.startspin blur', '.product-quantity__input', function () { 77 $.ajax({ 78 url: '/ajax/cart/quant', 79 type: 'POST', 80 data: { 81 _csrf: pub.getCsrfToken(), 82 qnt: $(this).val(), 83 id: $(this).attr('data-id') 84 }, 85 success: function (response) { 86 setCartPrice(response.price); 87 setCartQnt(response.qnt); 88 if ($('.cart-summary__total').length) { 89 updateCartItems(response.cartItems); 90 } 91 if ($('.cart-preview__total').length) { 92 $('.cart-preview__total span').html(response.price + ' <b class="rub">â½</b>'); 93 } 94 } 95 }); 96 }); 97 } 98 99 function updateCartItems(html) { 100 $('.cart-items').html(html); 101 touchSpinInit(); 102 LazyImgLoad(); 103 if ($('.tooltip-action').length) { 104 tooltipActionInit(); 105 } 106 } 107 108 return pub; 109})(jQuery); 110 111jQuery(document).ready(function () { 112 cart.init(); 113});
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.