1shop2.queue.favorite = function () { 2 3 var closeText = window._s3Lang.JS_CLOSE; 4 var deletItemFavorite = window._s3Lang.JS_REMOVE_ALL_FAVORITES; 5 var deleteFavorite = window._s3Lang.JS_DELETE; 6 var addedProduct = window._s3Lang.JS_ADDED_TO_FAVORITE; 7 var toFavorites = window._s3Lang.GR_ADD_TO_FAVORITE; 8 9 /*var closeText = $('html').attr('lang') == 'ru' ? 'ÐакÑÑÑÑ' : 'Close'; 10 var deletItemFavorite = $('html').attr('lang') == 'ru' ? 'УдалиÑÑ Ð²Ñе ÑоваÑÑ Ð¸Ð· избÑанного?' : 'Remove all products from favorites?'; 11 var deleteFavorite = $('html').attr('lang') == 'ru' ? 'УдалиÑÑ' : 'Delete'; 12 var addedProduct = $('html').attr('lang') == 'ru' ? 'Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½ в' : 'Product added to'; 13 var favoritVar = $('html').attr('lang') == 'ru' ? 'избÑанное' : 'favorites'; 14 var toFavorites = $('html').attr('lang') == 'ru' ? 'РизбÑанное' : 'Add to favorites';*/ 15 16 17 var popupClose = `<span>${closeText}<i><svg class="gr-svg-icon gr_big_icon"><use xlink:href="#icon_shop_close"></use></svg><svg class="gr-svg-icon"><use xlink:href="#icon_shop_close_small"></use></svg><svg class="gr-svg-icon gr_small_icon"><use xlink:href="#icon_shop_close_mini"></use></svg></i></span>`; 18 19 function popupClearFavorite() { 20 let popupWr = `<div class="gr-favorite-popup"><div class="gr-favorite-popup__inner"><div class="gr-favorite-popup__text">${deletItemFavorite}</div><div class="gr-favorite-popup__btns"><div class="shop2-btn gr-favorite-popup__clear">${deleteFavorite}</div><div class="shop2-btn-close gr-favorite-popup__close">` + popupClose + `</div></div></div></div>`; 21 22 $(popupWr).appendTo('body'); 23 }; 24 25 $(document).on('click', '.gr-favorite-btn:not(.active)', function () { 26 let $this = $(this), 27 kind_id = $this.parents('form').find('input[name="kind_id"]').val(); 28 29 let product = $('body').find('form input[value="' + kind_id + '"]').closest('form'), 30 button = product.find('.gr-favorite-btn'); 31 32 if ($.cookie('set_user_new_token') != 'is_set' && is_user) { 33 $.cookie('s3_user_token', '', { 34 path: "/" 35 }); 36 $.cookie('set_user_new_token', 'is_set'); 37 } 38 39 shop2.trigger('beforeFavoriteAddItem'); 40 41 $.ajax({ 42 url: '/-/x-api/v1/public/?method=shop2/addFavoriteProduct¶m[kind_id]=' + kind_id, 43 type: 'post', 44 dataType: 'json', 45 data: kind_id, 46 47 success: function (data) { 48 try { 49 let res = data.result.count; 50 let icon = '<i><svg class="gr-svg-icon"><use xlink:href="#icon_shop_notify_arr"></use></svg></i>'; 51 let $text = `${addedProduct}`; 52 /*let $text = `${addedProduct} <a href='%s' class='go-favorite-tooltip-btn'>${favoritVar} ${icon}</a>`;*/ 53 54 if (shop2.mode == 'favorites') { 55 var template_html = `<a href="javascript:void(0);" class="gr-favorite-btn__link"><ins>${deleteFavorite}</ins><span class="gr-favorite-btn__count">${res}</span></a>`; 56 } else { 57 var template_html = `<a href="${shop2.uri + '/favorites'}" class="gr-favorite-btn__link"><ins>${window._s3Lang.GR_SHOP2_FAVORITES}</ins><span class="gr-favorite-btn__count">${res}</span></a>`; 58 } 59 60 /*shop2.msg(`<span class="gr-favorite-btn-counter">${res}</span>` + $text.replace('%s', shop2.uri + '/favorites'), $this.find('.gr-favorite-btn__icon'));*/ 61 62 shop2.msg(`<span class="gr-favorite-btn-counter">${res}</span>` + $text.replace('%s', shop2.uri + '/favorites').replace('%i', '<i><svg class="gr-svg-icon"><use xlink:href="#icon_shop_notify_arr"></use></svg></i>'), $this.find('.gr-favorite-btn__icon')); 63 64 $('.gr-favorite-btn.active a > span').text(res); 65 $('.shop-panel-favorite__link .shop-panel-favorite__count').text(res); 66 $('.shop-panel-favorite').removeClass('not-null'); 67 68 69 $(document).find('#shop2-msg').addClass('msg-favorite'); 70 button.addClass('active').find('.gr-favorite-btn__text').replaceWith(template_html); 71 72 shop2.trigger('afterFavoriteAddItem', data); 73 } catch (e) { 74 console.log(e); 75 let alertText = window._s3Lang.JS_REQUEST_ERROR; 76 alert(alertText) 77 } 78 } 79 }); 80 81 82 }); 83 84 $(document).on('click', '.gr-favorite-btn.active a', function () { 85 if (shop2.mode == 'favorites') { 86 $(this).prev().trigger('click'); 87 } 88 }); 89 90 $(document).on('click', '.gr-favorite-btn.active .gr-favorite-btn__icon', function () {
91 let $this = $(this); 92 let kind_id = $(this).parents('form').find('input[name="kind_id"]').val(); 93 94 // Удаление без вÑплÑваÑÑего окна 95 let product = $('body').find('form input[value="' + kind_id + '"]').closest('form'), 96 button = product.find('.gr-favorite-btn'); 97 98 // ÐÐ»Ñ Ð¿Ð¾Ð¿Ñавки еÑли авÑоÑизованнÑй полÑÐ·Ð¾Ð²Ð°Ð»Ñ Ñак же добавлÑл избÑанное как не авÑоÑизованнÑй 99 if ($.cookie('set_user_new_token') != 'is_set' && is_user) { 100 $.cookie('s3_user_token', '', { 101 path: "/" 102 }); 103 $.cookie('set_user_new_token', 'is_set'); 104 } 105 shop2.trigger('beforeFavoriteRemoveItem'); 106 107 $.ajax({ 108 url: '/-/x-api/v1/public/?method=shop2/removeFavoriteProduct¶m[kind_id]=' + kind_id, 109 type: 'post', 110 dataType: 'json', 111 data: kind_id, 112 success: function (data) { 113 114 try { 115 let res = data.result.count; 116 let temlate = `<span class="gr-favorite-btn__text">${toFavorites}</span>`; 117 $('.gr-favorite-btn.active a > span').text(res); 118 $('.shop-panel-favorite__link .shop-panel-favorite__count').text(res); 119 if (res == 0) { 120 $('.shop-panel-favorite').addClass('not-null'); 121 } 122 button.removeClass('active'); 123 button.find('a').replaceWith(temlate); 124 125 //let $text = "Удалено из <a href='%s'>избÑанное</a>"; 126 let $text = window._s3Lang.JS_REMOVED_FROM_FAVORITE; 127 /*let $text = $('html').attr('lang') == 'ru' ? 'Ð¢Ð¾Ð²Ð°Ñ Ñдален из избÑанного' : 'Product removed from favorites';*/ 128 let template_html = `<a href="${shop2.uri + '/favorites'}" class="gr-favorite-btn__link"><ins>${window._s3Lang.GR_SHOP2_FAVORITES}</ins><span class="gr-favorite-btn__count">${res}</span></a>`; 129 shop2.msg($text.replace('%s', shop2.uri + '/favorites'), $this); 130 $(document).find('#shop2-msg').addClass('msg-favorite'); 131 132 shop2.trigger('afterFavoriteRemoveItem', data); 133 134 } catch (e) { 135 console.log(e); 136 let alertText = window._s3Lang.JS_REQUEST_ERROR; 137 alert(alertText) 138 } 139 } 140 }); 141 // Удаление без вÑплÑваÑÑего окна 142 }); 143 144 $(document).on('click', '.gr-favorite-popup__close', function () { 145 $('.gr-favorite-popup').removeClass('opened'); 146 }); 147 148 $(document).on('click', '.gr-favorite-popup-btn', function (e) { 149 e.preventDefault(); 150 if (!$('.gr-favorite-popup').length) { 151 popupClearFavorite(); 152 153 setTimeout(function () { 154 $('.gr-favorite-popup').addClass('opened'); 155 }, 190); 156 } else { 157 $('.gr-favorite-popup').addClass('opened'); 158 }; 159 }); 160 161 $(document).on('click', function (e) { 162 if (!$(e.target).closest('.gr-favorite-popup__inner, .gr-favorite-popup-btn').length) { 163 $('.gr-favorite-popup').removeClass('opened'); 164 }; 165 }); 166 167 $(document).on('click', '.gr-favorite-popup__clear', function (e) { 168 if ($.cookie('set_user_new_token') != 'is_set' && is_user) { 169 $.cookie('s3_user_token', '', { 170 path: "/" 171 }); 172 $.cookie('set_user_new_token', 'is_set'); 173 } 174 $.ajax({ 175 url: '/-/x-api/v1/public/?method=shop2/clearFavoriteProducts', 176 type: 'post', 177 dataType: 'json', 178 success: function (data) { 179 180 } 181 }); 182 location.reload() 183 }); 184}; 185 186shop2.on('afterFavoriteAddItem', function (d) { 187 $(document).find('.favorite-block .favorite-count').text(d.result.count) 188 if (d.result.count > 0) { 189 $(document).find('.favorite-block').removeClass('is-null'); 190 $(document).find('.shop-panel-favorite__link').removeClass('shop2-panel-link-disabled'); 191 } 192}); 193shop2.on('afterFavoriteRemoveItem', function (d) { 194 $(document).find('.favorite-block .favorite-count').text(d.result.count) 195 if (d.result.count == 0) { 196 $(document).find('.favorite-block').addClass('is-null'); 197 $(document).find('.shop-panel-favorite__link').addClass('shop2-panel-link-disabled'); 198 } 199});
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.