From 2b6b65a3032a5168a6963e384cd7f13adf34b644 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Thu, 1 Aug 2013 14:27:50 +0200 Subject: [PATCH] // norms --- themes/default/js/cart-summary.js | 155 +++++++++++++++--------------- themes/default/product.tpl | 2 +- 2 files changed, 78 insertions(+), 79 deletions(-) diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index 218faf25a..206e20737 100644 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -76,7 +76,7 @@ function changeAddressDelivery(obj) if (new_id_address_delivery == old_id_address_delivery) return; - + if (new_id_address_delivery > 0) // Change the delivery address { $.ajax({ @@ -86,24 +86,24 @@ function changeAddressDelivery(obj) async: true, cache: false, dataType: 'json', - data: 'controller=cart&ajax=true&changeAddressDelivery=1&summary=1&id_product='+id_product - +'&id_product_attribute='+id_product_attribute - +'&old_id_address_delivery='+old_id_address_delivery - +'&new_id_address_delivery='+new_id_address_delivery - +'&token='+static_token - +'&allow_refresh=1', + data: 'controller=cart&ajax=true&changeAddressDelivery=1&summary=1&id_product=' + id_product + + '&id_product_attribute='+id_product_attribute + + '&old_id_address_delivery='+old_id_address_delivery + + '&new_id_address_delivery='+new_id_address_delivery + + '&token='+static_token + + '&allow_refresh=1', success: function(jsonData) { if (typeof(jsonData.hasErrors) != 'undefined' && jsonData.hasErrors) { alert(jsonData.error); // Reset the old address - $('#select_address_delivery_'+id_product+'_'+id_product_attribute+'_'+old_id_address_delivery).val(old_id_address_delivery); + $('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery).val(old_id_address_delivery); } else { // The product exist - if ($('#product_'+id_product+'_'+id_product_attribute+'_0_'+new_id_address_delivery).length) + if ($('#product_' + id_product + '_' + id_product_attribute + '_0_' + new_id_address_delivery).length) { updateCartSummary(jsonData.summary); if (window.ajaxCart != undefined) @@ -116,10 +116,10 @@ function changeAddressDelivery(obj) // @todo reverse the remove order // This effect remove the current line, but it's better to remove the other one, and refresshing this one - $('#product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove(); + $('#product_' + id_product + '_' + id_product_attribute + '_0_' + old_id_address_delivery).remove(); // @todo improve customization upgrading - $('.product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove(); + $('.product_' + id_product + '_' + id_product_attribute + '_0_' + old_id_address_delivery).remove(); } if (window.ajaxCart != undefined) ajaxCart.updateCart(jsonData); @@ -142,7 +142,7 @@ function changeAddressDelivery(obj) // Get new address to deliver var id_address_delivery = 0; - var options = $('#select_address_delivery_'+id_product+'_'+id_product_attribute+'_'+old_id_address_delivery+' option'); + var options = $('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery + ' option'); $.each(options, function(i) { // Check the address is not already used for a similare products if ($(options[i]).val() > 0 && $(options[i]).val() !== old_id_address_delivery && $('#product_' + id_product + '_' + id_product_attribute + '_0_' + $(options[i]).val()).length == 0) @@ -161,13 +161,13 @@ function changeAddressDelivery(obj) dataType: 'json', context: obj, data: 'controller=cart' - +'&ajax=true&duplicate=true&summary=true' - +'&id_product='+id_product - +'&id_product_attribute='+id_product_attribute - +'&id_address_delivery='+old_id_address_delivery - +'&new_id_address_delivery='+id_address_delivery - +'&token='+static_token - +'&allow_refresh=1', + + '&ajax=true&duplicate=true&summary=true' + + '&id_product='+id_product + + '&id_product_attribute='+id_product_attribute + + '&id_address_delivery='+old_id_address_delivery + + '&new_id_address_delivery='+id_address_delivery + + '&token='+static_token + + '&allow_refresh=1', success: function(jsonData) { if (jsonData.error) @@ -176,16 +176,16 @@ function changeAddressDelivery(obj) return; } - var line = $('#product_' + id_product+'_' + id_product_attribute + '_0_' + old_id_address_delivery); + var line = $('#product_' + id_product + '_' + id_product_attribute + '_0_' + old_id_address_delivery); var new_line = line.clone(); updateAddressId(id_product, id_product_attribute, old_id_address_delivery, id_address_delivery, new_line); line.after(new_line); - new_line.find('input[name=quantity_' + id_product+'_' + id_product_attribute + '_0_' + old_id_address_delivery + '_hidden]') + new_line.find('input[name=quantity_' + id_product + '_' + id_product_attribute + '_0_' + old_id_address_delivery + '_hidden]') .val(1); new_line.find('.cart_quantity_input') .val(1); - $('#select_address_delivery_' + id_product+'_' + id_product_attribute + '_' + old_id_address_delivery).val(old_id_address_delivery); - $('#select_address_delivery_' + id_product+'_' + id_product_attribute + '_' + id_address_delivery).val(id_address_delivery); + $('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery).val(old_id_address_delivery); + $('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + id_address_delivery).val(id_address_delivery); cleanSelectAddressDelivery(); @@ -201,7 +201,6 @@ function changeAddressDelivery(obj) function updateAddressId(id_product, id_product_attribute, old_id_address_delivery, id_address_delivery, line) { - if (typeof(line) == 'undefined' || line.length == 0) line = $('#cart_summary tr[id^=product_' + id_product + '_' + id_product_attribute + '_0_], #cart_summary tr[id^=product_' + id_product + '_' + id_product_attribute + '_nocustom_]'); @@ -253,8 +252,8 @@ function updateQty(val, cart, el) if (exp.test(val) == true) { - var hidden = $(prefix+'input[name='+ id +'_hidden]').val(); - var input = $(prefix+'input[name='+ id +']').val(); + var hidden = $(prefix + 'input[name=' + id + '_hidden]').val(); + var input = $(prefix + 'input[name=' + id + ']').val(); var QtyToUp = parseInt(input) - parseInt(hidden); if (parseInt(QtyToUp) > 0) @@ -263,7 +262,7 @@ function updateQty(val, cart, el) downQuantity(id.replace('quantity_', ''), QtyToUp); } else - $(prefix+'input[name='+ id +']').val($(prefix+'input[name='+ id +'_hidden]').val()); + $(prefix + 'input[name=' + id + ']').val($(prefix + 'input[name=' + id + '_hidden]').val()); if (typeof(getCarrierListAndUpdate) !== 'undefined') getCarrierListAndUpdate(); @@ -292,13 +291,13 @@ function deleteProductFromSummary(id) cache: false, dataType: 'json', data: 'controller=cart' - +'&ajax=true&delete=true&summary=true' - +'&id_product='+productId - +'&ipa='+productAttributeId - +'&id_address_delivery='+id_address_delivery + + '&ajax=true&delete=true&summary=true' + + '&id_product='+productId + + '&ipa='+productAttributeId + + '&id_address_delivery='+id_address_delivery + ((customizationId !== 0) ? '&id_customization=' + customizationId : '') - +'&token=' + static_token - +'&allow_refresh=1', + + '&token=' + static_token + + '&allow_refresh=1', success: function(jsonData) { if (jsonData.hasError) @@ -333,7 +332,7 @@ function deleteProductFromSummary(id) } else { - $('#product_'+ id).fadeOut('slow', function() { + $('#product_' + id).fadeOut('slow', function() { $(this).remove(); cleanSelectAddressDelivery(); if (!customizationId) @@ -437,17 +436,17 @@ function upQuantity(id, qty) cache: false, dataType: 'json', data: 'controller=cart' - +'&ajax=true' - +'&add=true' - +'&getproductprice=true' - +'&summary=true' - +'&id_product=' + productId - +'&ipa=' + productAttributeId - +'&id_address_delivery=' + id_address_delivery + + '&ajax=true' + + '&add=true' + + '&getproductprice=true' + + '&summary=true' + + '&id_product=' + productId + + '&ipa=' + productAttributeId + + '&id_address_delivery=' + id_address_delivery + ((customizationId !== 0) ? '&id_customization=' + customizationId : '') - +'&qty=' + qty - +'&token=' + static_token - +'&allow_refresh=1', + + '&qty=' + qty + + '&token=' + static_token + + '&allow_refresh=1', success: function(jsonData) { if (jsonData.hasError) @@ -486,7 +485,7 @@ function upQuantity(id, qty) function downQuantity(id, qty) { - var val = $('input[name=quantity_'+id+']').val(); + var val = $('input[name=quantity_' + id + ']').val(); var newVal = val; if(typeof(qty) == 'undefined' || !qty) { @@ -511,7 +510,7 @@ function downQuantity(id, qty) if (typeof(ids[3]) !== 'undefined') id_address_delivery = parseInt(ids[3]); - if (newVal > 0 || $('#product_'+id+'_gift').length) + if (newVal > 0 || $('#product_' + id + '_gift').length) { $.ajax({ type: 'POST', @@ -521,18 +520,18 @@ function downQuantity(id, qty) cache: false, dataType: 'json', data: 'controller=cart' - +'&ajax=true' - +'&add=true' - +'&getproductprice=true' - +'&summary=true' - +'&id_product='+productId - +'&ipa='+productAttributeId - +'&id_address_delivery='+id_address_delivery - +'&op=down' + + '&ajax=true' + + '&add=true' + + '&getproductprice=true' + + '&summary=true' + + '&id_product='+productId + + '&ipa='+productAttributeId + + '&id_address_delivery='+id_address_delivery + + '&op=down' + ((customizationId !== 0) ? '&id_customization='+customizationId : '') - +'&qty='+qty - +'&token='+static_token - +'&allow_refresh=1', + + '&qty='+qty + + '&token='+static_token + + '&allow_refresh=1', success: function(jsonData) { if (jsonData.hasError) @@ -543,7 +542,7 @@ function downQuantity(id, qty) if(error !== 'indexOf') errors += $('
').html(jsonData.errors[error]).text() + "\n"; alert(errors); - $('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val()); + $('input[name=quantity_' + id + ']').val($('input[name=quantity_' + id + '_hidden]').val()); } else { @@ -558,7 +557,7 @@ function downQuantity(id, qty) updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); if (newVal == 0) - $('#product_'+id).hide(); + $('#product_' + id).hide(); if (typeof(getCarrierListAndUpdate) !== 'undefined') getCarrierListAndUpdate(); @@ -591,18 +590,18 @@ function updateCartSummary(json) $('div.error').fadeOut(); for (i=0;i 1 ? txtProducts : txtProduct)); + $('#summary_products_quantity').html(nbrProducts + ' ' + (nbrProducts > 1 ? txtProducts : txtProduct)); if (priceDisplayMethod !== 0) $('#total_product').html(formatCurrency(json.total_products, currencyFormat, currencySign, currencyBlank)); else @@ -772,8 +771,8 @@ function updateCustomizedDatas(json) for(var l in json[i][j][k]) { var quantity = json[i][j][k][l]['quantity']; - $('input[name=quantity_'+i+'_'+j+'_'+l+'_'+k+'_hidden]').val(quantity); - $('input[name=quantity_'+i+'_'+j+'_'+l+'_'+k+']').val(quantity); + $('input[name=quantity_' + i + '_' + j + '_' + l + '_' + k + '_hidden]').val(quantity); + $('input[name=quantity_' + i + '_' + j + '_' + l + '_' + k + ']').val(quantity); } } @@ -797,7 +796,7 @@ function refreshDeliveryOptions() carrier_id_list.pop(); var it = this; $(carrier_id_list).each(function() { - $(it).parent().find('input[value="'+this.toString()+'"]').change(); + $(it).parent().find('input[value="' + this.toString() + '"]').change(); }); } else @@ -820,9 +819,9 @@ $(document).ready(function() { async: true, cache: false, data: 'controller=cart&ajax=true&allowSeperatedPackage=true&value=' - +($(this).prop('checked') ? '1' : '0') - +'&token='+static_token - +'&allow_refresh=1', + + ($(this).prop('checked') ? '1' : '0') + + '&token='+static_token + + '&allow_refresh=1', success: function(jsonData) { if (typeof(getCarrierListAndUpdate) !== 'undefined') @@ -862,14 +861,14 @@ function updateExtraCarrier(id_delivery_option, id_address) cache: false, dataType : "json", data: 'ajax=true' - +'&method=updateExtraCarrier' - +'&id_address='+id_address - +'&id_delivery_option='+id_delivery_option - +'&token='+static_token - +'&allow_refresh=1', + + '&method=updateExtraCarrier' + + '&id_address='+id_address + + '&id_delivery_option='+id_delivery_option + + '&token='+static_token + + '&allow_refresh=1', success: function(jsonData) { - $('#HOOK_EXTRACARRIER_'+id_address).html(jsonData['content']); + $('#HOOK_EXTRACARRIER_' + id_address).html(jsonData['content']); } }); -} +} \ No newline at end of file diff --git a/themes/default/product.tpl b/themes/default/product.tpl index 508639287..a9a3ed9e4 100644 --- a/themes/default/product.tpl +++ b/themes/default/product.tpl @@ -609,7 +609,7 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving {if $field.type == 1}
  • - +
  • {counter} {/if}