1/* 2* 2007-2015 PrestaShop 3* 4* NOTICE OF LICENSE 5* 6* This source file is subject to the Academic Free License (AFL 3.0) 7* that is bundled with this package in the file LICENSE.txt. 8* It is also available through the world-wide-web at this URL: 9* http://opensource.org/licenses/afl-3.0.php 10* If you did not receive a copy of the license and are unable to 11* obtain it through the world-wide-web, please send an email 12* to [email protected] so we can send you a copy immediately. 13* 14* DISCLAIMER 15* 16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17* versions in the future. If you wish to customize PrestaShop for your 18* needs please refer to http://www.prestashop.com for more information. 19* 20* @author PrestaShop SA <[email protected]> 21* @copyright 2007-2015 PrestaShop SA 22* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23* International Registered Trademark & Property of PrestaShop SA 24*/ 25 26/** 27* Change product quantity 28* 29* @return void 30*/ 31function stWishlistUpdateProduct(id_st_wishlist, id_product, id_product_attribute, quantity) 32{ 33 if (typeof stmywishlist_url == 'undefined') 34 return (false); 35 $.ajax({ 36 type: 'GET', 37 url: stmywishlist_url, 38 headers: { "cache-control": "no-cache" }, 39 async: true, 40 cache: false, 41 dataType: "json", 42 data: { 43 id_product:id_product, 44 id_product_attribute:id_product_attribute, 45 quantity: quantity, 46 id_st_wishlist:id_st_wishlist, 47 ajax: 1, 48 action: 'updateProduct' 49 }, 50 success: function (resp) 51 { 52 if(resp.success==1) 53 $('.wishlist_update_quantity.active').removeClass('active').find('.hidden').removeClass('hidden'); 54 else if(!resp.success) 55 { 56 $('.wishlist_update_quantity.active').removeClass('active'); 57 stWishlistPopup(resp.message); 58 } 59 else if(resp.success==2) 60 stWishlistGoLogin(); 61 62 }, 63 error: function(XMLHttpRequest, textStatus, errorThrown) 64 { 65 $('.wishlist_update_quantity.active').removeClass('active'); 66 } 67 }); 68} 69 70/** 71* Change product quantity 72* 73* @return void 74*/ 75function stWishlistAddProduct(id_st_wishlist, id_product, id_product_attribute, quantity) 76{ 77 if (typeof stmywishlist_url == 'undefined') 78 return (false); 79 80 $.ajax({ 81 type: 'GET', 82 url: stmywishlist_url, 83 headers: { "cache-control": "no-cache" }, 84 async: true, 85 cache: false, 86 dataType: "json", 87 data: { 88 id_product:id_product, 89 id_product_attribute:id_product_attribute, 90 quantity: quantity, 91 id_st_wishlist:id_st_wishlist, 92 ajax: 1, 93 action: 'addProduct' 94 }, 95 success: function (resp) 96 { 97 $count_dom = $('.add_to_wishlit.active').find('.wishlist_product_count'); 98 if($count_dom.length) 99 $count_dom.html(resp.product_total); 100 if($('.wishlist_customer_count').length) 101 $('.wishlist_customer_count').html(resp.customer_total); 102 $('.add_to_wishlit.active').removeClass('active');//the same code also in resetSlidebar to make sure active get removed 103 $('stwish_'+id_product+'_'+id_product_attribute).addClass('st_added'); 104 105 $('#select_wishlist a[data-id-wishlist="'+id_st_wishlist+'"]').removeClass('active').addClass(typeof(resp.success)!=='undefined' && resp.success==1 ? 'st_done' : '').find('span').html(resp.current_total); 106 //$('.wishlist_link .amount_circle').html(resp.total); 107 if(!resp.success) 108 stWishlistPopup(resp.message); 109 else if(resp.success==2) 110 stWishlistGoLogin(); 111 }, 112 error: function(XMLHttpRequest, textStatus, errorThrown) 113 { 114 $('#select_wishlist a[data-id-wishlist="'+id_st_wishlist+'"]').removeClass('active'); 115 } 116 }); 117 118} 119 120function stWishlistProductRemove(id_st_wishlist, id_product, id_product_attribute) 121{ 122 if (typeof stmywishlist_url == 'undefined') 123 return (false); 124 125 $.ajax({ 126 type: 'GET', 127 url: stmywishlist_url, 128 headers: { "cache-control": "no-cache" }, 129 async: true, 130 cache: false, 131 dataType: "json", 132 data: { 133 id_product:id_product, 134 id_product_attribute:id_product_attribute, 135 id_st_wishlist:id_st_wishlist, 136 ajax: 1, 137 action: 'deleteProduct' 138 }, 139 success: function (resp) 140 { 141 if($('.wishlist_customer_count').length) 142 $('.wishlist_customer_count').html(resp.customer_total); 143 $('.wishlist_remove_product.active').removeClass('active'); 144 if (resp.success==1) { 145 $('.wishlist_product_item[data-id_wishlist='+id_st_wishlist+'][data-id_product='+id_product+']'+(id_product_attribute ? '[data-id_product_attribute='+id_product_attribute+']' : '')).empty(); 146 } 147 else if(!resp.success) 148 { 149 stWishlistPopup(resp.message); 150 } 151 else if(resp.success==2) 152 stWishlistGoLogin(); 153 }, 154 error: function(XMLHttpRequest, textStatus, errorThrown) 155 { 156 } 157 }); 158} 159 160function stWishlistSendEmail(id_st_wishlist) 161{ 162 if (typeof stmywishlist_url == 'undefined') 163 return false;
164 var email = $('#email_'+id_st_wishlist).val(); 165 if (!email) { 166 return false; 167 } 168 $.ajax({ 169 type: 'GET', 170 url: stmywishlist_url, 171 headers: { "cache-control": "no-cache" }, 172 async: true, 173 cache: false, 174 dataType: "json", 175 data: { 176 email: email, 177 id_st_wishlist:id_st_wishlist, 178 ajax: 1, 179 action: 'sendEmail' 180 }, 181 success: function (resp) 182 { 183 if (resp.success==1) { 184 $('.wishlist_share_email.active').removeClass('active').addClass('st_done'); 185 } 186 else 187 { 188 $('.wishlist_share_email').removeClass('active'); 189 stWishlistPopup(resp.message); 190 } 191 192 } 193 }); 194} 195function stWishlistPopup(msg) 196{ 197 $.magnificPopup.open({ 198 removalDelay: 500, 199 callbacks: { 200 beforeOpen: function() { 201 this.st.mainClass = 'mfp-zoom-in'; 202 } 203 }, 204 items: { 205 src: '<div class="inline_popup_content small_popup mfp-with-anim text-center">'+msg+'</div>', 206 type: 'inline' 207 } 208 }); 209} 210function stWishlistGoLogin() 211{ 212 $.magnificPopup.open({ 213 removalDelay: 500, 214 callbacks: { 215 beforeOpen: function() { 216 this.st.mainClass = 'mfp-zoom-in'; 217 } 218 }, 219 items: { 220 src: '#wishlist_go_login', 221 type: 'inline' 222 } 223 }); 224} 225function stWishUpdateInCache(){ 226 var selector = ''; 227 if(typeof(stwish_pros)!='undefined' && stwish_pros.length){ 228 selector += '.stwish_'+stwish_pros.join(',.stwish_'); 229 } 230 if(selector) 231 $(selector).addClass('st_added'); 232} 233$(document).ready(function () { 234 $('body').on('click', '.copy_wishlist_link', function (event) { 235 event.preventDefault(); 236 $(this).siblings('.form-control').select(); 237 document.execCommand("copy"); 238 return false; 239 }); 240 $('body').on('click', '.wishlist_update_quantity', function (event) { 241 event.preventDefault(); 242 var that = $(this).closest('.wishlist_product_item'); 243 var quantity = that.find('.pro_quantity').val(); 244 if(!$.isNumeric(quantity)) 245 return false; 246 var dataset = that.data(); 247 if(dataset.id_product && dataset.id_wishlist){ 248 $(this).addClass('active'); 249 stWishlistUpdateProduct(dataset.id_wishlist,dataset.id_product,dataset.id_product_attribute, quantity); 250 } 251 }); 252 $('body').on('click', '.wishlist_remove_product', function (event) { 253 event.preventDefault(); 254 var dataset = $(this).closest('.wishlist_product_item').data(); 255 if(dataset.id_product && dataset.id_wishlist){ 256 $(this).addClass('active'); 257 stWishlistProductRemove(dataset.id_wishlist,dataset.id_product,dataset.id_product_attribute); 258 } 259 }); 260 $('body').on('click', '.wishlist_share_email', function (event) { 261 event.preventDefault(); 262 var that = $(this).addClass('active'); 263 var id_wishlist = that.data('id-wishlist'); 264 if(id_wishlist) 265 stWishlistSendEmail(id_wishlist); 266 }); 267 $('body').on('click', '.add_to_wishlit', function (event) { 268 if(typeof(prestashop)==='undefined' || !prestashop.customer.is_logged) 269 { 270 stWishlistGoLogin(); 271 return false; 272 } 273 274 $('.add_to_wishlit').removeClass('active'); 275 $(this).addClass('active'); 276 $('#select_wishlist a.saved').removeClass('saved');// 277 // 278 $('#select_wishlist a').removeClass('st_done'); 279 $('.st-container').addClass('open_bar_right'); 280 $('#side_wishlist').addClass('sidebar_opened'); 281 }); 282 283 $('body').on('click', '#select_wishlist a', function (event) { 284 event.preventDefault(); 285 if($('#select_wishlist a.active').length) 286 return false; 287 var wishlist_btn = $('.add_to_wishlit.active'); 288 var id_product = wishlist_btn.data('id-product'); 289 var id_product_attribute = wishlist_btn.data('id-product-attribute'); 290 var id_wishlist = $(this).addClass('active').data('id-wishlist'); 291 stWishlistAddProduct(id_wishlist,id_product,id_product_attribute); 292 return false;
293 }); 294 295 $('#side_wishlist_submit').click(function(event){ 296 event.preventDefault(); 297 var name = $(this).closest('.form-group').find('.form-control').val(); 298 if(!name) { 299 return false; 300 } 301 $(this).addClass('active'); 302 $.ajax({ 303 type: 'GET', 304 url: stmywishlist_url, 305 headers: { "cache-control": "no-cache" }, 306 async: true, 307 cache: false, 308 dataType: "json", 309 data: { 310 name: name, 311 ajax: 1, 312 action: 'createWishlist' 313 }, 314 success: function (resp) 315 { 316 $('#side_wishlist_submit').removeClass('active'); 317 if(resp.success==2) 318 stWishlistGoLogin() 319 else if(resp.success==1) { 320 $('#select_wishlist').append(resp.data); 321 } 322 /*do not use pop when sidebar is opened 323 else 324 stWishlistPopup(resp.message);*/ 325 }, 326 error: function(XMLHttpRequest, textStatus, errorThrown) 327 { 328 $('#side_wishlist_submit').removeClass('active'); 329 } 330 }); 331 332 return false; 333 }); 334 335 prestashop.on('updatedProduct', function (event) { 336 $('.wishlist_product').data('id-product-attribute', event.id_product_attribute); 337 }); 338 stWishUpdateInCache(); 339});
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.