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* Update WishList Cart by adding, deleting, updating objects 28* 29* @return void 30*/ 31//global variables 32var wishlistProductsIds = []; 33$(document).ready(function(){ 34 wishlistRefreshStatus(); 35 36 $(document).on('change', 'select[name=wishlists]', function(){ 37 WishlistChangeDefault('wishlist_block_list', $(this).val()); 38 }); 39 40 $("#wishlist_button").popover({ 41 html: true, 42 content: function () { 43 return $("#popover-content").html(); 44 } 45 }); 46 47 $('.wishlist').each(function() { 48 current = $(this); 49 $(this).children('.wishlist_button_list').popover({ 50 html: true, 51 content: function () { 52 return current.children('.popover-content').html(); 53 } 54 }); 55 }); 56}); 57 58function WishlistCart( element, id, action, id_product, id_product_attribute, quantity, id_wishlist) 59{ 60 var id_product_attribute_select = $(element).parent().parent().find(".ajax_add_to_cart_button").attr("data-id-product-attribute"); 61 console.log(id_product_attribute_select); 62 $.ajax({ 63 type: 'GET', 64 url: baseDir + 'modules/blockwishlist/cart.php?rand=' + new Date().getTime(), 65 headers: { "cache-control": "no-cache" }, 66 async: true, 67 cache: false, 68 data: 'action=' + action + '&id_product=' + id_product + '&quantity=' + quantity + '&token=' + static_token + '&id_product_attribute=' + id_product_attribute_select + '&id_wishlist=' + id_wishlist, 69 success: function(data) 70 { 71 if (action == 'add') 72 { 73 if (isLogged == true) { 74 wishlistProductsIdsAdd(id_product); 75 wishlistRefreshStatus(); 76 77 if (!!$.prototype.fancybox) 78 $.fancybox.open([ 79 { 80 type: 'inline', 81 autoScale: true, 82 minHeight: 30, 83 content: '<p class="fancybox-error">' + added_to_wishlist + '</p>' 84 } 85 ], { 86 padding: 0 87 }); 88 else 89 alert(added_to_wishlist); 90 } 91 else 92 { 93 if (!!$.prototype.fancybox) 94 $.fancybox.open([ 95 { 96 type: 'inline', 97 autoScale: true, 98 minHeight: 30, 99 content: '<p class="fancybox-error">' + loggin_required + '</p>' 100 } 101 ], { 102 padding: 0 103 }); 104 else 105 alert(loggin_required); 106 } 107 }
108 if (action == 'delete') { 109 wishlistProductsIdsRemove(id_product); 110 wishlistRefreshStatus(); 111 } 112 if($('#' + id).length != 0) 113 { 114 $('#' + id).slideUp('normal'); 115 document.getElementById(id).innerHTML = data; 116 $('#' + id).slideDown('normal'); 117 } 118 } 119 }); 120} 121 122/** 123* Change customer default wishlist 124* 125* @return void 126*/ 127function WishlistChangeDefault(id, id_wishlist) 128{ 129 $.ajax({ 130 type: 'GET', 131 url: baseDir + 'modules/blockwishlist/cart.php?rand=' + new Date().getTime(), 132 headers: { "cache-control": "no-cache" }, 133 async: true, 134 data: 'id_wishlist=' + id_wishlist + '&token=' + static_token, 135 cache: false, 136 success: function(data) 137 { 138 $('#' + id).slideUp('normal'); 139 document.getElementById(id).innerHTML = data; 140 $('#' + id).slideDown('normal'); 141 } 142 }); 143} 144 145/** 146* Buy Product 147* 148* @return void 149*/ 150function WishlistBuyProduct(token, id_product, id_product_attribute, id_quantity, button, ajax) 151{ 152 if(ajax) 153 ajaxCart.add(id_product, id_product_attribute, false, button, 1, [token, id_quantity]); 154 else 155 { 156 $('#' + id_quantity).val(0); 157 WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity) 158 document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].method='POST'; 159 document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].action=baseUri + '?controller=cart'; 160 document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].elements['token'].value = static_token; 161 document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].submit(); 162 } 163 return (true); 164} 165 166function WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity) 167{ 168 if ($('#' + id_quantity).val() <= 0) 169 return (false); 170 171 $.ajax({ 172 type: 'GET', 173 url: baseDir + 'modules/blockwishlist/buywishlistproduct.php?rand=' + new Date().getTime(), 174 headers: { "cache-control": "no-cache" }, 175 data: 'token=' + token + '&static_token=' + static_token + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute, 176 async: true, 177 cache: false, 178 success: function(data) 179 { 180 if (data) 181 { 182 if (!!$.prototype.fancybox) 183 $.fancybox.open([ 184 { 185 type: 'inline', 186 autoScale: true, 187 minHeight: 30, 188 content: '<p class="fancybox-error">' + data + '</p>' 189 } 190 ], { 191 padding: 0 192 }); 193 else 194 alert(data); 195 } 196 else 197 $('#' + id_quantity).val($('#' + id_quantity).val() - 1); 198 } 199 }); 200 201 return (true); 202} 203 204/** 205* Show wishlist managment page 206* 207* @return void 208*/ 209function WishlistManage(id, id_wishlist) 210{ 211 $.ajax({ 212 type: 'GET', 213 async: true, 214 url: baseDir + 'modules/blockwishlist/managewishlist.php?rand=' + new Date().getTime(), 215 headers: { "cache-control": "no-cache" }, 216 data: 'id_wishlist=' + id_wishlist + '&refresh=' + false, 217 cache: false, 218 success: function(data) 219 { 220 $('#' + id).hide(); 221 document.getElementById(id).innerHTML = data; 222 $('#' + id).fadeIn('slow'); 223 224 $('.wishlist_change_button').each(function(index) { 225 $(this).popover({ 226 html: true, 227 content: function () { 228 return $(this).next('.popover-content').html(); 229 } 230 }); 231 }); 232 } 233 }); 234 235} 236 237/** 238* Show wishlist product managment page 239* 240* @return void 241*/ 242function WishlistProductManage(id, action, id_wishlist, id_product, id_product_attribute, quantity, priority) 243{ 244 $.ajax({ 245 type: 'GET', 246 async: true, 247 url: baseDir + 'modules/blockwishlist/managewishlist.php?rand=' + new Date().getTime(), 248 headers: { "cache-control": "no-cache" }, 249 data: 'action=' + action + '&id_wishlist=' + id_wishlist + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute + '&quantity=' + quantity + '&priority=' + priority + '&refresh=' + true, 250 cache: false, 251 success: function(data) 252 { 253 if (action == 'delete') 254 $('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast'); 255 else if (action == 'update') 256 { 257 $('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast'); 258 $('#wlp_' + id_product + '_' + id_product_attribute).fadeIn('fast'); 259 } 260 nb_products = 0; 261 $("[id^='quantity']").each(function(index, element){ 262 nb_products += parseInt(element.value); 263 }); 264 $("#wishlist_"+id_wishlist).children('td').eq(1).html(nb_products); 265 } 266 }); 267} 268 269/** 270* Delete wishlist 271* 272* @return boolean succeed 273*/ 274function WishlistDelete(id, id_wishlist, msg) 275{ 276 var res = confirm(msg); 277 if (res == false) 278 return (false); 279 280 if (typeof mywishlist_url == 'undefined') 281 return (false); 282 283 $.ajax({ 284 type: 'GET', 285 async: true, 286 dataType: "json", 287 url: mywishlist_url, 288 headers: { "cache-control": "no-cache" }, 289 cache: false, 290 data: { 291 rand: new Date().getTime(), 292 deleted: 1, 293 myajax: 1, 294 id_wishlist: id_wishlist, 295 action: 'deletelist' 296 }, 297 success: function(data) 298 { 299 var mywishlist_siblings_count = $('#' + id).siblings().length; 300 $('#' + id).fadeOut('slow').remove(); 301 $("#block-order-detail").html(''); 302 if (mywishlist_siblings_count == 0) 303 $("#block-history").remove(); 304 305 if (data.id_default) 306 { 307 var td_default = $("#wishlist_"+data.id_default+" > .wishlist_default"); 308 $("#wishlist_"+data.id_default+" > .wishlist_default > a").remove(); 309 td_default.append('<p class="is_wish_list_default"><i class="icon icon-check-square"></i></p>'); 310 } 311 } 312 }); 313} 314 315function WishlistDefault(id, id_wishlist) 316{ 317 if (typeof mywishlist_url == 'undefined') 318 return (false); 319 320 $.ajax({ 321 type: 'GET', 322 async: true, 323 url: mywishlist_url, 324 headers: { "cache-control": "no-cache" }, 325 cache: false, 326 data: { 327 rand:new Date().getTime(), 328 'default': 1, 329 id_wishlist:id_wishlist, 330 myajax: 1, 331 action: 'setdefault' 332 }, 333 success: function (data) 334 { 335 var old_default_id = $(".is_wish_list_default").parents("tr").attr("id"); 336 var td_check = $(".is_wish_list_default").parent(); 337 $(".is_wish_list_default").remove(); 338 td_check.append('<a href="#" onclick="javascript:event.preventDefault();(WishlistDefault(\''+old_default_id+'\', \''+old_default_id.replace("wishlist_", "")+'\'));"><i class="icon icon-square"></i></a>'); 339 var td_default = $("#"+id+" > .wishlist_default"); 340 $("#"+id+" > .wishlist_default > a").remove(); 341 td_default.append('<p class="is_wish_list_default"><i class="icon icon-check-square"></i></p>'); 342 } 343 }); 344} 345 346/** 347* Hide/Show bought product 348* 349* @return void 350*/ 351function WishlistVisibility(bought_class, id_button) 352{ 353 if ($('#hide' + id_button).is(':hidden')) 354 { 355 $('.' + bought_class).slideDown('fast'); 356 $('#show' + id_button).hide(); 357 $('#hide' + id_button).css('display', 'block'); 358 } 359 else 360 { 361 $('.' + bought_class).slideUp('fast'); 362 $('#hide' + id_button).hide(); 363 $('#show' + id_button).css('display', 'block'); 364 } 365} 366 367/** 368* Send wishlist by email 369* 370* @return void 371*/ 372function WishlistSend(id, id_wishlist, id_email) 373{ 374 $.post( 375 baseDir + 'modules/blockwishlist/sendwishlist.php', 376 { 377 token: static_token, 378 id_wishlist: id_wishlist, 379 email1: $('#' + id_email + '1').val(), 380 email2: $('#' + id_email + '2').val(), 381 email3: $('#' + id_email + '3').val(), 382 email4: $('#' + id_email + '4').val(), 383 email5: $('#' + id_email + '5').val(), 384 email6: $('#' + id_email + '6').val(), 385 email7: $('#' + id_email + '7').val(), 386 email8: $('#' + id_email + '8').val(), 387 email9: $('#' + id_email + '9').val(), 388 email10: $('#' + id_email + '10').val() 389 }, 390 function(data) 391 { 392 if (data) 393 { 394 if (!!$.prototype.fancybox) 395 $.fancybox.open([ 396 { 397 type: 'inline', 398 autoScale: true, 399 minHeight: 30, 400 content: '<p class="fancybox-error">' + data + '</p>' 401 } 402 ], { 403 padding: 0 404 }); 405 else 406 alert(data); 407 } 408 else 409 WishlistVisibility(id, 'hideSendWishlist'); 410 } 411 ); 412} 413 414function wishlistProductsIdsAdd(id) 415{ 416 if ($.inArray(parseInt(id),wishlistProductsIds) == -1) 417 wishlistProductsIds.push(parseInt(id)) 418} 419 420function wishlistProductsIdsRemove(id) 421{ 422 wishlistProductsIds.splice($.inArray(parseInt(id),wishlistProductsIds), 1) 423} 424 425function wishlistRefreshStatus() 426{ 427 $('.addToWishlist').each(function(){ 428 if ($.inArray(parseInt($(this).prop('rel')),wishlistProductsIds)!= -1) 429 $(this).addClass('checked'); 430 else 431 $(this).removeClass('checked'); 432 }); 433} 434 435function wishlistProductChange(id_product, id_product_attribute, id_old_wishlist, id_new_wishlist) 436{ 437 if (typeof mywishlist_url == 'undefined') 438 return (false); 439 440 var quantity = $('#quantity_' + id_product + '_' + id_product_attribute).val(); 441 442 $.ajax({ 443 type: 'GET', 444 url: mywishlist_url, 445 headers: { "cache-control": "no-cache" }, 446 async: true, 447 cache: false, 448 dataType: "json", 449 data: { 450 id_product:id_product, 451 id_product_attribute:id_product_attribute, 452 quantity: quantity, 453 priority: $('#priority_' + id_product + '_' + id_product_attribute).val(), 454 id_old_wishlist:id_old_wishlist, 455 id_new_wishlist:id_new_wishlist, 456 myajax: 1, 457 action: 'productchangewishlist' 458 }, 459 success: function (data) 460 { 461 if (data.success == true) { 462 $('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('slow'); 463 $('#wishlist_' + id_old_wishlist + ' td:nth-child(2)').text($('#wishlist_' + id_old_wishlist + ' td:nth-child(2)').text() - quantity); 464 $('#wishlist_' + id_new_wishlist + ' td:nth-child(2)').text(+$('#wishlist_' + id_new_wishlist + ' td:nth-child(2)').text() + +quantity); 465 } 466 else 467 {
468 if (!!$.prototype.fancybox) 469 $.fancybox.open([ 470 { 471 type: 'inline', 472 autoScale: true, 473 minHeight: 30, 474 content: '<p class="fancybox-error">' + data.error + '</p>' 475 } 476 ], { 477 padding: 0 478 }); 479 } 480 } 481 }); 482}
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.