1shop2.queue.favorite = function(){ 2 3 function popupDeleteFavorite($kind_id){ 4 var popupWr = '<div class="shop2-popup_favorite"><div class="popup_inner"><div class="text">УдалиÑÑ ÑÐ¾Ð²Ð°Ñ Ð¸Ð· избÑанного?</div><div class="btns"><div class="shop2-btn delete_fovorite" data-kind_id="' + $kind_id + '">УдалиÑÑ</div><div class="shop2-btn-close close_favorite">ÐакÑÑÑÑ</div></div></div></div>'; 5 6 $(popupWr).appendTo('body'); 7 } 8 9 function popupClearFavorite(){ 10 var popupWr = '<div class="shop2-popup_favorite"><div class="popup_inner"><div class="text">УдалиÑÑ Ð²Ñе ÑоваÑÑ Ð¸Ð· избÑанного?</div><div class="btns"><div class="shop2-btn clear_fovorite">УдалиÑÑ</div><div class="shop2-btn-close close_favorite">ÐакÑÑÑÑ</div></div></div></div>'; 11 12 $(popupWr).appendTo('body'); 13 } 14 15 $(document).on('click', '.favorite_btn:not(.active)', function(){ 16 let $this = $(this), 17 kind_id = $this.parents('form').find('input[name="kind_id"]').val(); 18 19 20 21 if($.cookie('set_user_new_token') !='is_set' && is_user){ 22 $.cookie('s3_user_token','',{path:"/"}); 23 $.cookie('set_user_new_token','is_set'); 24 } 25 26 shop2.trigger('beforeFavoriteAddItem'); 27 28 $.ajax({ 29 url: '/-/x-api/v1/public/?method=shop2/addFavoriteProduct¶m[kind_id]=' + kind_id, 30 type: 'post', 31 dataType: 'json', 32 data: kind_id, 33 34 success: function(data) { 35 console.log(data) 36 if (data.error){ 37 alert(data.error.message) 38 return 39 } 40 let res = data.result.count; 41 let $text = /*window._s3Lang.JS_ADD_FOVARITE;*/"Ðобавлено в <a href='%s'>избÑанное</a>"; 42 43 let template_html = `<a href="${shop2.uri + '/favorites'}">${window._s3Lang.FORUM_FAVORITES}(<span>${res}</span>)</a>`; 44 45 $('.favorite_btn.active a > span').text(res); 46 $('.shop2_favorite_cart_link span').text(res); 47 $('.favorite_panel').removeClass('not-null'); 48 49 //shop2.msg($text.replace('%s', shop2.uri + '/favorites'), $this); 50 $(document).find('#shop2-msg').addClass('msg-favorite'); 51 $this.addClass('active').find('.text-favorite').replaceWith(template_html); 52 shop2.trigger('afterFavoriteAddItem', data); 53 } 54 }); 55 56 57 }); 58 59 $(document).on('click', '.favorite_btn.active .icon', function(){ 60 let kind_id = $(this).parents('form').find('input[name="kind_id"]').val(); 61 //popupDeleteFavorite(kind_id); // ÐÑплÑваÑÑее окно ÑÐ´Ð°Ð»ÐµÐ½Ð¸Ñ Ð¸Ð· избÑанного. 62 63 // Удаление без вÑплÑваÑÑего окна 64 var product = $('body').find('form input[value="' + kind_id + '"]').closest('form'), 65 button = product.find('.favorite_btn'); 66 67 // ÐÐ»Ñ Ð¿Ð¾Ð¿Ñавки еÑли авÑоÑизованнÑй полÑÐ·Ð¾Ð²Ð°Ð»Ñ Ñак же добавлÑл избÑанное как не аквÑоÑизованнÑй 68 if($.cookie('set_user_new_token') !='is_set' && is_user){ 69 $.cookie('s3_user_token','',{path:"/"}); 70 $.cookie('set_user_new_token','is_set'); 71 } 72 shop2.trigger('beforeFavoriteRemoveItem'); 73 74 $.ajax({ 75 url: '/-/x-api/v1/public/?method=shop2/removeFavoriteProduct¶m[kind_id]=' + kind_id, 76 type: 'post', 77 dataType: 'json', 78 data: kind_id, 79 success: function(data) { 80 let res = data.result.count; 81 let temlate = `<span class="text-favorite">${window._s3Lang.ADD_TO_FAVORITE}</span>`; 82 $('.favorite_btn.active a > span').text(res); 83 $('.shop2_favorite_cart_link span').text(res); 84 if (res == 0){ 85 $('.favorite_panel').addClass('not-null'); 86 } 87 button.removeClass('active'); 88 button.find('a').replaceWith(temlate); 89 90 shop2.trigger('afterFavoriteRemoveItem', data); 91 } 92 }); 93 // Удаление без вÑплÑваÑÑего окна 94 }); 95 96 $(document).on('click', '.delete_fovorite', function(){ 97 var kind_id = $(this).data('kind_id'), 98 product = $('body').find('form input[value="' + kind_id + '"]').closest('form'), 99 button = product.find('.favorite_btn'); 100 101 // ÐÐ»Ñ Ð¿Ð¾Ð¿Ñавки еÑли авÑоÑизованнÑй полÑÐ·Ð¾Ð²Ð°Ð»Ñ Ñак же добавлÑл избÑанное как не аквÑоÑизованнÑй 102 if($.cookie('set_user_new_token') !='is_set' && is_user){ 103 $.cookie('s3_user_token','',{path:"/"}); 104 $.cookie('set_user_new_token','is_set'); 105 } 106 107 108 shop2.trigger('beforeFavoriteRemoveItem'); 109 110 $.ajax({
111 url: '/-/x-api/v1/public/?method=shop2/removeFavoriteProduct¶m[kind_id]=' + kind_id, 112 type: 'post', 113 dataType: 'json', 114 data: kind_id, 115 success: function(data) { 116 let res = data.result.count; 117 let temlate = `<span class="text-favorite">${window._s3Lang.ADD_TO_FAVORITE}</span>`; 118 $('.favorite_btn.active a > span').text(res); 119 $('.shop2_favorite_cart_link span').text(res); 120 if (res == 0){ 121 $('.favorite_panel').addClass('not-null'); 122 } 123 button.removeClass('active'); 124 button.find('a').replaceWith(temlate); 125 126 shop2.trigger('afterFavoriteRemoveItem', data); 127 } 128 }); 129 130 131 $('.shop2-popup_favorite').remove(); 132 }); 133 134 $(document).on('click', '.close_favorite', function(){ 135 $('.shop2-popup_favorite').remove(); 136 }); 137 138 $(document).on('click', '.shop2-btn_popup_favorite', function(e){ 139 popupClearFavorite(); 140 e.preventDefault(); 141 }); 142 143 $(document).on('click', '.clear_fovorite', function(e){ 144 if($.cookie('set_user_new_token') !='is_set' && is_user){ 145 $.cookie('s3_user_token','',{path:"/"}); 146 $.cookie('set_user_new_token','is_set'); 147 } 148 $.ajax({ 149 url: '/-/x-api/v1/public/?method=shop2/clearFavoriteProducts', 150 type: 'post', 151 dataType: 'json', 152 success: function(data) { 153 154 } 155 }); 156 location.reload() 157 }); 158}; 159 160shop2.on('afterFavoriteAddItem', function(d){ 161 $(document).find('.favorite_top .favorite_link span').text(d.result.count) 162 if (d.result.count>0){ 163 $(document).find('.favorite_top').removeClass('is-null'); 164 } 165}); 166 167shop2.on('afterFavoriteRemoveItem', function(d){ 168 $(document).find('.favorite_top .favorite_link span').text(d.result.count) 169 if (d.result.count==0){ 170 $(document).find('.favorite_top').addClass('is-null'); 171 } 172});
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.