1/*ÐÑпон*/ 2 3shop2.queue.coupon = function () { 4 shop2.on('afterCartAddCoupon, afterCartRemoveCoupon', function () { 5 document.location.reload(); 6 }); 7 8 $('.coupon-btn').on('click', function (e) { 9 var coupon = $('#coupon'), 10 code = coupon.val(); 11 12 e.preventDefault(); 13 14 if (code) { 15 shop2.cart.addCoupon(code); 16 } else { 17 shop2.msg('ÐведиÑе код кÑпона', $(this)); 18 } 19 20 }); 21 22 23 $('.coupon-delete').on('click', function (e) { 24 var $this = $(this), 25 code = $this.data('code'); 26 27 e.preventDefault(); 28 29 if (code) { 30 shop2.cart.removeCoupon(code); 31 } 32 }); 33}; 34 35/*ÐÑпон*/ 36 37/*ÐонÑÑÑ*/ 38 39shop2.cart.applyBonusPoint = function (bonus_points, func) { 40 41 shop2.trigger('beforeCartApplyBonus'); 42 43 $.getJSON( 44 '/-/x-api/v1/public/?method=cart/applyBonusPoints', { 45 param: { 46 hash: shop2.hash.cart, 47 bonus_points: bonus_points 48 } 49 }, 50 function (d, status) { 51 shop2.fire('afterCartApplyBonusPoints', func, d, status); 52 shop2.trigger('afterCartApplyBonusPoints', d, status); 53 } 54 ); 55 56 return false; 57}; 58 59shop2.cart.removeBonusPoint = function (func) { 60 61 shop2.trigger('beforeCartRemoveCartBonusPoints'); 62 63 $.getJSON( 64 '/-/x-api/v1/public/?method=cart/RemoveBonusPoints', { 65 param: { 66 hash: shop2.hash.cart 67 } 68 }, 69 function (d, status) { 70 shop2.fire('afterCartRemoveCartBonusPoints', func, d, status); 71 shop2.trigger('afterCartRemoveCartBonusPoints', d, status); 72 } 73 ); 74}; 75 76shop2.queue.bonus = function () { 77 78 shop2.on('afterCartApplyBonusPoints, afterCartRemoveCartBonusPoints', function () { 79 document.location.reload(); 80 }); 81 82 $(document).on('click', '.bonus-apply', function(e) { 83 var bonus = $('#bonus-points'), 84 points = Number(bonus.val()), 85 bonus_user = Number($('.bonus-amount').data('bonus-amount')); 86 87 switch (true) { 88 case points == "": 89 90 e.preventDefault(); 91 92 shop2.msg('ÐведиÑе знаÑение', $(this)); 93 94 break; 95 96 case points > bonus_user: 97 98 shop2.msg('Ðам доÑÑÑпно ÑолÑко '+bonus_user+' бонÑÑов', $(this)); 99 100 break; 101 102 case bonus_user >= points: 103 104 shop2.cart.applyBonusPoint(points); 105 106 break; 107 }; 108 }); 109 110 111 112 $(document).on('click', '.bonus-delete', function(e) { 113 shop2.cart.removeBonusPoint(); 114 }); 115 116 $(document).on('click', '.cart-bonuses__title label', function(e){ 117 e.preventDefault(); 118 var $check = $(':checkbox', this); 119 $check.prop('checked', !$check.prop('checked')); 120 121 $('.cart-bonuses__container').toggleClass('show_bonuses'); 122 123 if (!$check.prop('checked') && $('.cart-total__item.bonus_item').length) { 124 shop2.cart.removeBonusPoint(); 125 }; 126 }); 127 128 $.fn.inputFilter = function (inputFilter) { 129 return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function () { 130 if (inputFilter(this.value)) { 131 this.oldValue = this.value; 132 this.oldSelectionStart = this.selectionStart; 133 this.oldSelectionEnd = this.selectionEnd; 134 } else if (this.hasOwnProperty("oldValue")) { 135 this.value = this.oldValue; 136 this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd); 137 } 138 }); 139 }; 140 141 $("#bonus-points").inputFilter(function (value) { 142 return /^\d*$/.test(value); 143 }); 144}; 145 146/*ÐонÑÑÑ*/ 147 148 149$(function(){ 150 151 $(document).off('click.getPromoLink').off('click.promoPagelist'); 152 153 var gr_promo_info = {}; 154 155 $(document).on('click', '.get-promo-link', function (e) { 156 e.preventDefault(); 157 var ver_id = $(this).data('ver-id'), 158 cmd = $(this).data('cmd'), 159 hash = shop2.apiHash.getPromoProducts, 160 is_main = $(this).data('is-main'), 161 kind_id = $(this).data('kind-id'), 162 discount_id = $(this).data('discount-id'); 163 164 gr_promo_title = $(this).text(), 165 gr_promo_desc = $(this).parents('.promo-action').find('.promo-action__text').html(); 166 167 $.ajax({ 168 url: '/-/shop2-api/?ver_id=' + ver_id + '&cmd=' + cmd + '&hash=' + hash + '&kind_id=' + kind_id + '&discount_id=' + discount_id + '&is_main=' + is_main, 169 type: 'POST', 170 dataType: 'json', 171 data: {}, 172 success: function (res) { 173 shop2.alert(res.data, 'ÐакÑÑÑÑ', 'promo-products-list'); 174 175 setTimeout(function () { 176 $('.promo-header__title').html(gr_promo_title); 177 if (!gr_promo_desc) { 178 $('.promo-header__desc').hide(); 179 }; 180 $('.promo-header__desc').html(gr_promo_desc); 181 182 if (!$('.promo-products-list .shop-pagelist').length) { 183 $('.promo-products-list .product-list.list .product-item:last-child').css('border-bottom', 'none'); 184 }; 185 186 $('.promo-products-list').click().addClass('custom-scroll scroll-width-thin scroll'); 187 $('.promo-products-list .product-item').each(function() { 188 var $flags = $(this).find('.product-flags'); 189 var $flagsContainer = $(this).find('.product-item__bottom-left'); 190 191 $flags.prependTo($flagsContainer); 192 }); 193 194 $('.product-list .gr_images_lazy_load').each(function () { 195 $(this).attr('src', $(this).attr('data-src')); 196 }); 197 198 shop2_gr.methods.amountInit(); 199 }, 100); 200 } 201 }); 202 203 return gr_promo_info = { 204 gr_promo_title: gr_promo_title, 205 gr_promo_desc: gr_promo_desc 206 } 207 }); 208 209 $(document).on('click', '.promo-products-list li', function (e) { 210 e.preventDefault(); 211 var url = $(this).find('a').attr('href'); 212 213 $.ajax({ 214 url: url, 215 type: 'POST', 216 dataType: 'json', 217 data: {}, 218 success: function (res) { 219 shop2.alert(res.data, 'ÐакÑÑÑÑ', 'promo-products-list'); 220 221 setTimeout(function () { 222 $('.promo-header__title').html(gr_promo_info.gr_promo_title); 223 if (!gr_promo_info.gr_promo_desc) { 224 $('.promo-header__desc').hide(); 225 }; 226 $('.promo-header__desc').html(gr_promo_info.gr_promo_desc); 227 228 $('.promo-products-list').click().addClass('custom-scroll scroll-width-thin scroll'); 229 $('.promo-products-list .product-item').each(function() { 230 var $flags = $(this).find('.product-flags'); 231 var $flagsContainer = $(this).find('.product-item__bottom-left'); 232 233 $flags.prependTo($flagsContainer); 234 }); 235 236 $('.product-list .gr_images_lazy_load').each(function () { 237 $(this).attr('src', $(this).attr('data-src')); 238 }); 239 shop2_gr.methods.amountInit(); 240 }, 100); 241 } 242 }); 243 }); 244 245});
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.