// removed console.log()

This commit is contained in:
Kevin Granger committed 2013-12-06 17:18:20 +01:00
1 parent 9f106d06ef
commit ed5496479d
1 file changed
+20 -19
@@ -23,49 +23,52 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
function addToCompare(productId){ function addToCompare(productId) {
var totalValueNow = parseInt($('.bt_compare').next('.compare_product_count').val()); var totalValueNow = parseInt($('.bt_compare').next('.compare_product_count').val());
var action, totalVal;
$.inArray(parseInt(productId),comparedProductsIds) == -1?action = 'add':action = 'remove'; if($.inArray(parseInt(productId),comparedProductsIds) === -1){
action = 'add';
}
else {
action = 'remove';
}
$.ajax({ $.ajax({
url: 'index.php?controller=products-comparison&ajax=1&action='+action+'&id_product=' + productId, url: 'index.php?controller=products-comparison&ajax=1&action='+action+'&id_product=' + productId,
async: true, async: true,
cache: false, cache: false,
success: function(data){ success: function(data) {
if (action == 'add' && comparedProductsIds.length < comparator_max_item) { if (action === 'add' && comparedProductsIds.length < comparator_max_item) {
comparedProductsIds.push(parseInt(productId)), comparedProductsIds.push(parseInt(productId)),
compareButtonsStatusRefresh(), compareButtonsStatusRefresh(),
totalVal = totalValueNow +1, totalVal = totalValueNow +1,
$('.bt_compare').next('.compare_product_count').val(totalVal), $('.bt_compare').next('.compare_product_count').val(totalVal),
totalValue(totalVal) totalValue(totalVal);
} }
else if (action == 'remove') { else if (action === 'remove') {
comparedProductsIds.splice($.inArray(parseInt(productId),comparedProductsIds), 1), comparedProductsIds.splice($.inArray(parseInt(productId),comparedProductsIds), 1),
compareButtonsStatusRefresh(), compareButtonsStatusRefresh(),
totalVal = totalValueNow -1, totalVal = totalValueNow -1,
$('.bt_compare').next('.compare_product_count').val(totalVal), $('.bt_compare').next('.compare_product_count').val(totalVal),
totalValue(totalVal) totalValue(totalVal);
} }
else { else {
alert(max_item) alert(max_item);
} }
}, },
error: function(){} error: function(){}
}); });
} }
function compareButtonsStatusRefresh(){ function compareButtonsStatusRefresh() {
$('.addToCompare').each(function() { $('.addToCompare').each(function() {
console.log($(this).data('id-product')); if ($.inArray(parseInt($(this).data('id-product')),comparedProductsIds)!== -1) {
if ($.inArray(parseInt($(this).data('id-product')),comparedProductsIds)!= -1){
$(this).addClass('checked'); $(this).addClass('checked');
} }
else { else {
$(this).removeClass('checked'); $(this).removeClass('checked');
} }
}) });
} }
function totalValue(value) { function totalValue(value) {
@@ -73,10 +76,8 @@ function totalValue(value) {
} }
reloadProductComparison = function() { reloadProductComparison = function() {
$('a.cmp_remove').click(function(){ $('a.cmp_remove').click(function() {
var idProduct = $(this).data('id-product'); var idProduct = $(this).data('id-product');
$.ajax({ $.ajax({
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct, url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
async: false, async: false,
@@ -86,7 +87,7 @@ reloadProductComparison = function() {
} }
}); });
}); });
} };
$(document).ready(function() { $(document).ready(function() {
compareButtonsStatusRefresh(); compareButtonsStatusRefresh();