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$(document).ready(function(){ 26 $(document).on('click', '.add_to_compare', function(e){ 27 e.preventDefault(); 28 //Leotheme edit: add product name when add to compare 29 if (typeof addToCompare != 'undefined') 30 addToCompare(parseInt($(this).data('id-product')),$.trim($(this).parents('.product-container').find('.product-name').html())); 31 32 }); 33 34 reloadProductComparison(); 35 compareButtonsStatusRefresh(); 36 totalCompareButtons(); 37}); 38 39//Leotheme edit: add product name when add to compare 40function addToCompare(productId, productName) 41{ 42 var totalValueNow = parseInt($('.bt_compare').next('.compare_product_count').val()); 43 var action, totalVal; 44 //Leotheme add: get url of compare page for popup 45 if(mywishlist_url.indexOf('module/blockwishlist/mywishlist') != -1) 46 { 47 var url_list_comapre = mywishlist_url.replace('module/blockwishlist/mywishlist',''); 48 } 49 else 50 { 51 var url_list_comapre = baseUri+'?controller='; 52 } 53 54 if ($.inArray(parseInt(productId),comparedProductsIds) === -1) 55 action = 'add'; 56 else 57 action = 'remove'; 58 59 $.ajax({ 60 url: baseUri + '?controller=products-comparison&ajax=1&action=' + action + '&id_product=' + productId, 61 async: true, 62 cache: false, 63 success: function(data) { 64 if (action === 'add' && comparedProductsIds.length < comparator_max_item) { 65 comparedProductsIds.push(parseInt(productId)), 66 compareButtonsStatusRefresh(), 67 totalVal = totalValueNow +1, 68 $('.bt_compare').next('.compare_product_count').val(totalVal), 69 totalValue(totalVal); 70 //Leotheme add: update number product on icon compare 71 var old_num_compare = parseInt($('.ap-btn-compare .ap-total-compare').text()); 72 $('.ap-btn-compare .ap-total-compare').text(old_num_compare+1); 73 //Leotheme add: create content for popup after add compare 74 var content_alert = 'The product <strong>'+productName+'</strong> has been added to list compare. <a href="'+url_list_comapre+'products-comparison"><strong>Click to view list compare</strong></a>'; 75 if (!!$.prototype.fancybox) 76 $.fancybox.open([{ 77 type: 'inline', 78 autoScale: true, 79 minHeight: 30, 80 content: '<p class="fancybox-error">' + content_alert + '</p>' 81 }], { 82 padding: 0 83 }); 84 else 85 alert(content_alert); 86 87 } 88 else if (action === 'remove') { 89 comparedProductsIds.splice($.inArray(parseInt(productId), comparedProductsIds), 1), 90 compareButtonsStatusRefresh(), 91 totalVal = totalValueNow -1, 92 $('.bt_compare').next('.compare_product_count').val(totalVal), 93 totalValue(totalVal); 94 //Leotheme add: update number product on icon compare 95 var old_num_compare = parseInt($('.ap-btn-compare .ap-total-compare').text()); 96 $('.ap-btn-compare .ap-total-compare').text(old_num_compare-1); 97 //Leotheme add: create content for popup after remove from compare 98 var content_alert = 'The product <strong>'+productName+'</strong> has been removed from list compare. <a href="'+url_list_comapre+'products-comparison"><strong>Click to view list compare</strong></a>'; 99 if (!!$.prototype.fancybox) 100 $.fancybox.open([{ 101 type: 'inline', 102 autoScale: true, 103 minHeight: 30, 104 content: '<p class="fancybox-error">' + content_alert + '</p>' 105 }], { 106 padding: 0 107 }); 108 else 109 alert(content_alert); 110 111 } 112 else 113 { 114 if (!!$.prototype.fancybox) 115 $.fancybox.open([{ 116 type: 'inline', 117 autoScale: true, 118 minHeight: 30, 119 content: '<p class="fancybox-error">' + max_item + '</p>' 120 }], { 121 padding: 0 122 }); 123 else 124 alert(max_item); 125 } 126 totalCompareButtons(); 127 }, 128 error: function(){} 129 }); 130} 131 132function reloadProductComparison() 133{ 134 $(document).on('click', 'a.cmp_remove', function(e){ 135 e.preventDefault(); 136 var idProduct = parseInt($(this).data('id-product')); 137 $.ajax({ 138 url: baseUri + '?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct, 139 async: false, 140 cache: false 141 }); 142 $('td.product-' + idProduct).fadeOut(600); 143 144 var compare_product_list = get('compare_product_list'); 145 var bak = compare_product_list; 146 var new_compare_product_list = []; 147 compare_product_list = decodeURIComponent(compare_product_list).split('|'); 148 for (var i in compare_product_list) 149 if (parseInt(compare_product_list[i]) != idProduct) 150 new_compare_product_list.push(compare_product_list[i]); 151 if (new_compare_product_list.length) 152 window.location.search = window.location.search.replace(bak, new_compare_product_list.join(encodeURIComponent('|'))); 153 }); 154}; 155 156function compareButtonsStatusRefresh() 157{ 158 $('.add_to_compare').each(function() { 159 if ($.inArray(parseInt($(this).data('id-product')), comparedProductsIds) !== -1) 160 $(this).addClass('checked'); 161 else 162 $(this).removeClass('checked'); 163 }); 164} 165 166function totalCompareButtons() 167{ 168 var totalProductsToCompare = parseInt($('.bt_compare .total-compare-val').html());
169 if (typeof totalProductsToCompare !== "number" || totalProductsToCompare === 0) 170 $('.bt_compare').attr("disabled",true); 171 else 172 $('.bt_compare').attr("disabled",false); 173} 174 175function totalValue(value) 176{ 177 $('.bt_compare').find('.total-compare-val').html(value); 178} 179 180function get(name) 181{ 182 var regexS = "[\\?&]" + name + "=([^&#]*)"; 183 var regex = new RegExp(regexS); 184 var results = regex.exec(window.location.search); 185 186 if (results == null) 187 return ""; 188 else 189 return results[1]; 190}
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.