[+] FO : New Responsive, Bootstrap template
This commit is contained in:
@@ -0,0 +1,874 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('.cart_quantity_up').unbind('click').live('click', function(){upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false;});
|
||||
$('.cart_quantity_down').unbind('click').live('click', function(){downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false;});
|
||||
$('.cart_quantity_delete' ).unbind('click').live('click', function(){deleteProductFromSummary($(this).attr('id')); return false;});
|
||||
$('.cart_quantity_input').typeWatch({highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el);}});
|
||||
$('.cart_address_delivery').live('change', function(){changeAddressDelivery($(this));});
|
||||
cleanSelectAddressDelivery();
|
||||
});
|
||||
|
||||
function cleanSelectAddressDelivery()
|
||||
{
|
||||
if (window.ajaxCart !== undefined)
|
||||
{
|
||||
//Removing "Ship to an other address" from the address delivery select option if there is not enought address
|
||||
$.each($('.cart_address_delivery'), function(it, item)
|
||||
{
|
||||
var options = $(item).find('option');
|
||||
var address_count = 0;
|
||||
|
||||
var ids = $(item).attr('id').split('_');
|
||||
var id_product = ids[3];
|
||||
var id_product_attribute = ids[4];
|
||||
var id_address_delivery = ids[5];
|
||||
|
||||
$.each(options, function(i) {
|
||||
if ($(options[i]).val() > 0
|
||||
&& ($('#product_' + id_product + '_' + id_product_attribute + '_0_' + $(options[i]).val()).length == 0 // Check the address is not already used for a similare products
|
||||
|| id_address_delivery == $(options[i]).val()
|
||||
)
|
||||
)
|
||||
address_count++;
|
||||
});
|
||||
|
||||
// Need at least two address to allow skipping products to multiple address
|
||||
if (address_count < 2)
|
||||
$($(item).find('option[value=-2]')).remove();
|
||||
else if($($(item).find('option[value=-2]')).length == 0)
|
||||
$(item).append($('<option value="-2">' + ShipToAnOtherAddress + '</option>'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function changeAddressDelivery(obj)
|
||||
{
|
||||
var ids = obj.attr('id').split('_');
|
||||
var id_product = ids[3];
|
||||
var id_product_attribute = ids[4];
|
||||
var old_id_address_delivery = ids[5];
|
||||
var new_id_address_delivery = obj.val();
|
||||
|
||||
if (new_id_address_delivery == old_id_address_delivery)
|
||||
return;
|
||||
|
||||
if (new_id_address_delivery > 0) // Change the delivery address
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
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',
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The product exist
|
||||
if ($('#product_' + id_product + '_' + id_product_attribute + '_0_' + new_id_address_delivery).length)
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
if (window.ajaxCart != undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
|
||||
// @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();
|
||||
|
||||
// @todo improve customization upgrading
|
||||
$('.product_' + id_product + '_' + id_product_attribute + '_0_' + old_id_address_delivery).remove();
|
||||
}
|
||||
if (window.ajaxCart != undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
updateAddressId(id_product, id_product_attribute, old_id_address_delivery, new_id_address_delivery);
|
||||
cleanSelectAddressDelivery();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (new_id_address_delivery == -1) // Adding a new address
|
||||
window.location = $($('.address_add a')[0]).attr('href');
|
||||
else if (new_id_address_delivery == -2) // Add a new line for this product
|
||||
{
|
||||
// This test is will not usefull in the future
|
||||
if (old_id_address_delivery == 0)
|
||||
{
|
||||
alert(txtSelectAnAddressFirst);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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');
|
||||
$.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)
|
||||
{
|
||||
id_address_delivery = $(options[i]).val();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
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',
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.error)
|
||||
{
|
||||
alert(jsonData.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
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]')
|
||||
.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);
|
||||
|
||||
|
||||
cleanSelectAddressDelivery();
|
||||
|
||||
updateCartSummary(jsonData.summary);
|
||||
if (window.ajaxCart !== undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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_]');
|
||||
|
||||
$('.product_customization_for_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery).each(function(){
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + id_address_delivery)).removeClass('product_customization_for_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery + ' address_' + old_id_address_delivery).addClass('product_customization_for_' + id_product + '_' + id_product_attribute + '_' + id_address_delivery + ' address_' + id_address_delivery);
|
||||
$(this).find('input[name^=quantity_]').each(function(){
|
||||
if (typeof($(this).attr('name')) != 'undefined')
|
||||
$(this).attr('name', $(this).attr('name').replace(/_\d+(_hidden|)$/, '_' + id_address_delivery));
|
||||
});
|
||||
$(this).find('a').each(function(){
|
||||
if (typeof($(this).attr('href')) != 'undefined')
|
||||
$(this).attr('href', $(this).attr('href').replace(/id_address_delivery=\d+/, 'id_address_delivery=' + id_address_delivery));
|
||||
});
|
||||
});
|
||||
|
||||
line.attr('id', line.attr('id').replace(/_\d+$/, '_' + id_address_delivery)).removeClass('address_' + old_id_address_delivery).addClass('address_' + id_address_delivery).find('span[id^=cart_quantity_custom_], span[id^=total_product_price_], input[name^=quantity_], .cart_quantity_down, .cart_quantity_up, .cart_quantity_delete').each(function(){
|
||||
|
||||
if (typeof($(this).attr('name')) != 'undefined')
|
||||
$(this).attr('name', $(this).attr('name').replace(/_\d+(_hidden|)$/, '_' + id_address_delivery));
|
||||
if (typeof($(this).attr('id')) != 'undefined')
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + id_address_delivery));
|
||||
if (typeof($(this).attr('href')) != 'undefined')
|
||||
$(this).attr('href', $(this).attr('href').replace(/id_address_delivery=\d+/, 'id_address_delivery=' + id_address_delivery));
|
||||
});
|
||||
|
||||
line.find('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery).attr('id', 'select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + id_address_delivery);
|
||||
|
||||
if (window.ajaxCart !== undefined)
|
||||
{
|
||||
$('#cart_block_list dd, #cart_block_list dt').each(function(){
|
||||
if (typeof($(this).attr('id')) != 'undefined')
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + id_address_delivery));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateQty(val, cart, el)
|
||||
{
|
||||
var prefix = "";
|
||||
|
||||
if (typeof(cart) == 'undefined' || cart)
|
||||
prefix = '#order-detail-content ';
|
||||
else
|
||||
prefix = '#fancybox-content ';
|
||||
|
||||
var id = $(el).attr('name');
|
||||
|
||||
var exp = new RegExp("^[0-9]+$");
|
||||
|
||||
if (exp.test(val) == true)
|
||||
{
|
||||
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)
|
||||
upQuantity(id.replace('quantity_', ''), QtyToUp);
|
||||
else if(parseInt(QtyToUp) < 0)
|
||||
downQuantity(id.replace('quantity_', ''), QtyToUp);
|
||||
}
|
||||
else
|
||||
$(prefix + 'input[name=' + id + ']').val($(prefix + 'input[name=' + id + '_hidden]').val());
|
||||
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
|
||||
function deleteProductFromSummary(id)
|
||||
{
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
var id_address_delivery = 0;
|
||||
var ids = 0;
|
||||
ids = id.split('_');
|
||||
productId = parseInt(ids[0]);
|
||||
if (typeof(ids[1]) !== 'undefined')
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) !== 'undefined' && ids[2] !== 'nocustom')
|
||||
customizationId = parseInt(ids[2]);
|
||||
if (typeof(ids[3]) !== 'undefined')
|
||||
id_address_delivery = parseInt(ids[3]);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
data: 'controller=cart'
|
||||
+ '&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',
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if (error !== 'indexOf')
|
||||
errors += jsonData.errors[error] + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
if (parseInt(jsonData.summary.products.length) == 0)
|
||||
{
|
||||
if (typeof(orderProcess) == 'undefined' || orderProcess !== 'order-opc')
|
||||
document.location.href = document.location.href; // redirection
|
||||
else
|
||||
{
|
||||
$('#center_column').children().each(function() {
|
||||
if ($(this).attr('id') !== 'emptyCartWarning' && $(this).attr('class') !== 'breadcrumb' && $(this).attr('id') !== 'cart_title')
|
||||
{
|
||||
$(this).fadeOut('slow', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#summary_products_label').remove();
|
||||
$('#emptyCartWarning').fadeIn('slow');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#product_' + id).fadeOut('slow', function() {
|
||||
$(this).remove();
|
||||
cleanSelectAddressDelivery();
|
||||
if (!customizationId)
|
||||
refreshOddRow();
|
||||
});
|
||||
var exist = false;
|
||||
for (i=0;i<jsonData.summary.products.length;i++)
|
||||
{
|
||||
if (jsonData.summary.products[i].id_product == productId
|
||||
&& jsonData.summary.products[i].id_product_attribute == productAttributeId
|
||||
&& jsonData.summary.products[i].id_address_delivery == id_address_delivery
|
||||
&& (parseInt(jsonData.summary.products[i].customization_quantity) > 0))
|
||||
exist = true;
|
||||
}
|
||||
// if all customization removed => delete product line
|
||||
if (!exist && customizationId)
|
||||
$('#product_' + productId + '_' + productAttributeId + '_0_' + id_address_delivery).fadeOut('slow', function() {
|
||||
$(this).remove();
|
||||
var line = $('#product_' + productId + '_' + productAttributeId + '_nocustom_' + id_address_delivery);
|
||||
if (line.length > 0)
|
||||
{
|
||||
line.find('input[name^=quantity_], .cart_quantity_down, .cart_quantity_up, .cart_quantity_delete').each(function(){
|
||||
if (typeof($(this).attr('name')) != 'undefined')
|
||||
$(this).attr('name', $(this).attr('name').replace(/nocustom/, '0'));
|
||||
if (typeof($(this).attr('id')) != 'undefined')
|
||||
$(this).attr('id', $(this).attr('id').replace(/nocustom/, '0'));
|
||||
});
|
||||
line.find('span[id^=total_product_price_]').each(function(){
|
||||
$(this).attr('id', $(this).attr('id').replace(/_nocustom/, ''));
|
||||
});
|
||||
line.attr('id', line.attr('id').replace(/nocustom/, '0'));
|
||||
}
|
||||
refreshOddRow();
|
||||
});
|
||||
}
|
||||
updateCartSummary(jsonData.summary);
|
||||
if (window.ajaxCart != undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined' && jsonData.summary.products.length > 0)
|
||||
getCarrierListAndUpdate();
|
||||
if (typeof(updatePaymentMethodsDisplay) !== 'undefined')
|
||||
updatePaymentMethodsDisplay();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refreshOddRow()
|
||||
{
|
||||
var odd_class = 'odd';
|
||||
var even_class = 'even';
|
||||
$.each($('.cart_item'), function(i, it)
|
||||
{
|
||||
if (i == 0) // First item
|
||||
{
|
||||
if ($(this).hasClass('even'))
|
||||
{
|
||||
odd_class = 'even';
|
||||
even_class = 'odd';
|
||||
}
|
||||
$(this).addClass('first_item');
|
||||
}
|
||||
if(i % 2)
|
||||
$(this).removeClass(odd_class).addClass(even_class);
|
||||
else
|
||||
$(this).removeClass(even_class).addClass(odd_class);
|
||||
});
|
||||
$('.cart_item:last-child, .customization:last-child').addClass('last_item');
|
||||
}
|
||||
|
||||
function upQuantity(id, qty)
|
||||
{
|
||||
if (typeof(qty) == 'undefined' || !qty)
|
||||
qty = 1;
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
var id_address_delivery = 0;
|
||||
var ids = 0;
|
||||
ids = id.split('_');
|
||||
productId = parseInt(ids[0]);
|
||||
if (typeof(ids[1]) !== 'undefined')
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) !== 'undefined' && ids[2] !== 'nocustom')
|
||||
customizationId = parseInt(ids[2]);
|
||||
if (typeof(ids[3]) !== 'undefined')
|
||||
id_address_delivery = parseInt(ids[3]);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
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
|
||||
+ ((customizationId !== 0) ? '&id_customization=' + customizationId : '')
|
||||
+ '&qty=' + qty
|
||||
+ '&token=' + static_token
|
||||
+ '&allow_refresh=1',
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
$('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
updateCartSummary(jsonData.summary);
|
||||
if (window.ajaxCart != undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
if (customizationId !== 0)
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
if (typeof(updatePaymentMethodsDisplay) !== 'undefined')
|
||||
updatePaymentMethodsDisplay();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function downQuantity(id, qty)
|
||||
{
|
||||
var val = $('input[name=quantity_' + id + ']').val();
|
||||
var newVal = val;
|
||||
if(typeof(qty) == 'undefined' || !qty)
|
||||
{
|
||||
qty = 1;
|
||||
newVal = val - 1;
|
||||
}
|
||||
else if (qty < 0)
|
||||
qty = -qty;
|
||||
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
var id_address_delivery = 0;
|
||||
var ids = 0;
|
||||
|
||||
ids = id.split('_');
|
||||
productId = parseInt(ids[0]);
|
||||
if (typeof(ids[1]) !== 'undefined')
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
if (typeof(ids[2]) !== 'undefined' && ids[2] !== 'nocustom')
|
||||
customizationId = parseInt(ids[2]);
|
||||
if (typeof(ids[3]) !== 'undefined')
|
||||
id_address_delivery = parseInt(ids[3]);
|
||||
|
||||
if (newVal > 0 || $('#product_' + id + '_gift').length)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
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'
|
||||
+ ((customizationId !== 0) ? '&id_customization='+customizationId : '')
|
||||
+ '&qty='+qty
|
||||
+ '&token='+static_token
|
||||
+ '&allow_refresh=1',
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
$('input[name=quantity_' + id + ']').val($('input[name=quantity_' + id + '_hidden]').val());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
updateCartSummary(jsonData.summary);
|
||||
if (window.ajaxCart !== undefined)
|
||||
ajaxCart.updateCart(jsonData);
|
||||
if (customizationId !== 0)
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
|
||||
if (newVal == 0)
|
||||
$('#product_' + id).hide();
|
||||
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
if (typeof(updatePaymentMethodsDisplay) !== 'undefined')
|
||||
updatePaymentMethodsDisplay();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteProductFromSummary(id);
|
||||
}
|
||||
}
|
||||
|
||||
function updateCartSummary(json)
|
||||
{
|
||||
var i;
|
||||
var nbrProducts = 0;
|
||||
var product_list = new Array();
|
||||
|
||||
if (typeof json == 'undefined')
|
||||
return;
|
||||
|
||||
$('div.alert-danger').fadeOut();
|
||||
|
||||
for (i=0;i<json.products.length;i++)
|
||||
product_list[json.products[i].id_product + '_' + json.products[i].id_product_attribute + '_' + json.products[i].id_address_delivery] = json.products[i];
|
||||
|
||||
if (!$('.multishipping-cart:visible').length)
|
||||
{
|
||||
for (i=0;i<json.gift_products.length;i++)
|
||||
if (typeof(product_list[json.gift_products[i].id_product + '_' + json.gift_products[i].id_product_attribute + '_' + json.gift_products[i].id_address_delivery]) !== 'undefined')
|
||||
product_list[json.gift_products[i].id_product + '_' + json.gift_products[i].id_product_attribute + '_' + json.gift_products[i].id_address_delivery].quantity -= json.gift_products[i].cart_quantity;
|
||||
}
|
||||
else
|
||||
for (i=0;i<json.gift_products.length;i++)
|
||||
if (typeof(product_list[json.gift_products[i].id_product + '_' + json.gift_products[i].id_product_attribute + '_' + json.gift_products[i].id_address_delivery]) == 'undefined')
|
||||
product_list[json.gift_products[i].id_product + '_' + json.gift_products[i].id_product_attribute + '_' + json.gift_products[i].id_address_delivery] = json.gift_products[i];
|
||||
|
||||
for (i in product_list)
|
||||
{
|
||||
// if reduction, we need to show it in the cart by showing the initial price above the current one
|
||||
var reduction = product_list[i].reduction_applies;
|
||||
var initial_price_text = '';
|
||||
initial_price = '';
|
||||
if (typeof(product_list[i].price_without_quantity_discount) !== 'undefined')
|
||||
initial_price = formatCurrency(product_list[i].price_without_quantity_discount, currencyFormat, currencySign, currencyBlank);
|
||||
var current_price = '';
|
||||
if (priceDisplayMethod !== 0)
|
||||
current_price = formatCurrency(product_list[i].price, currencyFormat, currencySign, currencyBlank);
|
||||
else
|
||||
current_price = formatCurrency(product_list[i].price_wt, currencyFormat, currencySign, currencyBlank);
|
||||
if (reduction && typeof(initial_price) !== 'undefined')
|
||||
if (initial_price !== '' && product_list[i].price_without_quantity_discount > product_list[i].price)
|
||||
initial_price_text = '<span class="old-price">' + initial_price + '</span>';
|
||||
|
||||
var key_for_blockcart = product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + product_list[i].id_address_delivery;
|
||||
var key_for_blockcart_nocustom = product_list[i].id_product + '_' + product_list[i].id_product_attribute + '_' + ((product_list[i].id_customization && product_list[i].quantity_without_customization != product_list[i].quantity)? 'nocustom' : '0') + '_' + product_list[i].id_address_delivery;
|
||||
|
||||
if (priceDisplayMethod !== 0)
|
||||
{
|
||||
$('#product_price_' + key_for_blockcart).html(initial_price_text + current_price);
|
||||
if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined' && product_list[i].customizationQuantityTotal > 0)
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total_customization, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
if (product_list[i].quantity_without_customization != product_list[i].quantity)
|
||||
$('#total_product_price_' + key_for_blockcart_nocustom).html(formatCurrency(product_list[i].total, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#product_price_' + key_for_blockcart).html(initial_price_text + current_price);
|
||||
if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined' && product_list[i].customizationQuantityTotal > 0)
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total_customization_wt, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#total_product_price_' + key_for_blockcart).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
if (product_list[i].quantity_without_customization != product_list[i].quantity)
|
||||
$('#total_product_price_' + key_for_blockcart_nocustom).html(formatCurrency(product_list[i].total_wt, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
$('input[name=quantity_' + key_for_blockcart_nocustom + ']').val(product_list[i].id_customization? product_list[i].quantity_without_customization : product_list[i].cart_quantity);
|
||||
$('input[name=quantity_' + key_for_blockcart_nocustom + '_hidden]').val(product_list[i].id_customization? product_list[i].quantity_without_customization : product_list[i].cart_quantity);
|
||||
if (typeof(product_list[i].customizationQuantityTotal) !== 'undefined' && product_list[i].customizationQuantityTotal > 0)
|
||||
$('#cart_quantity_custom_' + key_for_blockcart).html(product_list[i].customizationQuantityTotal);
|
||||
nbrProducts += parseInt(product_list[i].quantity);
|
||||
}
|
||||
|
||||
// Update discounts
|
||||
if (json.discounts.length == 0)
|
||||
{
|
||||
$('.cart_discount').each(function(){$(this).remove();});
|
||||
$('.cart_total_voucher').remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($('.cart_discount').length == 0)
|
||||
location.reload();
|
||||
|
||||
if (priceDisplayMethod !== 0)
|
||||
$('#total_discount').html('-' + formatCurrency(json.total_discounts_tax_exc, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#total_discount').html('-' + formatCurrency(json.total_discounts, currencyFormat, currencySign, currencyBlank));
|
||||
|
||||
$('.cart_discount').each(function(){
|
||||
var idElmt = $(this).attr('id').replace('cart_discount_','');
|
||||
var toDelete = true;
|
||||
|
||||
for (i=0;i<json.discounts.length;i++)
|
||||
if (json.discounts[i].id_discount == idElmt)
|
||||
{
|
||||
if (json.discounts[i].value_real !== '!')
|
||||
{
|
||||
if (priceDisplayMethod !== 0)
|
||||
$('#cart_discount_' + idElmt + ' td.cart_discount_price span.price-discount').html(formatCurrency(json.discounts[i].value_tax_exc * -1, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#cart_discount_' + idElmt + ' td.cart_discount_price span.price-discount').html(formatCurrency(json.discounts[i].value_real * -1, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
toDelete = false;
|
||||
}
|
||||
if (toDelete)
|
||||
$('#cart_discount_' + idElmt + ', #cart_total_voucher').fadeTo('fast', 0, function(){ $(this).remove(); });
|
||||
});
|
||||
}
|
||||
|
||||
// Block cart
|
||||
$('#cart_block_shipping_cost').show();
|
||||
$('#cart_block_shipping_cost').next().show();
|
||||
if (json.total_shipping > 0)
|
||||
{
|
||||
if (priceDisplayMethod !== 0)
|
||||
{
|
||||
$('#cart_block_shipping_cost').html(formatCurrency(json.total_shipping_tax_exc, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_wrapping_cost').html(formatCurrency(json.total_wrapping_tax_exc, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_total').html(formatCurrency(json.total_price_without_tax, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#cart_block_shipping_cost').html(formatCurrency(json.total_shipping, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_wrapping_cost').html(formatCurrency(json.total_wrapping, currencyFormat, currencySign, currencyBlank));
|
||||
$('#cart_block_total').html(formatCurrency(json.total_price, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (json.carrier.id == null)
|
||||
{
|
||||
$('#cart_block_shipping_cost').hide();
|
||||
$('#cart_block_shipping_cost').next().hide();
|
||||
}
|
||||
}
|
||||
|
||||
$('#cart_block_tax_cost').html(formatCurrency(json.total_tax, currencyFormat, currencySign, currencyBlank));
|
||||
$('.ajax_cart_quantity').html(nbrProducts);
|
||||
|
||||
// Cart summary
|
||||
$('#summary_products_quantity').html(nbrProducts + ' ' + (nbrProducts > 1 ? txtProducts : txtProduct));
|
||||
if (priceDisplayMethod !== 0)
|
||||
$('#total_product').html(formatCurrency(json.total_products, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#total_product').html(formatCurrency(json.total_products_wt, currencyFormat, currencySign, currencyBlank));
|
||||
$('#total_price').html(formatCurrency(json.total_price, currencyFormat, currencySign, currencyBlank));
|
||||
$('#total_price_without_tax').html(formatCurrency(json.total_price_without_tax, currencyFormat, currencySign, currencyBlank));
|
||||
$('#total_tax').html(formatCurrency(json.total_tax, currencyFormat, currencySign, currencyBlank));
|
||||
|
||||
$('.cart_total_delivery').show();
|
||||
if (json.total_shipping > 0)
|
||||
{
|
||||
if (priceDisplayMethod !== 0)
|
||||
$('#total_shipping').html(formatCurrency(json.total_shipping_tax_exc, currencyFormat, currencySign, currencyBlank));
|
||||
else
|
||||
$('#total_shipping').html(formatCurrency(json.total_shipping, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (json.carrier.id != null)
|
||||
$('#total_shipping').html(freeShippingTranslation);
|
||||
else
|
||||
$('.cart_total_delivery').hide();
|
||||
}
|
||||
|
||||
if (json.free_ship > 0 && !json.is_virtual_cart)
|
||||
{
|
||||
$('.cart_free_shipping').fadeIn();
|
||||
$('#free_shipping').html(formatCurrency(json.free_ship, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
else
|
||||
$('.cart_free_shipping').hide();
|
||||
|
||||
if (json.total_wrapping > 0)
|
||||
{
|
||||
$('#total_wrapping').html(formatCurrency(json.total_wrapping, currencyFormat, currencySign, currencyBlank));
|
||||
$('#total_wrapping').parent().show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#total_wrapping').html(formatCurrency(json.total_wrapping, currencyFormat, currencySign, currencyBlank));
|
||||
$('#total_wrapping').parent().hide();
|
||||
}
|
||||
}
|
||||
|
||||
function updateCustomizedDatas(json)
|
||||
{
|
||||
for(var i in json)
|
||||
for(var j in json[i])
|
||||
for(var k in json[i][j])
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function updateHookShoppingCart(html)
|
||||
{
|
||||
$('#HOOK_SHOPPING_CART').html(html);
|
||||
}
|
||||
|
||||
function updateHookShoppingCartExtra(html)
|
||||
{
|
||||
$('#HOOK_SHOPPING_CART_EXTRA').html(html);
|
||||
}
|
||||
function refreshDeliveryOptions()
|
||||
{
|
||||
$.each($('.delivery_option_radio'), function() {
|
||||
if ($(this).prop('checked'))
|
||||
{
|
||||
if ($(this).parent().find('.delivery_option_carrier.not-displayable').length == 0)
|
||||
$(this).parent().find('.delivery_option_carrier').show();
|
||||
var carrier_id_list = $(this).val().split(',');
|
||||
carrier_id_list.pop();
|
||||
var it = this;
|
||||
$(carrier_id_list).each(function() {
|
||||
$(it).parent().find('input[value="' + this.toString() + '"]').change();
|
||||
});
|
||||
}
|
||||
else
|
||||
$(this).parent().find('.delivery_option_carrier').hide();
|
||||
});
|
||||
}
|
||||
$(document).ready(function() {
|
||||
|
||||
refreshDeliveryOptions();
|
||||
|
||||
$('.delivery_option_radio').live('change', function() {
|
||||
refreshDeliveryOptions();
|
||||
});
|
||||
|
||||
$('#allow_seperated_package').live('click', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'controller=cart&ajax=true&allowSeperatedPackage=true&value='
|
||||
+ ($(this).prop('checked') ? '1' : '0')
|
||||
+ '&token='+static_token
|
||||
+ '&allow_refresh=1',
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (typeof(getCarrierListAndUpdate) !== 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#gift').checkboxChange(function() { $('#gift_div').show('slow'); }, function() { $('#gift_div').hide('slow'); });
|
||||
|
||||
$('#enable-multishipping').checkboxChange(
|
||||
function() {
|
||||
$('.standard-checkout').hide(0);
|
||||
$('.multishipping-checkout').show(0);
|
||||
},
|
||||
function() {
|
||||
$('.standard-checkout').show(0);
|
||||
$('.multishipping-checkout').hide(0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function updateExtraCarrier(id_delivery_option, id_address)
|
||||
{
|
||||
var url = "";
|
||||
|
||||
if(typeof(orderOpcUrl) !== 'undefined')
|
||||
url = orderOpcUrl;
|
||||
else
|
||||
url = orderUrl;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: url + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
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',
|
||||
success: function(jsonData)
|
||||
{
|
||||
$('#HOOK_EXTRACARRIER_' + id_address).html(jsonData['content']);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function submitPublishCMS(url, redirect, token)
|
||||
{
|
||||
var id_cms = $('#admin-action-cms-id').val();
|
||||
|
||||
$.ajaxSetup({async: false});
|
||||
$.post(url+'/index.php', {
|
||||
action: 'PublishCMS',
|
||||
id_cms: id_cms,
|
||||
status: 1,
|
||||
redirect: redirect,
|
||||
ajax: 1,
|
||||
tab: 'AdminCmsContent',
|
||||
token: token
|
||||
},
|
||||
function(data)
|
||||
{
|
||||
if (data.indexOf('error') === -1)
|
||||
document.location.href = data;
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
$('select[name=id_order]').change(function () {
|
||||
showProductSelect($(this).attr('value'));
|
||||
});
|
||||
showProductSelect($('select[name=id_order]').attr('value'));
|
||||
});
|
||||
|
||||
function showProductSelect(id_order)
|
||||
{
|
||||
$('.product_select').hide().attr('disabled', 'disabled').parent('.selector').hide();
|
||||
$('#'+id_order+'_order_products').show().removeAttr('disabled').parent('.selector').show();
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
//show the order-details with ajax
|
||||
function showOrder(mode, var_content, file)
|
||||
{
|
||||
$.get(
|
||||
file,
|
||||
((mode === 1) ? {'id_order': var_content, 'ajax': true} : {'id_order_return': var_content, 'ajax': true}),
|
||||
function(data)
|
||||
{
|
||||
$('#block-order-detail').fadeOut('slow', function()
|
||||
{
|
||||
$(this).html(data);
|
||||
/* if return is allowed*/
|
||||
if ($('#order-detail-content .order_cb').length > 0)
|
||||
{
|
||||
//return slip : check or uncheck every checkboxes
|
||||
$('#order-detail-content th input[type=checkbox]').click(function()
|
||||
{
|
||||
$('#order-detail-content td input[type=checkbox]').each(function()
|
||||
{
|
||||
this.checked = $('#order-detail-content th input[type=checkbox]').is(':checked');
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
});
|
||||
//return slip : enable or disable 'global' quantity editing
|
||||
$('#order-detail-content td input[type=checkbox]').click(function()
|
||||
{
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
//return slip : limit quantities
|
||||
$('#order-detail-content td .order_qte_input').keyup(function()
|
||||
{
|
||||
var maxQuantity = parseInt($(this).parent().find('.order_qte_span').text());
|
||||
var quantity = parseInt($(this).val());
|
||||
if (isNaN($(this).val()) && $(this).val() !== '')
|
||||
{
|
||||
$(this).val(maxQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (quantity > maxQuantity)
|
||||
$(this).val(maxQuantity);
|
||||
else if (quantity < 1)
|
||||
$(this).val(1);
|
||||
}
|
||||
});
|
||||
// The button to increment the product return value
|
||||
$('.return_quantity_down').click(function () {
|
||||
var $input = $(this).parent().parent().find('input');
|
||||
var count = parseInt($input.val()) - 1;
|
||||
count = count < 1 ? 1 : count;
|
||||
$input.val(count);
|
||||
$input.change();
|
||||
return false;
|
||||
});
|
||||
// The button to decrement the product return value
|
||||
$('.return_quantity_up').click(function () {
|
||||
var maxQuantity = parseInt($(this).parent().parent().find('.order_qte_span').text());
|
||||
var $input = $(this).parent().parent().find('input');
|
||||
var count = parseInt($input.val()) + 1;
|
||||
count = count > maxQuantity ? maxQuantity : count;
|
||||
$input.val(count);
|
||||
$input.change();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('form#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow', function() {
|
||||
$.scrollTo(this, 1200);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateOrderLineDisplay(domCheckbox)
|
||||
{
|
||||
var lineQuantitySpan = $(domCheckbox).parent().parent().find('.order_qte_span');
|
||||
var lineQuantityInput = $(domCheckbox).parent().parent().find('.order_qte_input');
|
||||
var lineQuantityButtons = $(domCheckbox).parent().parent().find('.return_quantity_up, .return_quantity_down');
|
||||
if($(domCheckbox).is(':checked'))
|
||||
{
|
||||
lineQuantitySpan.hide();
|
||||
lineQuantityInput.show();
|
||||
lineQuantityButtons.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
lineQuantityInput.hide();
|
||||
lineQuantityButtons.hide();
|
||||
lineQuantityInput.val(lineQuantitySpan.text());
|
||||
lineQuantitySpan.show();
|
||||
}
|
||||
}
|
||||
|
||||
//send a message in relation to the order with ajax
|
||||
function sendOrderMessage()
|
||||
{
|
||||
paramString = "ajax=true";
|
||||
$('#sendOrderMessage').find('input, textarea, select').each(function(){
|
||||
paramString += '&' + $(this).attr('name') + '=' + encodeURIComponent($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: $('#sendOrderMessage').attr("action") + '?rand=' + new Date().getTime(),
|
||||
data: paramString,
|
||||
success: function (msg){
|
||||
$('#block-order-detail').fadeOut('slow', function() {
|
||||
$(this).html(msg);
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow');
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
|
||||
(function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0<a.indexOf("%")},l=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},w=function(a,b){return l(a,b)+"px"};f.extend(b,{version:"2.1.5",defaults:{padding:15,margin:20,
|
||||
width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!s,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},
|
||||
keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
|
||||
(I?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0,
|
||||
openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,
|
||||
isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k,
|
||||
c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&&
|
||||
k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
|
||||
b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
|
||||
setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,p.bind({"onCancel.player beforeClose.player":c,"onUpdate.player":e,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(q(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},prev:function(a){var d=b.current;
|
||||
d&&(q(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=l(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d=
|
||||
a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")),
|
||||
b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(),
|
||||
y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement;
|
||||
if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1<a.group.length&&k[c]!==v)return b[d](k[c]),e.preventDefault(),!1;if(-1<f.inArray(c,k))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,k,g){for(var h=f(d.target||null),j=!1;h.length&&!j&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)j=h[0]&&!(h[0].style.overflow&&"hidden"===h[0].style.overflow)&&
|
||||
(h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1<b.group.length&&!a.canShrink){if(0<g||0<k)b.prev(0<g?"down":"left");else if(0>g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0,
|
||||
{},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,
|
||||
mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=
|
||||
!0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");
|
||||
"image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload=
|
||||
this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);
|
||||
f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,
|
||||
e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,
|
||||
outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}",
|
||||
g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll":
|
||||
"no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside?
|
||||
h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth||
|
||||
h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),c<m&&(c=m,j=l(c/D)),j<u&&(j=u,c=l(j*D))):(c=Math.max(m,Math.min(c,n)),h.autoHeight&&
|
||||
"iframe"!==h.type&&(g.width(c),j=g.height()),j=Math.max(u,Math.min(j,p)));if(h.fitToView)if(g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>r)&&(c>m&&j>u)&&!(19<d++);)j=Math.max(u,Math.min(p,j-10)),c=l(j*D),c<m&&(c=m,j=l(c/D)),c>n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&j<A&&c+x+q<z)&&(c+=q);g.width(c).height(j);e.width(c+x);a=e.width();
|
||||
y=e.height();e=(a>z||y>r)&&c>m&&j>u;c=h.aspectRatio?c<F&&j<B&&c<C&&j<A:(c<F||j<B)&&(c<C||j<A);f.extend(h,{dim:{width:w(a),height:w(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:x,hPadding:v,wrapSpace:y-k.outerHeight(!0),skinSpace:k.height()-j});!H&&(h.autoHeight&&j>u&&j<p&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",top:c[0],left:c[3]};d.autoCenter&&d.fixed&&
|
||||
!a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=w(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=w(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&(d.preventDefault(),
|
||||
b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=!1,b.play()))},_afterZoomOut:function(a){a=
|
||||
a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,j=a.wPadding,m=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));t(e)?(c=e.offset(),e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):
|
||||
(c.top=m.y+(m.h-g)*a.topRatio,c.left=m.x+(m.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=m.y,c.left-=m.x;return c={top:w(c.top-h*a.topRatio),left:w(c.left-j*a.leftRatio),width:w(f+j),height:w(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](l("width"===f?c:c-g*e)),b.inner[f](l("width"===
|
||||
f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,k=f.extend({opacity:1},d);delete k.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(k,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&(c.opacity=0.1));b.wrap.animate(c,
|
||||
{duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=w(l(e[g])-200),c[g]="+=200px"):(e[g]=w(l(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:b._afterZoomIn})},changeOut:function(){var a=
|
||||
b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!s,fixed:!0},overlay:null,fixed:!1,el:f("html"),create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();this.overlay=
|
||||
f('<div class="fancybox-overlay"></div>').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive?
|
||||
b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth),
|
||||
p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"===
|
||||
f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=
|
||||
b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,
|
||||
e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+
|
||||
":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body");var e=20===
|
||||
d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("<style type='text/css'>.fancybox-margin{margin-right:"+(d-a)+"px;}</style>").appendTo("head")})})(window,document,jQuery);
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
function highdpi_init() {
|
||||
if(jQuery('.replace-2x').css('font-size') == "1px") {
|
||||
var els = jQuery("img.replace-2x").get();
|
||||
for(var i = 0; i < els.length; i++) {
|
||||
var src = els[i].src
|
||||
src = src.replace(".png", "2x.png");
|
||||
src = src.replace(".jpg", "2x.jpg");
|
||||
src = src.replace(".gif", "2x.gif");
|
||||
els[i].src = src;
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery(document).ready(function() {
|
||||
highdpi_init();
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,829 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
// Retrocompatibility with 1.4
|
||||
if (typeof baseUri === "undefined" && typeof baseDir !== "undefined")
|
||||
baseUri = baseDir;
|
||||
|
||||
//JS Object : update the cart by ajax actions
|
||||
var ajaxCart = {
|
||||
nb_total_products: 0,
|
||||
|
||||
//override every button in the page in relation to the cart
|
||||
overrideButtonsInThePage : function(){
|
||||
//for every 'add' buttons...
|
||||
$('.ajax_add_to_cart_button').unbind('click').click(function(){
|
||||
var idProduct = $(this).attr('rel').replace('nofollow', '').replace('ajax_id_product_', '');
|
||||
if ($(this).attr('disabled') != 'disabled')
|
||||
ajaxCart.add(idProduct, null, false, this);
|
||||
return false;
|
||||
});
|
||||
//for product page 'add' button...
|
||||
$('#add_to_cart input').unbind('click').click(function(){
|
||||
ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);
|
||||
return false;
|
||||
});
|
||||
|
||||
//for 'delete' buttons in the cart block...
|
||||
$('#cart_block_list .ajax_cart_block_remove_link').unbind('click').click(function(){
|
||||
// Customized product management
|
||||
var customizationId = 0;
|
||||
var productId = 0;
|
||||
var productAttributeId = 0;
|
||||
var customizableProductDiv = $($(this).parent().parent()).find("div[id^=deleteCustomizableProduct_]");
|
||||
|
||||
if (customizableProductDiv && $(customizableProductDiv).length)
|
||||
{
|
||||
$(customizableProductDiv).each(function(){
|
||||
var ids = $(this).attr('id').split('_');
|
||||
if (typeof(ids[1]) != 'undefined')
|
||||
{
|
||||
customizationId = parseInt(ids[1]);
|
||||
productId = parseInt(ids[2]);
|
||||
if (typeof(ids[3]) != 'undefined')
|
||||
productAttributeId = parseInt(ids[3]);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Common product management
|
||||
if (!customizationId)
|
||||
{
|
||||
//retrieve idProduct and idCombination from the displayed product in the block cart
|
||||
var firstCut = $(this).parent().parent().attr('id').replace('cart_block_product_', '');
|
||||
firstCut = firstCut.replace('deleteCustomizableProduct_', '');
|
||||
ids = firstCut.split('_');
|
||||
productId = parseInt(ids[0]);
|
||||
if (typeof(ids[1]) != 'undefined')
|
||||
productAttributeId = parseInt(ids[1]);
|
||||
}
|
||||
|
||||
var idAddressDelivery = $(this).parent().parent().attr('id').match(/.*_\d+_\d+_(\d+)/)[1];
|
||||
|
||||
// Removing product from the cart
|
||||
ajaxCart.remove(productId, productAttributeId, customizationId, idAddressDelivery);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
// try to expand the cart
|
||||
expand : function(){
|
||||
if ($('#cart_block_list').hasClass('collapsed'))
|
||||
{
|
||||
$('#cart_block_summary').slideUp(200, function(){
|
||||
$(this).addClass('collapsed').removeClass('expanded');
|
||||
$('#cart_block_list').slideDown({
|
||||
duration: 450,
|
||||
complete: function(){$(this).addClass('expanded').removeClass('collapsed');}
|
||||
});
|
||||
});
|
||||
// toogle the button expand/collapse button
|
||||
$('#block_cart_expand').fadeOut('slow', function(){
|
||||
$('#block_cart_collapse').fadeIn('fast');
|
||||
});
|
||||
|
||||
// save the expand statut in the user cookie
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax_blockcart_display=expand'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
// Fix display when using back and previous browsers buttons
|
||||
refresh : function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=cart&ajax=true&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
ajaxCart.updateCart(jsonData);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// try to collapse the cart
|
||||
collapse : function(){
|
||||
|
||||
if ($('#cart_block_list').hasClass('expanded'))
|
||||
{
|
||||
$('#cart_block_list').slideUp('slow', function(){
|
||||
$(this).addClass('collapsed').removeClass('expanded');
|
||||
$('#cart_block_summary').slideDown(450, function(){
|
||||
$(this).addClass('expanded').removeClass('collapsed');
|
||||
});
|
||||
});
|
||||
$('#block_cart_collapse').fadeOut('slow', function(){
|
||||
$('#block_cart_expand').fadeIn('fast');
|
||||
});
|
||||
|
||||
// save the expand statut in the user cookie
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/blockcart/blockcart-set-collapse.php' + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax_blockcart_display=collapse' + '&rand=' + new Date().getTime()
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Update the cart information
|
||||
updateCartInformation : function (jsonData, addedFromProductPage)
|
||||
{
|
||||
ajaxCart.updateCart(jsonData);
|
||||
|
||||
//reactive the button when adding has finished
|
||||
if (addedFromProductPage)
|
||||
$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
|
||||
else
|
||||
$('.ajax_add_to_cart_button').removeAttr('disabled');
|
||||
},
|
||||
|
||||
// add a product in the cart via ajax
|
||||
add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist){
|
||||
if (addedFromProductPage && !checkCustomizations())
|
||||
{
|
||||
alert(fieldRequired);
|
||||
return ;
|
||||
}
|
||||
emptyCustomizations();
|
||||
//disabled the button when adding to not double add if user double click
|
||||
if (addedFromProductPage)
|
||||
{
|
||||
$('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
|
||||
$('.filled').removeClass('filled');
|
||||
}
|
||||
else
|
||||
$(callerElement).attr('disabled', true);
|
||||
|
||||
if ($('#cart_block_list').hasClass('collapsed'))
|
||||
this.expand();
|
||||
//send the ajax request to the server
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
|
||||
success: function(jsonData,textStatus,jqXHR)
|
||||
{
|
||||
// add appliance to whishlist module
|
||||
if (whishlist && !jsonData.errors)
|
||||
WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
|
||||
|
||||
// add the picture to the cart
|
||||
var $element = $(callerElement).parents('.ajax_block_product').find('a.product_image img,a.product_img_link img');
|
||||
if (!$element.length)
|
||||
$element = $('#bigpic');
|
||||
var $picture = $element.clone();
|
||||
var pictureOffsetOriginal = $element.offset();
|
||||
pictureOffsetOriginal.right = $(window).innerWidth() - pictureOffsetOriginal.left - $element.width();
|
||||
|
||||
if ($picture.length)
|
||||
{
|
||||
$picture.css({
|
||||
position: 'absolute',
|
||||
top: pictureOffsetOriginal.top,
|
||||
right: pictureOffsetOriginal.right
|
||||
});
|
||||
}
|
||||
|
||||
var pictureOffset = $picture.offset();
|
||||
var cartBlock = $('#cart_block');
|
||||
if (!$('#cart_block')[0] || !$('#cart_block').offset().top || !$('#cart_block').offset().left)
|
||||
cartBlock = $('#shopping_cart');
|
||||
var cartBlockOffset = cartBlock.offset();
|
||||
cartBlockOffset.right = $(window).innerWidth() - cartBlockOffset.left - cartBlock.width();
|
||||
|
||||
// Check if the block cart is activated for the animation
|
||||
if (cartBlockOffset != undefined && $picture.length)
|
||||
{
|
||||
$picture.appendTo('body');
|
||||
$picture
|
||||
.css({
|
||||
position: 'absolute',
|
||||
top: pictureOffsetOriginal.top,
|
||||
right: pictureOffsetOriginal.right,
|
||||
zIndex: 4242
|
||||
})
|
||||
.animate({
|
||||
width: $element.attr('width')*0.66,
|
||||
height: $element.attr('height')*0.66,
|
||||
opacity: 0.2,
|
||||
top: cartBlockOffset.top + 30,
|
||||
right: cartBlockOffset.right + 15
|
||||
}, 1000)
|
||||
.fadeOut(100, function() {
|
||||
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
|
||||
$(this).remove();
|
||||
if (!jsonData.hasError)
|
||||
{
|
||||
$('.crossseling').html(jsonData.crossSelling)
|
||||
$(jsonData.products).each(function(){
|
||||
if (this.id != undefined && this.id == parseInt(idProduct))
|
||||
ajaxCart.updateLayer(this);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown)
|
||||
{
|
||||
alert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText);
|
||||
//reactive the button when adding has finished
|
||||
if (addedFromProductPage)
|
||||
$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');
|
||||
else
|
||||
$(callerElement).removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//remove a product from the cart via ajax
|
||||
remove : function(idProduct, idCombination, customizationId, idAddressDelivery){
|
||||
//send the ajax request to the server
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'controller=cart&delete=1&id_product=' + idProduct + '&ipa=' + ((idCombination != null && parseInt(idCombination)) ? idCombination : '') + ((customizationId && customizationId != null) ? '&id_customization=' + customizationId : '') + '&id_address_delivery=' + idAddressDelivery + '&token=' + static_token + '&ajax=true',
|
||||
success: function(jsonData) {
|
||||
ajaxCart.updateCart(jsonData);
|
||||
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
||||
deleteProductFromSummary(idProduct+'_'+idCombination+'_'+customizationId+'_'+idAddressDelivery);
|
||||
},
|
||||
error: function() {alert('ERROR: unable to delete the product');}
|
||||
});
|
||||
},
|
||||
|
||||
//hide the products displayed in the page but no more in the json data
|
||||
hideOldProducts : function(jsonData) {
|
||||
//delete an eventually removed product of the displayed cart (only if cart is not empty!)
|
||||
if ($('#cart_block_list dl.products').length > 0)
|
||||
{
|
||||
var removedProductId = null;
|
||||
var removedProductData = null;
|
||||
var removedProductDomId = null;
|
||||
//look for a product to delete...
|
||||
$('#cart_block_list dl.products dt').each(function(){
|
||||
//retrieve idProduct and idCombination from the displayed product in the block cart
|
||||
var domIdProduct = $(this).attr('id');
|
||||
var firstCut = domIdProduct.replace('cart_block_product_', '');
|
||||
var ids = firstCut.split('_');
|
||||
|
||||
//try to know if the current product is still in the new list
|
||||
var stayInTheCart = false;
|
||||
for (aProduct in jsonData.products)
|
||||
{
|
||||
//we've called the variable aProduct because IE6 bug if this variable is called product
|
||||
//if product has attributes
|
||||
if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1]))
|
||||
{
|
||||
stayInTheCart = true;
|
||||
// update the product customization display (when the product is still in the cart)
|
||||
ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], domIdProduct);
|
||||
}
|
||||
}
|
||||
//remove product if it's no more in the cart
|
||||
if (!stayInTheCart)
|
||||
{
|
||||
removedProductId = $(this).attr('id');
|
||||
if (removedProductId != null)
|
||||
{
|
||||
var firstCut = removedProductId.replace('cart_block_product_', '');
|
||||
var ids = firstCut.split('_');
|
||||
|
||||
$('#'+removedProductId).addClass('strike').fadeTo('slow', 0, function(){
|
||||
$(this).slideUp('slow', function(){
|
||||
$(this).remove();
|
||||
// If the cart is now empty, show the 'no product in the cart' message and close detail
|
||||
if($('#cart_block dl.products dt').length == 0)
|
||||
{
|
||||
$("#cart_block").stop(true, true).slideUp(200);
|
||||
$('#cart_block_no_products:hidden').slideDown(450);
|
||||
$('#cart_block dl.products').remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#cart_block_combination_of_' + ids[0] + (ids[1] ? '_'+ids[1] : '') + (ids[2] ? '_'+ids[2] : '')).fadeTo('fast', 0, function(){
|
||||
$(this).slideUp('fast', function(){
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
hideOldProductCustomizations : function (product, domIdProduct)
|
||||
{
|
||||
var customizationList = $('#customization_' + product['id'] + '_' + product['idCombination']);
|
||||
if(customizationList.length > 0)
|
||||
{
|
||||
$(customizationList).find("li").each(function(){
|
||||
$(this).find("div").each(function() {
|
||||
var customizationDiv = $(this).attr('id');
|
||||
var tmp = customizationDiv.replace('deleteCustomizableProduct_', '');
|
||||
var ids = tmp.split('_');
|
||||
if ((parseInt(product.idCombination) == parseInt(ids[2])) && !ajaxCart.doesCustomizationStillExist(product, ids[0]))
|
||||
$('#' + customizationDiv).parent().addClass('strike').fadeTo('slow', 0, function(){
|
||||
$(this).slideUp('slow');
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var removeLinks = $('#' + domIdProduct).find('.ajax_cart_block_remove_link');
|
||||
if (!product.hasCustomizedDatas && !removeLinks.length)
|
||||
$('#' + domIdProduct + ' span.remove_link').html('<a class="ajax_cart_block_remove_link" rel="nofollow" href="' + baseUri + '?controller=cart&delete=1&id_product=' + product['id'] + '&ipa=' + product['idCombination'] + '&token=' + static_token + '"> </a>');
|
||||
if (product.is_gift)
|
||||
$('#' + domIdProduct + ' span.remove_link').html('');
|
||||
},
|
||||
|
||||
doesCustomizationStillExist : function (product, customizationId)
|
||||
{
|
||||
var exists = false;
|
||||
|
||||
$(product.customizedDatas).each(function() {
|
||||
if (this.customizationId == customizationId)
|
||||
{
|
||||
exists = true;
|
||||
// This return does not mean that we found nothing but simply break the loop
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return (exists);
|
||||
},
|
||||
|
||||
//refresh display of vouchers (needed for vouchers in % of the total)
|
||||
refreshVouchers : function (jsonData) {
|
||||
if (typeof(jsonData.discounts) == 'undefined' || jsonData.discounts.length == 0)
|
||||
$('#vouchers').hide();
|
||||
else
|
||||
{
|
||||
$('#vouchers tbody').html('');
|
||||
|
||||
for (i=0;i<jsonData.discounts.length;i++)
|
||||
{
|
||||
if (parseFloat(jsonData.discounts[i].price_float) > 0)
|
||||
{
|
||||
var delete_link = '';
|
||||
if (jsonData.discounts[i].code.length)
|
||||
delete_link = '<a class="delete_voucher" href="'+jsonData.discounts[i].link+'" title="'+delete_txt+'"><i class="icon-remove-sign"></i></a>';
|
||||
$('#vouchers tbody').append($(
|
||||
'<tr class="bloc_cart_voucher" id="bloc_cart_voucher_'+jsonData.discounts[i].id+'">'
|
||||
+' <td class="quantity">1x</td>'
|
||||
+' <td class="name" title="'+jsonData.discounts[i].description+'">'+jsonData.discounts[i].name+'</td>'
|
||||
+' <td class="price">-'+jsonData.discounts[i].price+'</td>'
|
||||
+' <td class="delete">' + delete_link + '</td>'
|
||||
+'</tr>'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$('#vouchers').show();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// Update product quantity
|
||||
updateProductQuantity : function (product, quantity) {
|
||||
|
||||
$('#cart_block_product_' + product.id + '_' + (product.idCombination ? product.idCombination : '0')+ '_' + (product.idAddressDelivery ? product.idAddressDelivery : '0') + ' .quantity').fadeTo('fast', 0, function() {
|
||||
$(this).text(quantity);
|
||||
$(this).fadeTo('fast', 1, function(){
|
||||
$(this).fadeTo('fast', 0, function(){
|
||||
$(this).fadeTo('fast', 1, function(){
|
||||
$(this).fadeTo('fast', 0, function(){
|
||||
$(this).fadeTo('fast', 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//display the products witch are in json data but not already displayed
|
||||
displayNewProducts : function(jsonData) {
|
||||
|
||||
//add every new products or update displaying of every updated products
|
||||
$(jsonData.products).each(function(){
|
||||
//fix ie6 bug (one more item 'undefined' in IE6)
|
||||
if (this.id != undefined)
|
||||
{
|
||||
//create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty)
|
||||
|
||||
if ($('#cart_block dl.products').length == 0)
|
||||
{
|
||||
$('#cart_block_no_products').before('<dl class="products"></dl>');
|
||||
$('#cart_block_no_products').hide();
|
||||
}
|
||||
//if product is not in the displayed cart, add a new product's line
|
||||
var domIdProduct = this.id + '_' + (this.idCombination ? this.idCombination : '0') + '_' + (this.idAddressDelivery ? this.idAddressDelivery : '0');
|
||||
var domIdProductAttribute = this.id + '_' + (this.idCombination ? this.idCombination : '0');
|
||||
if ($('#cart_block_product_'+ domIdProduct).length == 0)
|
||||
{
|
||||
var productId = parseInt(this.id);
|
||||
var productAttributeId = (this.hasAttributes ? parseInt(this.attributes) : 0);
|
||||
var content = '<dt class="unvisible" id="cart_block_product_' + domIdProduct + '">';
|
||||
content += '<a class="cart-images" href="' + this.link + '" title="' + this.name.substring(0, 12) + '"><img src="' + this.image_cart + '" alt="' + this.name +'"></a>';
|
||||
var min = this.name.indexOf(';', 10);
|
||||
var name = (this.name.length > 12 ? this.name.substring(0, ((min - 10) <= 7) ? min : 10) + '...' : this.name);
|
||||
content += '<div class="cart-info"><div class="product-name"><a href="' + this.link + '" title="' + this.name + '" class="cart_block_product_name">' + name + '</a></div>';
|
||||
if (this.hasAttributes)
|
||||
content += '<div class="product-atributes"><a href="' + this.link + '" title="' + this.name + '">' + this.attributes + '</a></div>';
|
||||
content += '<span class="quantity-formated"><span class="quantity">' + this.quantity + '</span>x </span>';
|
||||
if (typeof(freeProductTranslation) != 'undefined')
|
||||
content += '<span class="price">' + (parseFloat(this.price_float) > 0 ? this.priceByLine : freeProductTranslation) + '</span></div>';
|
||||
|
||||
if (typeof(this.is_gift) == 'undefined' || this.is_gift == 0)
|
||||
content += '<span class="remove_link"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&token=' + static_token + (this.hasAttributes ? '&ipa=' + parseInt(this.idCombination) : '') + '"> </a></span>';
|
||||
else
|
||||
content += '<span class="remove_link"></span>';
|
||||
content += '</dt>';
|
||||
if (this.hasAttributes)
|
||||
content += '<dd id="cart_block_combination_of_' + domIdProduct + '" class="unvisible">';
|
||||
if (this.hasCustomizedDatas)
|
||||
content += ajaxCart.displayNewCustomizedDatas(this);
|
||||
if (this.hasAttributes) content += '</dd>';
|
||||
|
||||
$('#cart_block dl.products').append(content);
|
||||
}
|
||||
//else update the product's line
|
||||
else
|
||||
{
|
||||
var jsonProduct = this;
|
||||
if($.trim($('#cart_block_product_' + domIdProduct + ' .quantity').html()) != jsonProduct.quantity || $.trim($('#cart_block_product_' + domIdProduct + ' .price').html()) != jsonProduct.priceByLine)
|
||||
{
|
||||
// Usual product
|
||||
if (!this.is_gift)
|
||||
$('#cart_block_product_' + domIdProduct + ' .price').text(jsonProduct.priceByLine);
|
||||
else
|
||||
$('#cart_block_product_' + domIdProduct + ' .price').html(freeProductTranslation);
|
||||
ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.quantity);
|
||||
|
||||
// Customized product
|
||||
if (jsonProduct.hasCustomizedDatas)
|
||||
{
|
||||
customizationFormatedDatas = ajaxCart.displayNewCustomizedDatas(jsonProduct);
|
||||
if (!$('#customization_' + domIdProductAttribute).length)
|
||||
{
|
||||
if (jsonProduct.hasAttributes)
|
||||
$('#cart_block_combination_of_' + domIdProduct).append(customizationFormatedDatas);
|
||||
else
|
||||
$('#cart_block dl.products').append(customizationFormatedDatas);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#customization_' + domIdProductAttribute).html('');
|
||||
$('#customization_' + domIdProductAttribute).append(customizationFormatedDatas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#cart_block dl.products .unvisible').slideDown(450).removeClass('unvisible');
|
||||
|
||||
var removeLinks = $('#cart_block_product_' + domIdProduct).find('a.ajax_cart_block_remove_link');
|
||||
if (this.hasCustomizedDatas && removeLinks.length)
|
||||
$(removeLinks).each(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
displayNewCustomizedDatas : function(product)
|
||||
{
|
||||
var content = '';
|
||||
var productId = parseInt(product.id);
|
||||
var productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
|
||||
var hasAlreadyCustomizations = $('#customization_' + productId + '_' + productAttributeId).length;
|
||||
|
||||
if (!hasAlreadyCustomizations)
|
||||
{
|
||||
if (!product.hasAttributes)
|
||||
content += '<dd id="cart_block_combination_of_' + productId + '" class="unvisible">';
|
||||
if ($('#customization_' + productId + '_' + productAttributeId).val() == undefined)
|
||||
content += '<ul class="cart_block_customizations" id="customization_' + productId + '_' + productAttributeId + '">';
|
||||
}
|
||||
|
||||
$(product.customizedDatas).each(function()
|
||||
{
|
||||
var done = 0;
|
||||
customizationId = parseInt(this.customizationId);
|
||||
productAttributeId = typeof(product.idCombination) == 'undefined' ? 0 : parseInt(product.idCombination);
|
||||
content += '<li name="customization"><div class="deleteCustomizableProduct" id="deleteCustomizableProduct_' + customizationId + '_' + productId + '_' + (productAttributeId ? productAttributeId : '0') + '"><a rel="nofollow" class="ajax_cart_block_remove_link" href="' + baseUri + '?controller=cart&delete=1&id_product=' + productId + '&ipa=' + productAttributeId + '&id_customization=' + customizationId + '&token=' + static_token + '"></a></div><span class="quantity-formated"><span class="quantity">' + parseInt(this.quantity) + '</span>x</span>';
|
||||
|
||||
// Give to the customized product the first textfield value as name
|
||||
$(this.datas).each(function(){
|
||||
if (this['type'] == CUSTOMIZE_TEXTFIELD)
|
||||
{
|
||||
$(this.datas).each(function(){
|
||||
if (this['index'] == 0)
|
||||
{
|
||||
content += ' ' + this.truncatedValue.replace(/<br \/>/g, ' ');
|
||||
done = 1;
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// If the customized product did not have any textfield, it will have the customizationId as name
|
||||
if (!done)
|
||||
content += customizationIdMessage + customizationId;
|
||||
if (!hasAlreadyCustomizations) content += '</li>';
|
||||
// Field cleaning
|
||||
if (customizationId)
|
||||
{
|
||||
$('#uploadable_files li div.customizationUploadBrowse img').remove();
|
||||
$('#text_fields input').attr('value', '');
|
||||
}
|
||||
});
|
||||
|
||||
if (!hasAlreadyCustomizations)
|
||||
{
|
||||
content += '</ul>';
|
||||
if (!product.hasAttributes) content += '</dd>';
|
||||
}
|
||||
return (content);
|
||||
},
|
||||
updateLayer : function(product) {
|
||||
$('#layer_cart_product_title').text(product.name);
|
||||
$('#layer_cart_product_attributes').text('');
|
||||
if (product.hasAttributes && product.hasAttributes == true)
|
||||
$('#layer_cart_product_attributes').html(product.attributes);
|
||||
$('#layer_cart_product_price').text(product.price);
|
||||
$('#layer_cart_product_quantity').text(product.quantity);
|
||||
$('.layer_cart_img').prop({'src' : product.image, 'alt' : product.name, 'title' : product.name});
|
||||
var h = parseInt($(window).height());
|
||||
var s = parseInt($(window).scrollTop());
|
||||
var t = $('#layer_cart').outerHeight(true);
|
||||
if (t < h)
|
||||
var n = parseInt(((h-t) / 2) + s) + 'px';
|
||||
$('.layer_cart_overlay').css('width',$('body').width());
|
||||
$('.layer_cart_overlay').css('height',$('body').height());
|
||||
$('.layer_cart_overlay').show();
|
||||
$('#layer_cart').css({'top': n}).fadeIn('fast');
|
||||
crossselling_serialScroll();
|
||||
},
|
||||
|
||||
//genarally update the display of the cart
|
||||
updateCart : function(jsonData) {
|
||||
//user errors display
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for (error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if (error != 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
ajaxCart.updateCartEverywhere(jsonData);
|
||||
ajaxCart.hideOldProducts(jsonData);
|
||||
ajaxCart.displayNewProducts(jsonData);
|
||||
ajaxCart.refreshVouchers(jsonData);
|
||||
|
||||
//update 'first' and 'last' item classes
|
||||
$('#cart_block .products dt').removeClass('first_item').removeClass('last_item').removeClass('item');
|
||||
$('#cart_block .products dt:first').addClass('first_item');
|
||||
$('#cart_block .products dt:not(:first,:last)').addClass('item');
|
||||
$('#cart_block .products dt:last').addClass('last_item');
|
||||
|
||||
//reset the onlick events in relation to the cart block (it allow to bind the onclick event to the new 'delete' buttons added)
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
}
|
||||
},
|
||||
|
||||
//update general cart informations everywhere in the page
|
||||
updateCartEverywhere : function(jsonData) {
|
||||
$('.ajax_cart_total').text($.trim(jsonData.productTotal));
|
||||
|
||||
if (parseFloat(jsonData.shippingCostFloat) > 0 || jsonData.nbTotalProducts < 1)
|
||||
$('.ajax_cart_shipping_cost').text(jsonData.shippingCost);
|
||||
else if (typeof(freeShippingTranslation) != 'undefined')
|
||||
$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
|
||||
$('.ajax_cart_tax_cost').text(jsonData.taxCost);
|
||||
$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
|
||||
$('.ajax_block_cart_total').text(jsonData.total);
|
||||
$('.ajax_block_products_total').text(jsonData.productTotal);
|
||||
$('.ajax_total_price_wt').text(jsonData.total_price_wt);
|
||||
|
||||
if (parseFloat(jsonData.freeShippingFloat) > 0)
|
||||
{
|
||||
$('.ajax_cart_free_shipping').html(jsonData.freeShipping);
|
||||
$('.freeshipping').fadeIn(0);
|
||||
}
|
||||
else if (parseFloat(jsonData.freeShippingFloat) == 0)
|
||||
$('.freeshipping').fadeOut(0);
|
||||
|
||||
this.nb_total_products = jsonData.nbTotalProducts;
|
||||
|
||||
if (parseInt(jsonData.nbTotalProducts) > 0)
|
||||
{
|
||||
$('.ajax_cart_no_product').hide();
|
||||
$('.ajax_cart_quantity').text(jsonData.nbTotalProducts);
|
||||
$('.ajax_cart_quantity').fadeIn('slow');
|
||||
$('.ajax_cart_total').fadeIn('slow');
|
||||
|
||||
if (parseInt(jsonData.nbTotalProducts) > 1)
|
||||
{
|
||||
$('.ajax_cart_product_txt').each( function () {
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$('.ajax_cart_product_txt_s').each( function () {
|
||||
$(this).show();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.ajax_cart_product_txt').each( function () {
|
||||
$(this).show();
|
||||
});
|
||||
|
||||
$('.ajax_cart_product_txt_s').each( function () {
|
||||
$(this).hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){
|
||||
$(this).hide();
|
||||
});
|
||||
$('.ajax_cart_no_product').show('slow');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#block_cart_collapse').click(function(){
|
||||
ajaxCart.collapse();
|
||||
});
|
||||
$('#block_cart_expand').click(function(){
|
||||
ajaxCart.expand();
|
||||
});
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
|
||||
var cart_qty = 0;
|
||||
var current_timestamp = parseInt(new Date().getTime() / 1000);
|
||||
|
||||
if (typeof $('.ajax_cart_quantity').html() == 'undefined' || (typeof generated_date != 'undefined' && generated_date != null && (parseInt(generated_date) + 30) < current_timestamp))
|
||||
ajaxCart.refresh();
|
||||
else
|
||||
cart_qty = parseInt($('.ajax_cart_quantity').html());
|
||||
|
||||
/* roll over cart */
|
||||
var cart_block = new HoverWatcher('#cart_block');
|
||||
var shopping_cart = new HoverWatcher('#shopping_cart');
|
||||
|
||||
$("#shopping_cart a:first").hover(
|
||||
function() {
|
||||
if (ajaxCart.nb_total_products > 0 || cart_qty > 0)
|
||||
$("#header_right #cart_block").stop(true, true).slideDown(450);
|
||||
},
|
||||
function() {
|
||||
setTimeout(function() {
|
||||
if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
|
||||
$("#header_right #cart_block").stop(true, true).slideUp(450);
|
||||
}, 200);
|
||||
}
|
||||
);
|
||||
|
||||
$("#header_right #cart_block").hover(
|
||||
function() {
|
||||
},
|
||||
function() {
|
||||
setTimeout(function() {
|
||||
if (!shopping_cart.isHoveringOver())
|
||||
$("#header_right #cart_block").stop(true, true).slideUp(450);
|
||||
}, 200);
|
||||
}
|
||||
);
|
||||
|
||||
$('.delete_voucher').live('click', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
async: true,
|
||||
cache: false,
|
||||
url:$(this).attr('href') + '?rand=' + new Date().getTime()
|
||||
});
|
||||
$(this).parent().parent().remove();
|
||||
if ($('body').attr('id') == 'order' || $('body').attr('id') == 'order-opc')
|
||||
{
|
||||
if (typeof(updateAddressSelection) != 'undefined')
|
||||
updateAddressSelection();
|
||||
else
|
||||
location.reload();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#cart_navigation input').click(function(){
|
||||
$(this).attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
|
||||
$(this).closest("form").get(0).submit();
|
||||
});
|
||||
|
||||
$('#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay').click(function(){
|
||||
$('.layer_cart_overlay').hide(); $('#layer_cart').fadeOut('fast'); return false;
|
||||
});
|
||||
});
|
||||
|
||||
function HoverWatcher(selector){
|
||||
this.hovering = false;
|
||||
var self = this;
|
||||
|
||||
this.isHoveringOver = function() {
|
||||
return self.hovering;
|
||||
}
|
||||
|
||||
$(selector).hover(function() {
|
||||
self.hovering = true;
|
||||
}, function() {
|
||||
self.hovering = false;
|
||||
})
|
||||
}
|
||||
|
||||
function crossselling_serialScrollFixLock(event, targeted, scrolled, items, position)
|
||||
{
|
||||
serialScrollNbImages = $('#blockcart_list li:visible').length;
|
||||
serialScrollNbImagesDisplayed = 4;
|
||||
|
||||
var leftArrow = position == 0 ? true : false;
|
||||
var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false;
|
||||
|
||||
$('#blockcart_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
|
||||
$('#blockcart_scroll_right').css('cursor', rightArrow ? 'default' : 'pointer').fadeTo(0, rightArrow ? 0 : 1).css('display', rightArrow ? 'none' : 'block');
|
||||
return true;
|
||||
}
|
||||
|
||||
function crossselling_serialScroll()
|
||||
{
|
||||
$('#blockcart_list').serialScroll({
|
||||
items:'li:visible',
|
||||
prev:'#blockcart_scroll_left',
|
||||
next:'#blockcart_scroll_right',
|
||||
axis:'x',
|
||||
offset:0,
|
||||
start:0,
|
||||
stop:true,
|
||||
onBefore:crossselling_serialScrollFixLock,
|
||||
duration:300,
|
||||
step: 1,
|
||||
lazy: true,
|
||||
lock: false,
|
||||
force:false
|
||||
});
|
||||
$('#blockcart_list').trigger('goto', 0);
|
||||
}
|
||||
@@ -0,0 +1,618 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registred Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
var ajaxQueries = new Array();
|
||||
var ajaxLoaderOn = 0;
|
||||
var sliderList = new Array();
|
||||
var slidersInit = false;
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
cancelFilter();
|
||||
openCloseFilter();
|
||||
|
||||
// Click on color
|
||||
$('#layered_form input[type=button], #layered_form label.layered_color').live('click', function()
|
||||
{
|
||||
if (!$('input[name='+$(this).attr('name')+'][type=hidden]').length)
|
||||
$('<input />').attr('type', 'hidden').attr('name', $(this).attr('name')).val($(this).attr('rel')).appendTo('#layered_form');
|
||||
else
|
||||
$('input[name='+$(this).attr('name')+'][type=hidden]').remove();
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
// Click on checkbox
|
||||
$('#layered_form input[type=checkbox], #layered_form input[type=radio], #layered_form select').live('change', function()
|
||||
{
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
// Changing content of an input text
|
||||
$('#layered_form input.layered_input_range').live('keyup', function()
|
||||
{
|
||||
if ($(this).attr('timeout_id'))
|
||||
window.clearTimeout($(this).attr('timeout_id'));
|
||||
|
||||
// IE Hack, setTimeout do not acept the third parameter
|
||||
var reference = this;
|
||||
|
||||
$(this).attr('timeout_id', window.setTimeout(function(it) {
|
||||
if (!$(it).attr('id'))
|
||||
it = reference;
|
||||
|
||||
var filter = $(it).attr('id').replace(/^layered_(.+)_range_.*$/, '$1');
|
||||
|
||||
var value_min = parseInt($('#layered_'+filter+'_range_min').val());
|
||||
if (isNaN(value_min))
|
||||
value_min = 0;
|
||||
$('#layered_'+filter+'_range_min').val(value_min);
|
||||
|
||||
var value_max = parseInt($('#layered_'+filter+'_range_max').val());
|
||||
if (isNaN(value_max))
|
||||
value_max = 0;
|
||||
$('#layered_'+filter+'_range_max').val(value_max);
|
||||
|
||||
if (value_max < value_min) {
|
||||
$('#layered_'+filter+'_range_max').val($(it).val());
|
||||
$('#layered_'+filter+'_range_min').val($(it).val());
|
||||
}
|
||||
reloadContent();
|
||||
}, 500, this));
|
||||
});
|
||||
|
||||
$('#layered_block_left .radio').live('click', function() {
|
||||
var name = $(this).attr('name');
|
||||
$.each($(this).parent().parent().find('input[type=button]'), function (it, item) {
|
||||
if ($(item).hasClass('on') && $(item).attr('name') != name) {
|
||||
$(item).click();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
// Click on label
|
||||
$('#layered_block_left label a').live({
|
||||
click: function() {
|
||||
var disable = $(this).parent().parent().find('input').attr('disabled');
|
||||
if (disable == ''
|
||||
|| typeof(disable) == 'undefined'
|
||||
|| disable == false)
|
||||
{
|
||||
$(this).parent().parent().find('input').click();
|
||||
reloadContent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
layered_hidden_list = {};
|
||||
$('.hide-action').live('click', function() {
|
||||
if (typeof(layered_hidden_list[$(this).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(this).parent().find('ul').attr('id')] == false)
|
||||
{
|
||||
layered_hidden_list[$(this).parent().find('ul').attr('id')] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layered_hidden_list[$(this).parent().find('ul').attr('id')] = false;
|
||||
}
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
$('.hide-action').each(function() {
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
|
||||
// To be sure there is no other events attached to the selectPrductSort, change the ID
|
||||
var id = 1;
|
||||
while ($('#selectPrductSort').length) { // Because ids are duplicated
|
||||
// Unbind event change on #selectPrductSort
|
||||
$('#selectPrductSort').unbind('change');
|
||||
$('#selectPrductSort').attr('onchange', '');
|
||||
$('#selectPrductSort').addClass('selectProductSort');
|
||||
$('#selectPrductSort').attr('id', 'selectPrductSort'+id);
|
||||
$('label[for=selectPrductSort]').attr('for', 'selectPrductSort'+id);
|
||||
id++;
|
||||
}
|
||||
|
||||
// Since 1.5, event is add to .selectProductSort and not to #selectPrductSort
|
||||
setTimeout(function() {
|
||||
$('.selectProductSort').unbind('change');
|
||||
}, 100);
|
||||
|
||||
$('.selectProductSort').live('change', function(event) {
|
||||
$('.selectProductSort').val($(this).val());
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
$('.js-nb_item').unbind('change').attr('onchange', '');
|
||||
|
||||
$('.js-nb_item').live('change', function(event) {
|
||||
$('.js-nb_item').val($(this).val());
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
paginationButton();
|
||||
initLayered();
|
||||
});
|
||||
|
||||
function hideFilterValueAction(it)
|
||||
{
|
||||
if (typeof(layered_hidden_list[$(it).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(it).parent().find('ul').attr('id')] == false)
|
||||
{
|
||||
$(it).parent().find('.hiddable').hide();
|
||||
$(it).parent().find('.hide-action.less').hide();
|
||||
$(it).parent().find('.hide-action.more').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(it).parent().find('.hiddable').show();
|
||||
$(it).parent().find('.hide-action.less').show();
|
||||
$(it).parent().find('.hide-action.more').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function addSlider(type, data, unit, format)
|
||||
{
|
||||
sliderList.push({
|
||||
type: type,
|
||||
data: data,
|
||||
unit: unit,
|
||||
format: format
|
||||
});
|
||||
}
|
||||
|
||||
function initSliders()
|
||||
{
|
||||
$(sliderList).each(function(i, slider){
|
||||
$('#layered_'+slider['type']+'_slider').slider(slider['data']);
|
||||
|
||||
var from = '';
|
||||
var to = '';
|
||||
switch (slider['format'])
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
from = blocklayeredFormatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 0), slider['format'], slider['unit']);
|
||||
to = blocklayeredFormatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 1), slider['format'], slider['unit']);
|
||||
break;
|
||||
case 5:
|
||||
from = $('#layered_'+slider['type']+'_slider').slider('values', 0)+slider['unit']
|
||||
to = $('#layered_'+slider['type']+'_slider').slider('values', 1)+slider['unit'];
|
||||
break;
|
||||
}
|
||||
$('#layered_'+slider['type']+'_range').html(from+' - '+to);
|
||||
});
|
||||
}
|
||||
|
||||
function initLayered()
|
||||
{
|
||||
initSliders();
|
||||
initLocationChange();
|
||||
updateProductUrl();
|
||||
if (window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
|
||||
{
|
||||
var params = window.location.href.split('#')[1];
|
||||
reloadContent('&selected_filters='+params);
|
||||
}
|
||||
}
|
||||
|
||||
function paginationButton() {
|
||||
$('div.pagination a').not(':hidden').each(function () {
|
||||
if ($(this).attr('href').search('&p=') == -1) {
|
||||
var page = 1;
|
||||
}
|
||||
else {
|
||||
var page = $(this).attr('href').replace(/^.*&p=(\d+).*$/, '$1');
|
||||
}
|
||||
var location = window.location.href.replace(/#.*$/, '');
|
||||
$(this).attr('href', location+current_friendly_url.replace(/\/page-(\d+)/, '')+'/page-'+page);
|
||||
});
|
||||
$('div.pagination li').not('.current, .disabled').each(function () {
|
||||
var nbPage = 0;
|
||||
if ($(this).hasClass('pagination_next'))
|
||||
nbPage = parseInt($('div.pagination li.current').children().html())+ 1;
|
||||
else if ($(this).hasClass('pagination_previous'))
|
||||
nbPage = parseInt($('div.pagination li.current').children().html())- 1;
|
||||
|
||||
$(this).children().children().click(function () {
|
||||
if (nbPage == 0)
|
||||
p = parseInt($(this).html()) + parseInt(nbPage);
|
||||
else
|
||||
p = nbPage;
|
||||
p = '&p='+ p;
|
||||
reloadContent(p);
|
||||
nbPage = 0;
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function cancelFilter()
|
||||
{
|
||||
$('#enabled_filters a').live('click', function(e)
|
||||
{
|
||||
if ($(this).attr('rel').search(/_slider$/) > 0)
|
||||
{
|
||||
if ($('#'+$(this).attr('rel')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel')).slider('values' , 0, $('#'+$(this).attr('rel')).slider('option' , 'min' ));
|
||||
$('#'+$(this).attr('rel')).slider('values' , 1, $('#'+$(this).attr('rel')).slider('option' , 'max' ));
|
||||
$('#'+$(this).attr('rel')).slider('option', 'slide')(0,{values:[$('#'+$(this).attr('rel')).slider( 'option' , 'min' ), $('#'+$(this).attr('rel')).slider( 'option' , 'max' )]});
|
||||
}
|
||||
else if($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).attr('limitValue'));
|
||||
$('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).attr('limitValue'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($('option#'+$(this).attr('rel')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel')).parent().val('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+$(this).attr('rel')).attr('checked', false);
|
||||
$('.'+$(this).attr('rel')).attr('checked', false);
|
||||
$('#layered_form input[type=hidden][name='+$(this).attr('rel')+']').remove();
|
||||
}
|
||||
}
|
||||
reloadContent();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
function openCloseFilter()
|
||||
{
|
||||
$('#layered_form span.layered_close a').live('click', function(e)
|
||||
{
|
||||
if ($(this).html() == '<')
|
||||
{
|
||||
$('#'+$(this).attr('rel')).show();
|
||||
$(this).html('v');
|
||||
$(this).parent().removeClass('closed');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+$(this).attr('rel')).hide();
|
||||
$(this).html('<');
|
||||
$(this).parent().addClass('closed');
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
function stopAjaxQuery() {
|
||||
if (typeof(ajaxQueries) == 'undefined')
|
||||
ajaxQueries = new Array();
|
||||
for(i = 0; i < ajaxQueries.length; i++)
|
||||
ajaxQueries[i].abort();
|
||||
ajaxQueries = new Array();
|
||||
}
|
||||
|
||||
function reloadContent(params_plus)
|
||||
{
|
||||
stopAjaxQuery();
|
||||
|
||||
if (!ajaxLoaderOn)
|
||||
{
|
||||
$('#product_list').prepend($('#layered_ajax_loader').html());
|
||||
$('#product_list').css('opacity', '0.7');
|
||||
ajaxLoaderOn = 1;
|
||||
}
|
||||
|
||||
data = $('#layered_form').serialize();
|
||||
$('.layered_slider').each( function () {
|
||||
var sliderStart = $(this).slider('values', 0);
|
||||
var sliderStop = $(this).slider('values', 1);
|
||||
if (typeof(sliderStart) == 'number' && typeof(sliderStop) == 'number')
|
||||
data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop;
|
||||
});
|
||||
|
||||
$(['price', 'weight']).each(function(it, sliderType)
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_range_min').length)
|
||||
{
|
||||
data += '&layered_'+sliderType+'_slider='+$('#layered_'+sliderType+'_range_min').val()+'_'+$('#layered_'+sliderType+'_range_max').val();
|
||||
}
|
||||
});
|
||||
|
||||
$('#layered_form .select option').each( function () {
|
||||
if($(this).attr('id') && $(this).parent().val() == $(this).val())
|
||||
{
|
||||
data += '&'+$(this).attr('id') + '=' + $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('.selectProductSort').length && $('.selectProductSort').val())
|
||||
{
|
||||
if ($('.selectProductSort').val().search(/orderby=/) > 0)
|
||||
{
|
||||
// Old ordering working
|
||||
var splitData = [
|
||||
$('.selectProductSort').val().match(/orderby=(\w*)/)[1],
|
||||
$('.selectProductSort').val().match(/orderway=(\w*)/)[1]
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// New working for default theme 1.4 and theme 1.5
|
||||
var splitData = $('.selectProductSort').val().split(':');
|
||||
}
|
||||
data += '&orderby='+splitData[0]+'&orderway='+splitData[1];
|
||||
}
|
||||
if ($('.js-nb_item').length)
|
||||
{
|
||||
data += '&n='+$('.js-nb_item').val();
|
||||
}
|
||||
|
||||
var slideUp = true;
|
||||
if (params_plus == undefined)
|
||||
{
|
||||
params_plus = '';
|
||||
slideUp = false;
|
||||
}
|
||||
|
||||
// Get nb items per page
|
||||
var n = '';
|
||||
$('div.pagination .js-nb_item').children().each(function(it, option) {
|
||||
if (option.selected)
|
||||
n = '&n='+option.value;
|
||||
});
|
||||
|
||||
ajaxQuery = $.ajax(
|
||||
{
|
||||
type: 'GET',
|
||||
url: baseDir + 'modules/blocklayered/blocklayered-ajax.php',
|
||||
data: data+params_plus+n,
|
||||
dataType: 'json',
|
||||
cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example
|
||||
success: function(result)
|
||||
{
|
||||
$('#layered_block_left').replaceWith(utf8_decode(result.filtersBlock));
|
||||
|
||||
$('.category-product-count').html(result.categoryCount);
|
||||
|
||||
if (result.productList)
|
||||
$('#product_list').replaceWith(utf8_decode(result.productList));
|
||||
else
|
||||
$('#product_list').html('');
|
||||
|
||||
$('#product_list').css('opacity', '1');
|
||||
if ($.browser.msie) // Fix bug with IE8 and aliasing
|
||||
$('#product_list').css('filter', '');
|
||||
|
||||
if (result.pagination.search(/[^\s]/) >= 0) {
|
||||
if ($(result.pagination).find('ul.pagination').length)
|
||||
{
|
||||
$('div.pagination').show();
|
||||
$('ul.pagination').each(function () {
|
||||
$(this).replaceWith($(result.pagination).find('ul.pagination'));
|
||||
});
|
||||
}
|
||||
else if (!$('ul.pagination').length)
|
||||
{
|
||||
$('div.pagination').show();
|
||||
$('div.pagination').each(function () {
|
||||
$(this).html($(result.pagination));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('ul.pagination').html('');
|
||||
$('div.pagination').hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('ul.pagination').html('');
|
||||
$('div.pagination').hide();
|
||||
}
|
||||
|
||||
paginationButton();
|
||||
ajaxLoaderOn = 0;
|
||||
|
||||
// On submiting nb items form, relaod with the good nb of items
|
||||
$('div.pagination form').submit(function() {
|
||||
val = $('div.pagination .js-nb_item').val();
|
||||
$('div.pagination .js-nb_item').children().each(function(it, option) {
|
||||
if (option.value == val)
|
||||
$(option).attr('selected', true);
|
||||
else
|
||||
$(option).removeAttr('selected');
|
||||
});
|
||||
// Reload products and pagination
|
||||
reloadContent();
|
||||
return false;
|
||||
});
|
||||
if (typeof(ajaxCart) != "undefined")
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
|
||||
if (typeof(reloadProductComparison) == 'function')
|
||||
reloadProductComparison();
|
||||
initSliders();
|
||||
|
||||
// Currente page url
|
||||
if (typeof(current_friendly_url) == 'undefined')
|
||||
current_friendly_url = '#';
|
||||
|
||||
// Get all sliders value
|
||||
$(['price', 'weight']).each(function(it, sliderType)
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_slider').length)
|
||||
{
|
||||
// Check if slider is enable & if slider is used
|
||||
if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object')
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min')
|
||||
|| $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max'))
|
||||
current_friendly_url += '/'+sliderType+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1)
|
||||
}
|
||||
}
|
||||
else if ($('#layered_'+sliderType+'_range_min').length)
|
||||
{
|
||||
current_friendly_url += '/'+sliderType+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val();
|
||||
}
|
||||
});
|
||||
if (current_friendly_url == '#')
|
||||
current_friendly_url = '#/';
|
||||
window.location = current_friendly_url;
|
||||
lockLocationChecking = true;
|
||||
|
||||
if(slideUp)
|
||||
$.scrollTo('#product_list', 400);
|
||||
updateProductUrl();
|
||||
|
||||
$('.hide-action').each(function() {
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(ajaxQuery);
|
||||
}
|
||||
|
||||
function initLocationChange(func, time)
|
||||
{
|
||||
if(!time) time = 500;
|
||||
var current_friendly_url = getUrlParams();
|
||||
setInterval(function()
|
||||
{
|
||||
if(getUrlParams() != current_friendly_url && !lockLocationChecking)
|
||||
{
|
||||
// Don't reload page if current_friendly_url and real url match
|
||||
if (current_friendly_url.replace(/^#(\/)?/, '') == getUrlParams().replace(/^#(\/)?/, ''))
|
||||
return;
|
||||
|
||||
lockLocationChecking = true;
|
||||
reloadContent('&selected_filters='+getUrlParams().replace(/^#/, ''));
|
||||
}
|
||||
else {
|
||||
lockLocationChecking = false;
|
||||
current_friendly_url = getUrlParams();
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
|
||||
function getUrlParams()
|
||||
{
|
||||
var params = current_friendly_url;
|
||||
if(window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
|
||||
params = '#'+window.location.href.split('#')[1];
|
||||
return params;
|
||||
}
|
||||
|
||||
function updateProductUrl()
|
||||
{
|
||||
// Adding the filters to URL product
|
||||
if (typeof(param_product_url) != 'undefined' && param_product_url != '' && param_product_url !='#') {
|
||||
$.each($('ul#product_list li.ajax_block_product .product_img_link,'+
|
||||
'ul#product_list li.ajax_block_product h3 a,'+
|
||||
'ul#product_list li.ajax_block_product .product_desc a,'+
|
||||
'ul#product_list li.ajax_block_product .lnk_view'), function() {
|
||||
$(this).attr('href', $(this).attr('href') + param_product_url);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy of the php function utf8_decode()
|
||||
*/
|
||||
function utf8_decode (utfstr) {
|
||||
var res = '';
|
||||
for (var i = 0; i < utfstr.length;) {
|
||||
var c = utfstr.charCodeAt(i);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
res += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224))
|
||||
{
|
||||
var c1 = utfstr.charCodeAt(i+1);
|
||||
res += String.fromCharCode(((c & 31) << 6) | (c1 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var c1 = utfstr.charCodeAt(i+1);
|
||||
var c2 = utfstr.charCodeAt(i+2);
|
||||
res += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted price
|
||||
* Copy from tools.js
|
||||
*/
|
||||
function blocklayeredFormatCurrency(price, currencyFormat, currencySign, currencyBlank)
|
||||
{
|
||||
// if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)
|
||||
blank = '';
|
||||
price = parseFloat(price.toFixed(6));
|
||||
price = ps_round(price, priceDisplayPrecision);
|
||||
if (currencyBlank > 0)
|
||||
blank = ' ';
|
||||
if (currencyFormat == 1)
|
||||
return currencySign + blank + blocklayeredFormatNumber(price, priceDisplayPrecision, ',', '.');
|
||||
if (currencyFormat == 2)
|
||||
return (blocklayeredFormatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
|
||||
if (currencyFormat == 3)
|
||||
return (currencySign + blank + blocklayeredFormatNumber(price, priceDisplayPrecision, '.', ','));
|
||||
if (currencyFormat == 4)
|
||||
return (blocklayeredFormatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted number
|
||||
* Copy from tools.js
|
||||
*/
|
||||
function blocklayeredFormatNumber(value, numberOfDecimal, thousenSeparator, virgule)
|
||||
{
|
||||
value = value.toFixed(numberOfDecimal);
|
||||
var val_string = value+'';
|
||||
var tmp = val_string.split('.');
|
||||
var abs_val_string = (tmp.length == 2) ? tmp[0] : val_string;
|
||||
var deci_string = ('0.' + (tmp.length == 2 ? tmp[1] : 0)).substr(2);
|
||||
var nb = abs_val_string.length;
|
||||
|
||||
for (var i = 1 ; i < 4; i++)
|
||||
if (value >= Math.pow(10, (3 * i)))
|
||||
abs_val_string = abs_val_string.substring(0, nb - (3 * i)) + thousenSeparator + abs_val_string.substring(nb - (3 * i));
|
||||
|
||||
if (parseInt(numberOfDecimal) == 0)
|
||||
return abs_val_string;
|
||||
return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
(function($){
|
||||
/* hoverIntent by Brian Cherne */
|
||||
$.fn.hoverIntent = function(f,g) {
|
||||
// default configuration options
|
||||
var cfg = {
|
||||
sensitivity: 7,
|
||||
interval: 100,
|
||||
timeout: 0
|
||||
};
|
||||
// override configuration options with user supplied object
|
||||
cfg = $.extend(cfg, g ? { over: f, out: g } : f );
|
||||
|
||||
// instantiate variables
|
||||
// cX, cY = current X and Y position of mouse, updated by mousemove event
|
||||
// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
|
||||
var cX, cY, pX, pY;
|
||||
|
||||
// A private function for getting mouse position
|
||||
var track = function(ev) {
|
||||
cX = ev.pageX;
|
||||
cY = ev.pageY;
|
||||
};
|
||||
|
||||
// A private function for comparing current and previous mouse position
|
||||
var compare = function(ev,ob) {
|
||||
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
||||
// compare mouse positions to see if they've crossed the threshold
|
||||
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
|
||||
$(ob).unbind("mousemove",track);
|
||||
// set hoverIntent state to true (so mouseOut can be called)
|
||||
ob.hoverIntent_s = 1;
|
||||
return cfg.over.apply(ob,[ev]);
|
||||
} else {
|
||||
// set previous coordinates for next time
|
||||
pX = cX; pY = cY;
|
||||
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
|
||||
ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
|
||||
}
|
||||
};
|
||||
|
||||
// A private function for delaying the mouseOut function
|
||||
var delay = function(ev,ob) {
|
||||
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
|
||||
ob.hoverIntent_s = 0;
|
||||
return cfg.out.apply(ob,[ev]);
|
||||
};
|
||||
|
||||
// A private function for handling mouse 'hovering'
|
||||
var handleHover = function(e) {
|
||||
// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
|
||||
var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
|
||||
while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
|
||||
if ( p == this ) { return false; }
|
||||
|
||||
// copy objects to be passed into t (required for event object to be passed in IE)
|
||||
var ev = jQuery.extend({},e);
|
||||
var ob = this;
|
||||
|
||||
// cancel hoverIntent timer if it exists
|
||||
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
|
||||
|
||||
// else e.type == "onmouseover"
|
||||
if (e.type == "mouseover") {
|
||||
// set "previous" X and Y position based on initial entry point
|
||||
pX = ev.pageX; pY = ev.pageY;
|
||||
// update "current" X and Y position based on mousemove
|
||||
$(ob).bind("mousemove",track);
|
||||
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
||||
if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
|
||||
|
||||
// else e.type == "onmouseout"
|
||||
} else {
|
||||
// unbind expensive mousemove event
|
||||
$(ob).unbind("mousemove",track);
|
||||
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
||||
if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
|
||||
}
|
||||
};
|
||||
|
||||
// bind the function to the two event listeners
|
||||
return this.mouseover(handleHover).mouseout(handleHover);
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
/*
|
||||
* Superfish v1.4.8 - jQuery menu widget
|
||||
* Copyright (c) 2008 Joel Birch
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
|
||||
*/
|
||||
|
||||
;(function($){
|
||||
$.fn.superfish = function(op){
|
||||
|
||||
var sf = $.fn.superfish,
|
||||
c = sf.c,
|
||||
$arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
|
||||
over = function(){
|
||||
var $$ = $(this), menu = getMenu($$);
|
||||
clearTimeout(menu.sfTimer);
|
||||
$$.showSuperfishUl().siblings().hideSuperfishUl();
|
||||
},
|
||||
out = function(){
|
||||
var $$ = $(this), menu = getMenu($$), o = sf.op;
|
||||
clearTimeout(menu.sfTimer);
|
||||
menu.sfTimer=setTimeout(function(){
|
||||
o.retainPath=($.inArray($$[0],o.$path)>-1);
|
||||
$$.hideSuperfishUl();
|
||||
if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
|
||||
},o.delay);
|
||||
},
|
||||
getMenu = function($menu){
|
||||
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
|
||||
sf.op = sf.o[menu.serial];
|
||||
return menu;
|
||||
},
|
||||
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
|
||||
|
||||
return this.each(function() {
|
||||
var s = this.serial = sf.o.length;
|
||||
var o = $.extend({},sf.defaults,op);
|
||||
o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
|
||||
$(this).addClass([o.hoverClass,c.bcClass].join(' '))
|
||||
.filter('li:has(ul)').removeClass(o.pathClass);
|
||||
});
|
||||
sf.o[s] = sf.op = o;
|
||||
|
||||
$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
|
||||
if (o.autoArrows) addArrow( $('>a:first-child',this) );
|
||||
})
|
||||
.not('.'+c.bcClass)
|
||||
.hideSuperfishUl();
|
||||
|
||||
var $a = $('a',this);
|
||||
$a.each(function(i){
|
||||
var $li = $a.eq(i).parents('li');
|
||||
$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
|
||||
});
|
||||
o.onInit.call(this);
|
||||
|
||||
}).each(function() {
|
||||
menuClasses = [c.menuClass];
|
||||
if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
|
||||
$(this).addClass(menuClasses.join(' '));
|
||||
});
|
||||
};
|
||||
|
||||
var sf = $.fn.superfish;
|
||||
sf.o = [];
|
||||
sf.op = {};
|
||||
sf.IE7fix = function(){
|
||||
var o = sf.op;
|
||||
if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
|
||||
this.toggleClass(sf.c.shadowClass+'-off');
|
||||
};
|
||||
sf.c = {
|
||||
bcClass : 'sf-breadcrumb',
|
||||
menuClass : 'sf-js-enabled',
|
||||
anchorClass : 'sf-with-ul',
|
||||
arrowClass : 'sf-sub-indicator',
|
||||
shadowClass : 'sf-shadow'
|
||||
};
|
||||
sf.defaults = {
|
||||
hoverClass : 'sfHover',
|
||||
pathClass : 'overideThisToUse',
|
||||
pathLevels : 1,
|
||||
delay : 800,
|
||||
animation : {opacity:'show'},
|
||||
speed : 'fast',
|
||||
autoArrows : false,
|
||||
dropShadows : false,
|
||||
disableHI : false, // true disables hoverIntent detection
|
||||
onInit : function(){}, // callback functions
|
||||
onBeforeShow: function(){},
|
||||
onShow : function(){},
|
||||
onHide : function(){}
|
||||
};
|
||||
$.fn.extend({
|
||||
hideSuperfishUl : function(){
|
||||
var o = sf.op,
|
||||
not = (o.retainPath===true) ? o.$path : '';
|
||||
o.retainPath = false;
|
||||
var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
|
||||
.find('>ul').hide().css('visibility','hidden');
|
||||
o.onHide.call($ul);
|
||||
return this;
|
||||
},
|
||||
showSuperfishUl : function(){
|
||||
var o = sf.op,
|
||||
sh = sf.c.shadowClass+'-off',
|
||||
$ul = this.addClass(o.hoverClass)
|
||||
.find('>ul:hidden').css('visibility','visible');
|
||||
sf.IE7fix.call($ul);
|
||||
o.onBeforeShow.call($ul);
|
||||
$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
jQuery(function(){
|
||||
jQuery('ul.sf-menu').superfish();
|
||||
});
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/**
|
||||
* Update WishList Cart by adding, deleting, updating objects
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistCart(id, action, id_product, id_product_attribute, quantity)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: baseDir + 'modules/blockwishlist/cart.php',
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'action=' + action + '&id_product=' + id_product + '&quantity=' + quantity + '&token=' + static_token + '&id_product_attribute=' + id_product_attribute,
|
||||
success: function(data)
|
||||
{
|
||||
if (action == 'add')
|
||||
{
|
||||
if (isLoggedWishlist == true) {
|
||||
alert ('Adedd to wishlist')
|
||||
}
|
||||
else {
|
||||
alert ('You must be logged in to manage your wishlist.')
|
||||
}
|
||||
}
|
||||
|
||||
if($('#' + id).length != 0)
|
||||
{
|
||||
$('#' + id).slideUp('normal');
|
||||
document.getElementById(id).innerHTML = data;
|
||||
$('#' + id).slideDown('normal');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Change customer default wishlist
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistChangeDefault(id, id_wishlist)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: baseDir + 'modules/blockwishlist/cart.php',
|
||||
async: true,
|
||||
data: 'id_wishlist=' + id_wishlist + '&token=' + static_token,
|
||||
cache: false,
|
||||
success: function(data)
|
||||
{
|
||||
$('#' + id).slideUp('normal');
|
||||
document.getElementById(id).innerHTML = data;
|
||||
$('#' + id).slideDown('normal');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Buy Product
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistBuyProduct(token, id_product, id_product_attribute, id_quantity, button, ajax)
|
||||
{
|
||||
if(ajax)
|
||||
ajaxCart.add(id_product, id_product_attribute, false, button, 1, [token, id_quantity]);
|
||||
else
|
||||
{
|
||||
$('#' + id_quantity).val(0);
|
||||
WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity)
|
||||
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].method='POST';
|
||||
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].action=baseUri + '?controller=cart';
|
||||
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].elements['token'].value = static_token;
|
||||
document.forms['addtocart' + '_' + id_product + '_' + id_product_attribute].submit();
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
function WishlistAddProductCart(token, id_product, id_product_attribute, id_quantity)
|
||||
{
|
||||
if ($('#' + id_quantity).val() <= 0)
|
||||
return (false);
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: baseDir + 'modules/blockwishlist/buywishlistproduct.php',
|
||||
data: 'token=' + token + '&static_token=' + static_token + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute,
|
||||
async: true,
|
||||
cache: false,
|
||||
success: function(data)
|
||||
{
|
||||
if (data)
|
||||
alert(data);
|
||||
else
|
||||
{
|
||||
$('#' + id_quantity).val($('#' + id_quantity).val() - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
return (true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show wishlist managment page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistManage(id, id_wishlist)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
async: true,
|
||||
url: baseDir + 'modules/blockwishlist/managewishlist.php',
|
||||
data: 'id_wishlist=' + id_wishlist + '&refresh=' + false,
|
||||
cache: false,
|
||||
success: function(data)
|
||||
{
|
||||
$('#' + id).hide();
|
||||
document.getElementById(id).innerHTML = data;
|
||||
$('#' + id).fadeIn('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show wishlist product managment page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistProductManage(id, action, id_wishlist, id_product, id_product_attribute, quantity, priority)
|
||||
{
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
async: true,
|
||||
url: baseDir + 'modules/blockwishlist/managewishlist.php',
|
||||
data: 'action=' + action + '&id_wishlist=' + id_wishlist + '&id_product=' + id_product + '&id_product_attribute=' + id_product_attribute + '&quantity=' + quantity + '&priority=' + priority + '&refresh=' + true,
|
||||
cache: false,
|
||||
success: function(data)
|
||||
{
|
||||
if (action == 'delete')
|
||||
$('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast');
|
||||
else if (action == 'update')
|
||||
{
|
||||
$('#wlp_' + id_product + '_' + id_product_attribute).fadeOut('fast');
|
||||
$('#wlp_' + id_product + '_' + id_product_attribute).fadeIn('fast');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete wishlist
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
function WishlistDelete(id, id_wishlist, msg)
|
||||
{
|
||||
var res = confirm(msg);
|
||||
if (res == false)
|
||||
return (false);
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
async: true,
|
||||
url: baseDir + 'modules/blockwishlist/mywishlist.php',
|
||||
cache: false,
|
||||
data: 'deleted&id_wishlist=' + id_wishlist,
|
||||
success: function(data)
|
||||
{
|
||||
$('#' + id).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide/Show bought product
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistVisibility(bought_class, id_button)
|
||||
{
|
||||
if ($('#hide' + id_button).css('display') == 'none')
|
||||
{
|
||||
$('.' + bought_class).slideDown('fast');
|
||||
$('#show' + id_button).hide();
|
||||
$('#hide' + id_button).css('display', 'block');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.' + bought_class).slideUp('fast');
|
||||
$('#hide' + id_button).hide();
|
||||
$('#show' + id_button).css('display', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send wishlist by email
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function WishlistSend(id, id_wishlist, id_email)
|
||||
{
|
||||
$.post(baseDir + 'modules/blockwishlist/sendwishlist.php',
|
||||
{ token: static_token,
|
||||
id_wishlist: id_wishlist,
|
||||
email1: $('#' + id_email + '1').val(),
|
||||
email2: $('#' + id_email + '2').val(),
|
||||
email3: $('#' + id_email + '3').val(),
|
||||
email4: $('#' + id_email + '4').val(),
|
||||
email5: $('#' + id_email + '5').val(),
|
||||
email6: $('#' + id_email + '6').val(),
|
||||
email7: $('#' + id_email + '7').val(),
|
||||
email8: $('#' + id_email + '8').val(),
|
||||
email9: $('#' + id_email + '9').val(),
|
||||
email10: $('#' + id_email + '10').val() },
|
||||
function(data)
|
||||
{
|
||||
if (data)
|
||||
alert(data);
|
||||
else
|
||||
WishlistVisibility(id, 'hideSendWishlist');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function PS_SE_HandleEvent()
|
||||
{
|
||||
$(document).ready(function() {
|
||||
$('#id_country').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
|
||||
if (SE_RefreshMethod == 0)
|
||||
{
|
||||
$('#id_state').change(function() {
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
});
|
||||
|
||||
$('#zipcode').bind('keyup',function(e) {
|
||||
if (e.keyCode == '13')
|
||||
{
|
||||
resetAjaxQueries();
|
||||
updateCarriersList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#update_carriers_list').click(function() {
|
||||
updateCarriersList();
|
||||
});
|
||||
|
||||
$('#carriercompare_submit').click(function() {
|
||||
resetAjaxQueries();
|
||||
saveSelection();
|
||||
return false;
|
||||
});
|
||||
|
||||
updateStateByIdCountry();
|
||||
});
|
||||
}
|
||||
|
||||
function displayWaitingAjax(type, message)
|
||||
{
|
||||
$('#SE_AjaxDisplay').find('p').html(message);
|
||||
$('#SE_AjaxDisplay').css('display', type);
|
||||
}
|
||||
|
||||
function updateStateByIdCountry()
|
||||
{
|
||||
$('#id_state').children().remove();
|
||||
$('#availableCarriers').slideUp('fast');
|
||||
$('#states').slideUp('fast');
|
||||
displayWaitingAjax('block', SE_RefreshStateTS);
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(),
|
||||
data: 'method=getStates&id_country=' + $('#id_country').val(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
if (json.length)
|
||||
{
|
||||
for (state in json)
|
||||
{
|
||||
$('#id_state').append('<option value=\''+json[state].id_state+'\' '+(id_state == json[state].id_state ? 'selected="selected"' : '')+'>'+json[state].name+'</option>');
|
||||
}
|
||||
$('#states').slideDown('fast');
|
||||
}
|
||||
if (SE_RefreshMethod == 0)
|
||||
updateCarriersList();
|
||||
displayWaitingAjax('none', '');
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(query);
|
||||
}
|
||||
|
||||
function updateCarriersList()
|
||||
{
|
||||
$('#carriercompare_errors_list').children().remove();
|
||||
$('#availableCarriers').slideUp('normal', function(){
|
||||
$(this).find(('tbody')).children().remove();
|
||||
$('#noCarrier').slideUp('fast');
|
||||
displayWaitingAjax('block', SE_RetrievingInfoTS);
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(),
|
||||
data: 'method=getCarriers&id_country=' + $('#id_country').val() + '&id_state=' + $('#id_state').val() + '&zipcode=' + $('#zipcode').val(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
if (json.length)
|
||||
{
|
||||
for (carrier in json)
|
||||
{
|
||||
var html = '<tr class="'+(carrier % 2 ? 'alternate_' : '')+'item">'+
|
||||
'<td class="carrier_action">'+
|
||||
'<input type="radio" name="id_carrier" value="'+json[carrier].id_carrier+'" id="id_carrier'+json[carrier].id_carrier+'" '+(id_carrier == json[carrier].id_carrier ? 'checked="checked"' : '')+'/>'+
|
||||
'</td>'+
|
||||
'<td class="carrier_name">'+
|
||||
'<label for="id_carrier'+json[carrier].id_carrier+'">'+
|
||||
(json[carrier].img ? '<img src="'+json[carrier].img+'" alt="'+json[carrier].name+'" />' : json[carrier].name)+
|
||||
'</label>'+
|
||||
'</td>'+
|
||||
'<td class="carrier_infos">'+((json[carrier].delay != null) ? json[carrier].delay : '') +'</td>'+
|
||||
'<td class="carrier_price">';
|
||||
|
||||
if (json[carrier].price)
|
||||
{
|
||||
html += '<span class="price">'+(displayPrice == 1 ? formatCurrency(json[carrier].price_tax_exc, currencyFormat, currencySign, currencyBlank) : formatCurrency(json[carrier].price, currencyFormat, currencySign, currencyBlank))+'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
html += txtFree;
|
||||
}
|
||||
html += '</td>'+
|
||||
'</tr>';
|
||||
$('#carriers_list').append(html);
|
||||
}
|
||||
displayWaitingAjax('none', '');
|
||||
$('#availableCarriers').slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
displayWaitingAjax('none', '');
|
||||
$('#noCarrier').slideDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(query);
|
||||
});
|
||||
}
|
||||
|
||||
function saveSelection()
|
||||
{
|
||||
$('#carriercompare_errors').slideUp();
|
||||
$('#carriercompare_errors_list').children().remove();
|
||||
displayWaitingAjax('block', SE_RedirectTS);
|
||||
|
||||
var query = $.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + 'modules/carriercompare/ajax.php' + '?rand=' + new Date().getTime(),
|
||||
data: 'method=saveSelection&' + $('#compare_shipping_form').serialize(),
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
if (json.length)
|
||||
{
|
||||
for (error in json)
|
||||
$('#carriercompare_errors_list').append('<li>'+json[error]+'</li>');
|
||||
$('#carriercompare_errors').slideDown();
|
||||
displayWaitingAjax('none', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('.SE_SubmitRefreshCard').fadeOut('fast');
|
||||
location.reload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
var ajaxQueries = new Array();
|
||||
function resetAjaxQueries()
|
||||
{
|
||||
for (i = 0; i < ajaxQueries.length; ++i)
|
||||
ajaxQueries[i].abort();
|
||||
ajaxQueries = new Array();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(function(){
|
||||
|
||||
if (typeof(homeslider_speed) == 'undefined')
|
||||
homeslider_speed = 500;
|
||||
if (typeof(homeslider_pause) == 'undefined')
|
||||
homeslider_pause = 3000;
|
||||
if (typeof(homeslider_loop) == 'undefined')
|
||||
homeslider_loop = true;
|
||||
|
||||
$('#homeslider').bxSlider();
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
if (typeof(formatedAddressFieldsValuesList) !== 'undefined')
|
||||
updateAddressesDisplay(true);
|
||||
});
|
||||
|
||||
//update the display of the addresses
|
||||
function updateAddressesDisplay(first_view)
|
||||
{
|
||||
// update content of delivery address
|
||||
updateAddressDisplay('delivery');
|
||||
var txtInvoiceTitle = "";
|
||||
try{
|
||||
var adrs_titles = getAddressesTitles();
|
||||
txtInvoiceTitle = adrs_titles.invoice;
|
||||
}
|
||||
catch (e)
|
||||
{}
|
||||
// update content of invoice address
|
||||
//if addresses have to be equals...
|
||||
if ($('input[type=checkbox]#addressesAreEquals:checked').length === 1 && ($('#multishipping_mode_checkbox:checked').length === 0))
|
||||
{
|
||||
if ($('#multishipping_mode_checkbox:checked').length === 0) {
|
||||
$('#address_invoice_form:visible').hide('fast');
|
||||
}
|
||||
$('ul#address_invoice').html($('ul#address_delivery').html());
|
||||
$('ul#address_invoice li.address_title').html(txtInvoiceTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#address_invoice_form:hidden').show('fast');
|
||||
if ($('#id_address_invoice').val())
|
||||
updateAddressDisplay('invoice');
|
||||
else
|
||||
{
|
||||
$('ul#address_invoice').html($('ul#address_delivery').html());
|
||||
$('ul#address_invoice li.address_title').html(txtInvoiceTitle);
|
||||
}
|
||||
}
|
||||
if(!first_view)
|
||||
{
|
||||
if (orderProcess === 'order')
|
||||
updateAddresses();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateAddressDisplay(addressType)
|
||||
{
|
||||
if (formatedAddressFieldsValuesList.length <= 0)
|
||||
return false;
|
||||
|
||||
var idAddress = parseInt($('#id_address_' + addressType + '').val());
|
||||
buildAddressBlock(idAddress, addressType, $('#address_' + addressType));
|
||||
|
||||
// change update link
|
||||
var link = $('ul#address_' + addressType + ' li.address_update a').attr('href');
|
||||
var expression = /id_address=\d+/;
|
||||
if (link)
|
||||
{
|
||||
link = link.replace(expression, 'id_address=' + idAddress);
|
||||
$('ul#address_' + addressType + ' li.address_update a').attr('href', link);
|
||||
}
|
||||
}
|
||||
|
||||
function updateAddresses()
|
||||
{
|
||||
var idAddress_delivery = parseInt($('#id_address_delivery').val());
|
||||
var idAddress_invoice = $('input[type=checkbox]#addressesAreEquals:checked').length === 1 ? idAddress_delivery : parseInt($('#id_address_invoice').val());
|
||||
|
||||
if(isNaN(idAddress_delivery) == false && isNaN(idAddress_invoice) == false)
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: {
|
||||
processAddress: true,
|
||||
step: 2,
|
||||
ajax: 'true',
|
||||
controller: 'order',
|
||||
'multi-shipping': $('#id_address_delivery:hidden').length,
|
||||
id_address_delivery: idAddress_delivery,
|
||||
id_address_invoice: idAddress_invoice,
|
||||
token: static_token
|
||||
},
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,869 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function updateCarrierList(json)
|
||||
{
|
||||
var html = json.carrier_block;
|
||||
|
||||
// @todo check with theme 1.4
|
||||
//if ($('#HOOK_EXTRACARRIER').length == 0 && json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined)
|
||||
// html += json.HOOK_EXTRACARRIER;
|
||||
|
||||
$('#carrier_area').replaceWith(html);
|
||||
bindInputs();
|
||||
/* update hooks for carrier module */
|
||||
$('#HOOK_BEFORECARRIER').html(json.HOOK_BEFORECARRIER);
|
||||
}
|
||||
|
||||
function updatePaymentMethods(json)
|
||||
{
|
||||
$('#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
|
||||
$('#opc_payment_methods-content #HOOK_PAYMENT').html(json.HOOK_PAYMENT);
|
||||
}
|
||||
|
||||
function updatePaymentMethodsDisplay()
|
||||
{
|
||||
var checked = '';
|
||||
if ($('#cgv:checked').length !== 0)
|
||||
checked = 1;
|
||||
else
|
||||
checked = 0;
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow', function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
updatePaymentMethods(json);
|
||||
}
|
||||
});
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function updateAddressSelection()
|
||||
{
|
||||
var idAddress_delivery = ($('#opc_id_address_delivery').length == 1 ? $('#opc_id_address_delivery').val() : $('#id_address_delivery').val());
|
||||
var idAddress_invoice = ($('#opc_id_address_invoice').length == 1 ? $('#opc_id_address_invoice').val() : ($('#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : idAddress_delivery)));
|
||||
|
||||
$('#opc_account-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'allow_refresh=1&ajax=true&method=updateAddressesSelected&id_address_delivery=' + idAddress_delivery + '&id_address_invoice=' + idAddress_invoice + '&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
// Update all product keys with the new address id
|
||||
$('#cart_summary .address_'+deliveryAddress).each(function() {
|
||||
$(this)
|
||||
.removeClass('address_'+deliveryAddress)
|
||||
.addClass('address_'+idAddress_delivery);
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
if ($(this).find('.cart_unit span').length > 0 && $(this).find('.cart_unit span').attr('id').length > 0)
|
||||
$(this).find('.cart_unit span').attr('id', $(this).find('.cart_unit span').attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
|
||||
if ($(this).find('.cart_total span').length > 0 && $(this).find('.cart_total span').attr('id').length > 0)
|
||||
$(this).find('.cart_total span').attr('id', $(this).find('.cart_total span').attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
|
||||
if ($(this).find('.cart_quantity_input').length > 0 && $(this).find('.cart_quantity_input').attr('name').length > 0)
|
||||
{
|
||||
var name = $(this).find('.cart_quantity_input').attr('name')+'_hidden';
|
||||
$(this).find('.cart_quantity_input').attr('name', $(this).find('.cart_quantity_input').attr('name').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
if ($(this).find('[name='+name+']').length > 0)
|
||||
$(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_delete')
|
||||
.attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_down')
|
||||
.attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_up')
|
||||
.attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
});
|
||||
|
||||
// Update global var deliveryAddress
|
||||
deliveryAddress = idAddress_delivery;
|
||||
if (window.ajaxCart !== undefined)
|
||||
{
|
||||
$('#cart_block_list dd, #cart_block_list dt').each(function(){
|
||||
if (typeof($(this).attr('id')) != 'undefined')
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + idAddress_delivery));
|
||||
});
|
||||
}
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(jsonData.gift_price);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCarrierListAndUpdate()
|
||||
{
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getCarrierList&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
updateCarrierList(jsonData);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierSelectionAndGift()
|
||||
{
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
if ($(this).prop('checked'))
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&';
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
if ($('input#gift:checked').length)
|
||||
{
|
||||
gift = 1;
|
||||
giftMessage = encodeURIComponent($('#gift_message').val());
|
||||
}
|
||||
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
refreshDeliveryOptions();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmFreeOrder()
|
||||
{
|
||||
if ($('#opc_new_account-overlay').length !== 0)
|
||||
$('#opc_new_account-overlay').fadeIn('slow');
|
||||
else
|
||||
$('#opc_account-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$('#confirmOrder').attr('disabled', 'disabled');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "html",
|
||||
data: 'ajax=true&method=makeFreeOrder&token=' + static_token ,
|
||||
success: function(html)
|
||||
{
|
||||
$('#confirmOrder').attr('disabled', '');
|
||||
var array_split = html.split(':');
|
||||
if (array_split[0] == 'freeorder')
|
||||
{
|
||||
if (isGuest)
|
||||
document.location.href = guestTrackingUrl+'?id_order='+encodeURIComponent(array_split[1])+'&email='+encodeURIComponent(array_split[2]);
|
||||
else
|
||||
document.location.href = historyUrl;
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to confirm the order \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveAddress(type)
|
||||
{
|
||||
if (type !== 'delivery' && type !== 'invoice')
|
||||
return false;
|
||||
|
||||
var params = 'firstname='+encodeURIComponent($('#firstname'+(type == 'invoice' ? '_invoice' : '')).val())+'&lastname='+encodeURIComponent($('#lastname'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'company='+encodeURIComponent($('#company'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'vat_number='+encodeURIComponent($('#vat_number'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'dni='+encodeURIComponent($('#dni'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'address1='+encodeURIComponent($('#address1'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'address2='+encodeURIComponent($('#address2'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'postcode='+encodeURIComponent($('#postcode'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'city='+encodeURIComponent($('#city'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'id_country='+encodeURIComponent($('#id_country').val())+'&';
|
||||
if ($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val())
|
||||
params += 'id_state='+encodeURIComponent($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'other='+encodeURIComponent($('#other'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'phone='+encodeURIComponent($('#phone'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'alias='+encodeURIComponent($('#alias'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
if (type == 'delivery' && $('#opc_id_address_delivery').val() != undefined && parseInt($('#opc_id_address_delivery').val()) > 0)
|
||||
params += 'opc_id_address_delivery='+encodeURIComponent($('#opc_id_address_delivery').val())+'&';
|
||||
if (type == 'invoice' && $('#opc_id_address_invoice').val() != undefined && parseInt($('#opc_id_address_invoice').val()) > 0)
|
||||
params += 'opc_id_address_invoice='+encodeURIComponent($('#opc_id_address_invoice').val())+'&';
|
||||
// Clean the last &
|
||||
params = params.substr(0, params.length-1);
|
||||
|
||||
var result = false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: addressUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&submitAddress=true&type='+type+'&'+params+'&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
{
|
||||
i = i+1;
|
||||
tmp += '<li>'+jsonData.errors[error]+'</li>';
|
||||
}
|
||||
tmp += '</ol>';
|
||||
var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
|
||||
$('#opc_account_errors').slideUp('fast', function(){
|
||||
$(this).html(errors).slideDown('slow', function(){
|
||||
$.scrollTo('#opc_account_errors', 800);
|
||||
});
|
||||
});
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update addresses id
|
||||
$('input#opc_id_address_delivery').val(jsonData.id_address_delivery);
|
||||
$('input#opc_id_address_invoice').val(jsonData.id_address_invoice);
|
||||
result = true;
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function updateNewAccountToAddressBlock()
|
||||
{
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getAddressBlockAndCarriersAndPayments&token=' + static_token ,
|
||||
success: function(json)
|
||||
{
|
||||
isLogged = 1;
|
||||
if (json.no_address == 1)
|
||||
document.location.href = addressUrl;
|
||||
|
||||
$('#opc_new_account').fadeOut('fast', function() {
|
||||
$('#opc_new_account').html(json.order_opc_adress);
|
||||
// update block user info
|
||||
if (json.block_user_info !== '' && $('#header_user').length == 1)
|
||||
{
|
||||
var elt = $(json.block_user_info).find('#header_user_info').html();
|
||||
$('#header_user_info').fadeOut('nortmal', function() {
|
||||
$(this).html(elt).fadeIn();
|
||||
});
|
||||
}
|
||||
$('#opc_new_account').fadeIn('fast', function() {
|
||||
//After login, the products are automatically associated to an address
|
||||
$.each(json.summary.products, function() {
|
||||
updateAddressId(this.id_product, this.id_product_attribute, '0', this.id_address_delivery);
|
||||
});
|
||||
updateAddressesDisplay(true);
|
||||
updateCarrierList(json.carrier_data);
|
||||
updateCarrierSelectionAndGift();
|
||||
updatePaymentMethods(json);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(json.gift_price);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT
|
||||
if ((!isLogged) || (isGuest))
|
||||
{
|
||||
if (guestCheckoutEnabled && !isLogged)
|
||||
{
|
||||
$('#opc_account_choice').show();
|
||||
$('#opc_account_form, #opc_invoice_address').hide();
|
||||
|
||||
$('#opc_createAccount').click(function() {
|
||||
$('.is_customer_param').show();
|
||||
$('#opc_account_form').slideDown('slow');
|
||||
$('#is_new_customer').val('1');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
$('#opc_guestCheckout').click(function() {
|
||||
$('.is_customer_param').hide();
|
||||
$('#opc_account_form').slideDown('slow');
|
||||
$('#is_new_customer').val('0');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
$('#new_account_title').html(txtInstantCheckout);
|
||||
$('#submitAccount').prop({id : 'submitGuestAccount', name : 'submitGuestAccount'});
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
}
|
||||
else if (isGuest)
|
||||
{
|
||||
$('.is_customer_param').hide();
|
||||
$('#opc_account_form').show('slow');
|
||||
$('#is_new_customer').val('0');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
$('#new_account_title').html(txtInstantCheckout);
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#opc_account_choice').hide();
|
||||
$('#is_new_customer').val('1');
|
||||
$('.is_customer_param, #opc_account_form').show();
|
||||
$('#opc_invoice_address').hide();
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
}
|
||||
|
||||
// LOGIN FORM
|
||||
$('#openLoginFormBlock').click(function() {
|
||||
$('#openNewAccountBlock').show();
|
||||
$(this).hide();
|
||||
$('#login_form_content').slideDown('slow');
|
||||
$('#new_account_form_content').slideUp('slow');
|
||||
return false;
|
||||
});
|
||||
// LOGIN FORM SENDING
|
||||
$('#SubmitLogin').click(function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: authenticationUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#login_passwd').val())+'&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += '<li>'+jsonData.errors[error]+'</li>';
|
||||
errors += '</ol>';
|
||||
$('#opc_login_errors').html(errors).slideDown('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
// update token
|
||||
static_token = jsonData.token;
|
||||
updateNewAccountToAddressBlock();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// INVOICE ADDRESS
|
||||
$('#invoice_address').click(function() {
|
||||
bindCheckbox();
|
||||
});
|
||||
|
||||
// VALIDATION / CREATION AJAX
|
||||
$('#submitAccount').click(function() {
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
|
||||
|
||||
var callingFile = '';
|
||||
var params = '';
|
||||
|
||||
if (parseInt($('#opc_id_customer').val()) == 0)
|
||||
{
|
||||
callingFile = authenticationUrl;
|
||||
params = 'submitAccount=true&';
|
||||
}
|
||||
else
|
||||
{
|
||||
callingFile = orderOpcUrl;
|
||||
params = 'method=editCustomer&';
|
||||
}
|
||||
|
||||
$('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() {
|
||||
if ($(this).is('input[type=checkbox]'))
|
||||
{
|
||||
if ($(this).is(':checked'))
|
||||
params += encodeURIComponent($(this).attr('name'))+'=1&';
|
||||
}
|
||||
else if ($(this).is('input[type=radio]'))
|
||||
{
|
||||
if ($(this).is(':checked'))
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
}
|
||||
else
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
});
|
||||
$('#opc_account_form select:visible').each(function() {
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
});
|
||||
params += 'customer_lastname='+encodeURIComponent($('#customer_lastname').val())+'&';
|
||||
params += 'customer_firstname='+encodeURIComponent($('#customer_firstname').val())+'&';
|
||||
params += 'alias='+encodeURIComponent($('#alias').val())+'&';
|
||||
params += 'other='+encodeURIComponent($('#other').val())+'&';
|
||||
params += 'is_new_customer='+encodeURIComponent($('#is_new_customer').val())+'&';
|
||||
// Clean the last &
|
||||
params = params.substr(0, params.length-1);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: callingFile + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&'+params+'&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
{
|
||||
i = i+1;
|
||||
tmp += '<li>'+jsonData.errors[error]+'</li>';
|
||||
}
|
||||
tmp += '</ol>';
|
||||
var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
|
||||
$('#opc_account_errors').slideUp('fast', function(){
|
||||
$(this).html(errors).slideDown('slow', function(){
|
||||
$.scrollTo('#opc_account_errors', 800);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#opc_account_errors').slideUp('slow', function(){
|
||||
$(this).html('');
|
||||
});
|
||||
}
|
||||
|
||||
isGuest = parseInt($('#is_new_customer').val()) == 1 ? 0 : 1;
|
||||
// update addresses id
|
||||
if(jsonData.id_address_delivery !== undefined && jsonData.id_address_delivery > 0)
|
||||
$('#opc_id_address_delivery').val(jsonData.id_address_delivery);
|
||||
if(jsonData.id_address_invoice !== undefined && jsonData.id_address_invoice > 0)
|
||||
$('#opc_id_address_invoice').val(jsonData.id_address_invoice);
|
||||
|
||||
if (jsonData.id_customer !== undefined && jsonData.id_customer !== 0 && jsonData.isSaved)
|
||||
{
|
||||
// update token
|
||||
static_token = jsonData.token;
|
||||
|
||||
// It's not a new customer
|
||||
if ($('#opc_id_customer').val() !== '0')
|
||||
if (!saveAddress('delivery'))
|
||||
return false;
|
||||
|
||||
// update id_customer
|
||||
$('#opc_id_customer').val(jsonData.id_customer);
|
||||
|
||||
if ($('#invoice_address:checked').length !== 0)
|
||||
{
|
||||
if (!saveAddress('invoice'))
|
||||
return false;
|
||||
}
|
||||
|
||||
// update id_customer
|
||||
$('#opc_id_customer').val(jsonData.id_customer);
|
||||
|
||||
// force to refresh carrier list
|
||||
if (isGuest)
|
||||
{
|
||||
isLogged = 1;
|
||||
$('#opc_account_saved').fadeIn('slow');
|
||||
$('#submitAccount').hide();
|
||||
updateAddressSelection();
|
||||
}
|
||||
else
|
||||
updateNewAccountToAddressBlock();
|
||||
}
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
bindCheckbox();
|
||||
bindInputs();
|
||||
|
||||
$('#opc_account_form input,select,textarea').change(function() {
|
||||
if ($(this).is(':visible'))
|
||||
{
|
||||
$('#opc_account_saved').fadeOut('slow');
|
||||
$('#submitAccount').show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function bindCheckbox()
|
||||
{
|
||||
if ($('#invoice_address:checked').length > 0)
|
||||
{
|
||||
$('#opc_invoice_address').slideDown('slow');
|
||||
if ($('#company_invoice').val() == '')
|
||||
$('#vat_number_block_invoice').hide();
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
}
|
||||
else
|
||||
$('#opc_invoice_address').slideUp('slow');
|
||||
}
|
||||
|
||||
function bindInputs()
|
||||
{
|
||||
// Order message update
|
||||
$('#message').blur(function() {
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Recyclable checkbox
|
||||
$('#recyclable').click(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Gift checkbox update
|
||||
$('#gift').click(function() {
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
|
||||
// Gift message update
|
||||
$('#gift_message').change(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Term Of Service (TOS)
|
||||
$('#cgv').click(function() {
|
||||
updatePaymentMethodsDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
function multishippingMode(it)
|
||||
{
|
||||
if ($(it).prop('checked'))
|
||||
{
|
||||
$('#address_delivery, .address_delivery').hide();
|
||||
$('#address_delivery, .address_delivery').parent().hide();
|
||||
$('#address_invoice').removeClass('alternate_item').addClass('item');
|
||||
$('#multishipping_mode_box').addClass('on');
|
||||
$('.addressesAreEquals').hide();
|
||||
$('#address_invoice_form').show();
|
||||
|
||||
$('#link_multishipping_form').click(function() {return false;});
|
||||
$('.address_add a').attr('href', addressMultishippingUrl);
|
||||
|
||||
$('#link_multishipping_form').fancybox({
|
||||
'transitionIn': 'elastic',
|
||||
'transitionOut': 'elastic',
|
||||
'type': 'ajax',
|
||||
'beforeClose': function()
|
||||
{
|
||||
// Reload the cart
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
data: 'ajax=true&method=cartReload',
|
||||
dataType : 'html',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$('#cart_summary').replaceWith($(data).find('#cart_summary'));
|
||||
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el); } });
|
||||
}
|
||||
});
|
||||
updateCarrierSelectionAndGift();
|
||||
},
|
||||
'beforeLoad': function()
|
||||
{
|
||||
// Removing all ids on the cart to avoid conflic with the new one on the fancybox
|
||||
// This action could "break" the cart design, if css rules use ids of the cart
|
||||
$.each($('#cart_summary *'), function(it, el) {
|
||||
$(el).attr('id', '');
|
||||
});
|
||||
},
|
||||
'onComplete': function()
|
||||
{
|
||||
$('#fancybox-content .cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, false, this.el);} });
|
||||
cleanSelectAddressDelivery();
|
||||
$('#fancybox-content').append($('<div class="multishipping_close_container"><a id="multishipping-close" class="button_large btn btn-default" href="#">' + CloseTxt + '</a></div>'));
|
||||
$('#multishipping-close').click(function() {
|
||||
var newTotalQty = 0;
|
||||
$('#fancybox-content .cart_quantity_input').each(function(){
|
||||
newTotalQty += parseInt($(this).val());
|
||||
});
|
||||
if (newTotalQty !== totalQty) {
|
||||
if(!confirm(QtyChanged)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$.fancybox.close();
|
||||
return false;
|
||||
});
|
||||
totalQty = 0;
|
||||
$('#fancybox-content .cart_quantity_input').each(function(){
|
||||
totalQty += parseInt($(this).val());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#address_delivery, .address_delivery').show();
|
||||
$('#address_invoice').removeClass('item').addClass('alternate_item');
|
||||
$('#multishipping_mode_box').removeClass('on');
|
||||
$('.addressesAreEquals').show();
|
||||
if ($('.addressesAreEquals').find('input:checked').length)
|
||||
$('#address_invoice_form').hide();
|
||||
else
|
||||
$('#address_invoice_form').show();
|
||||
$('.address_add a').attr('href', addressUrl);
|
||||
|
||||
// Disable multi address shipping
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax=true&method=noMultiAddressDelivery'
|
||||
});
|
||||
|
||||
// Reload the cart
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax=true&method=cartReload',
|
||||
dataType : 'html',
|
||||
success: function(data) {
|
||||
$('#cart_summary').replaceWith($(data).find('#cart_summary'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// If the multishipping mode is off assure us the checkbox "I want to specify a delivery address for each products I order." is unchecked.
|
||||
$('#multishipping_mode_checkbox').attr('checked', false);
|
||||
// If the multishipping mode is on, check the box "I want to specify a delivery address for each products I order.".
|
||||
if (typeof(multishipping_mode) !== 'undefined' && multishipping_mode)
|
||||
{
|
||||
$('#multishipping_mode_checkbox').click();
|
||||
$('.addressesAreEquals').hide().find('input').attr('checked', false);
|
||||
}
|
||||
if (typeof(open_multishipping_fancybox) !== 'undefined' && open_multishipping_fancybox)
|
||||
$('#link_multishipping_form').click();
|
||||
});
|
||||
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
|
||||
//global variables
|
||||
var combinations = [];
|
||||
var selectedCombination = [];
|
||||
var globalQuantity = 0;
|
||||
var colors = [];
|
||||
|
||||
//check if a function exists
|
||||
function function_exists(function_name)
|
||||
{
|
||||
if (typeof function_name == 'string')
|
||||
return (typeof window[function_name] == 'function');
|
||||
return (function_name instanceof Function);
|
||||
}
|
||||
|
||||
//execute oosHook js code
|
||||
function oosHookJsCode()
|
||||
{
|
||||
for (var i = 0; i < oosHookJsCodeFunctions.length; i++)
|
||||
{
|
||||
if (function_exists(oosHookJsCodeFunctions[i]))
|
||||
setTimeout(oosHookJsCodeFunctions[i] + '()', 0);
|
||||
}
|
||||
}
|
||||
|
||||
//add a combination of attributes in the global JS sytem
|
||||
function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, unit_price, minimal_quantity, available_date, combination_specific_price)
|
||||
{
|
||||
globalQuantity += quantity;
|
||||
|
||||
var combination = [];
|
||||
combination['idCombination'] = idCombination;
|
||||
combination['quantity'] = quantity;
|
||||
combination['idsAttributes'] = arrayOfIdAttributes;
|
||||
combination['price'] = price;
|
||||
combination['ecotax'] = ecotax;
|
||||
combination['image'] = id_image;
|
||||
combination['reference'] = reference;
|
||||
combination['unit_price'] = unit_price;
|
||||
combination['minimal_quantity'] = minimal_quantity;
|
||||
combination['available_date'] = [];
|
||||
combination['available_date'] = available_date;
|
||||
combination['specific_price'] = [];
|
||||
combination['specific_price'] = combination_specific_price;
|
||||
combinations.push(combination);
|
||||
}
|
||||
|
||||
// search the combinations' case of attributes and update displaying of availability, prices, ecotax, and image
|
||||
function findCombination(firstTime)
|
||||
{
|
||||
$('#minimal_quantity_wanted_p').fadeOut();
|
||||
$('#quantity_wanted').val(1);
|
||||
//create a temporary 'choice' array containing the choices of the customer
|
||||
var choice = [];
|
||||
$('#attributes select, #attributes input[type=hidden], #attributes input[type=radio]:checked').each(function(){
|
||||
choice.push($(this).val());
|
||||
});
|
||||
|
||||
//testing every combination to find the conbination's attributes' case of the user
|
||||
for (var combination = 0; combination < combinations.length; ++combination)
|
||||
{
|
||||
//verify if this combinaison is the same that the user's choice
|
||||
var combinationMatchForm = true;
|
||||
$.each(combinations[combination]['idsAttributes'], function(key, value)
|
||||
{
|
||||
if (!in_array(value, choice))
|
||||
combinationMatchForm = false;
|
||||
});
|
||||
|
||||
if (combinationMatchForm)
|
||||
{
|
||||
if (combinations[combination]['minimal_quantity'] > 1)
|
||||
{
|
||||
$('#minimal_quantity_label').html(combinations[combination]['minimal_quantity']);
|
||||
$('#minimal_quantity_wanted_p').fadeIn();
|
||||
$('#quantity_wanted').val(combinations[combination]['minimal_quantity']);
|
||||
$('#quantity_wanted').bind('keyup', function() {checkMinimalQuantity(combinations[combination]['minimal_quantity']);});
|
||||
}
|
||||
//combination of the user has been found in our specifications of combinations (created in back office)
|
||||
selectedCombination['unavailable'] = false;
|
||||
selectedCombination['reference'] = combinations[combination]['reference'];
|
||||
$('#idCombination').val(combinations[combination]['idCombination']);
|
||||
|
||||
//get the data of product with these attributes
|
||||
quantityAvailable = combinations[combination]['quantity'];
|
||||
selectedCombination['price'] = combinations[combination]['price'];
|
||||
selectedCombination['unit_price'] = combinations[combination]['unit_price'];
|
||||
selectedCombination['specific_price'] = combinations[combination]['specific_price'];
|
||||
if (combinations[combination]['ecotax'])
|
||||
selectedCombination['ecotax'] = combinations[combination]['ecotax'];
|
||||
else
|
||||
selectedCombination['ecotax'] = default_eco_tax;
|
||||
|
||||
//show the large image in relation to the selected combination
|
||||
if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
|
||||
displayImage($('#thumb_' + combinations[combination]['image']).parent());
|
||||
|
||||
//show discounts values according to the selected combination
|
||||
if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
|
||||
displayDiscounts(combinations[combination]['idCombination']);
|
||||
|
||||
//get available_date for combination product
|
||||
selectedCombination['available_date'] = combinations[combination]['available_date'];
|
||||
|
||||
//update the display
|
||||
updateDisplay();
|
||||
|
||||
if(typeof(firstTime) != 'undefined' && firstTime)
|
||||
refreshProductImages(0);
|
||||
else
|
||||
refreshProductImages(combinations[combination]['idCombination']);
|
||||
//leave the function because combination has been found
|
||||
return;
|
||||
}
|
||||
}
|
||||
//this combination doesn't exist (not created in back office)
|
||||
selectedCombination['unavailable'] = true;
|
||||
if (typeof(selectedCombination['available_date']) != 'undefined')
|
||||
delete selectedCombination['available_date'];
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
//update display of the availability of the product AND the prices of the product
|
||||
function updateDisplay()
|
||||
{
|
||||
var productPriceDisplay = productPrice;
|
||||
var productPriceWithoutReductionDisplay = productPriceWithoutReduction;
|
||||
|
||||
if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1)
|
||||
{
|
||||
//show the choice of quantities
|
||||
$('#quantity_wanted_p:hidden').show('slow');
|
||||
|
||||
//show the "add to cart" button ONLY if it was hidden
|
||||
$('#add_to_cart:hidden').fadeIn(600);
|
||||
|
||||
//hide the hook out of stock
|
||||
$('#oosHook').hide();
|
||||
|
||||
$('#availability_date').fadeOut();
|
||||
|
||||
//availability value management
|
||||
if (availableNowValue != '')
|
||||
{
|
||||
//update the availability statut of the product
|
||||
$('#availability_value').removeClass('warning_inline');
|
||||
$('#availability_value').text(availableNowValue);
|
||||
if(stock_management == 1)
|
||||
$('#availability_statut:hidden').show();
|
||||
}
|
||||
else
|
||||
$('#availability_statut:visible').hide();
|
||||
|
||||
//'last quantities' message management
|
||||
if (!allowBuyWhenOutOfStock)
|
||||
{
|
||||
if (quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage)
|
||||
$('#last_quantities').show('slow');
|
||||
else
|
||||
$('#last_quantities').hide('slow');
|
||||
}
|
||||
|
||||
if (quantitiesDisplayAllowed)
|
||||
{
|
||||
$('#pQuantityAvailable:hidden').show('slow');
|
||||
$('#quantityAvailable').text(quantityAvailable);
|
||||
|
||||
if (quantityAvailable < 2) // we have 1 or less product in stock and need to show "item" instead of "items"
|
||||
{
|
||||
$('#quantityAvailableTxt').show();
|
||||
$('#quantityAvailableTxtMultiple').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#quantityAvailableTxt').hide();
|
||||
$('#quantityAvailableTxtMultiple').show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//show the hook out of stock
|
||||
if (productAvailableForOrder == 1)
|
||||
{
|
||||
$('#oosHook').show();
|
||||
if ($('#oosHook').length > 0 && function_exists('oosHookJsCode'))
|
||||
oosHookJsCode();
|
||||
}
|
||||
|
||||
//hide 'last quantities' message if it was previously visible
|
||||
$('#last_quantities:visible').hide('slow');
|
||||
|
||||
//hide the quantity of pieces if it was previously visible
|
||||
$('#pQuantityAvailable:visible').hide('slow');
|
||||
|
||||
//hide the choice of quantities
|
||||
if (!allowBuyWhenOutOfStock)
|
||||
$('#quantity_wanted_p:visible').hide('slow');
|
||||
|
||||
//display that the product is unavailable with theses attributes
|
||||
if (!selectedCombination['unavailable'])
|
||||
$('#availability_value').text(doesntExistNoMore + (globalQuantity > 0 ? ' ' + doesntExistNoMoreBut : '')).addClass('warning_inline');
|
||||
else
|
||||
{
|
||||
$('#availability_value').text(doesntExist).addClass('warning_inline');
|
||||
$('#oosHook').hide();
|
||||
}
|
||||
if(stock_management == 1 && !allowBuyWhenOutOfStock)
|
||||
$('#availability_statut:hidden').show();
|
||||
|
||||
if (typeof(selectedCombination['available_date']) != 'undefined' && selectedCombination['available_date']['date'].length != 0)
|
||||
{
|
||||
var available_date = selectedCombination['available_date']['date'];
|
||||
var tab_date = available_date.split('-');
|
||||
var time_available = new Date(tab_date[0], tab_date[1], tab_date[2]);
|
||||
time_available.setMonth(time_available.getMonth()-1);
|
||||
var now = new Date();
|
||||
if (now.getTime() < time_available.getTime() && $('#availability_date_value').text() != selectedCombination['available_date']['date_formatted'])
|
||||
{
|
||||
$('#availability_date').fadeOut('normal', function(){
|
||||
$('#availability_date_value').text(selectedCombination['available_date']['date_formatted']);
|
||||
$(this).fadeIn();
|
||||
});
|
||||
}
|
||||
else if(now.getTime() < time_available.getTime())
|
||||
$('#availability_date').fadeIn();
|
||||
}
|
||||
else
|
||||
$('#availability_date').fadeOut();
|
||||
|
||||
//show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible
|
||||
if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder == 1)
|
||||
{
|
||||
$('#add_to_cart:hidden').fadeIn(600);
|
||||
|
||||
if (availableLaterValue != '')
|
||||
{
|
||||
$('#availability_value').text(availableLaterValue);
|
||||
if(stock_management == 1)
|
||||
$('#availability_statut:hidden').show('slow');
|
||||
}
|
||||
else
|
||||
$('#availability_statut:visible').hide('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#add_to_cart:visible').fadeOut(600);
|
||||
if(stock_management == 1)
|
||||
$('#availability_statut:hidden').show('slow');
|
||||
}
|
||||
|
||||
if (productAvailableForOrder == 0)
|
||||
$('#availability_statut:visible').hide();
|
||||
}
|
||||
|
||||
if (selectedCombination['reference'] || productReference)
|
||||
{
|
||||
if (selectedCombination['reference'])
|
||||
$('#product_reference span').text(selectedCombination['reference']);
|
||||
else if (productReference)
|
||||
$('#product_reference span').text(productReference);
|
||||
$('#product_reference:hidden').show('slow');
|
||||
}
|
||||
else
|
||||
$('#product_reference:visible').hide('slow');
|
||||
|
||||
//update display of the the prices in relation to tax, discount, ecotax, and currency criteria
|
||||
if (!selectedCombination['unavailable'] && productShowPrice == 1)
|
||||
{
|
||||
var priceTaxExclWithoutGroupReduction = '';
|
||||
|
||||
// retrieve price without group_reduction in order to compute the group reduction after
|
||||
// the specific price discount (done in the JS in order to keep backward compatibility)
|
||||
priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);
|
||||
|
||||
var tax = (taxRate / 100) + 1;
|
||||
var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);
|
||||
|
||||
if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute'])
|
||||
{
|
||||
if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0)
|
||||
var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate);
|
||||
else
|
||||
var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate);
|
||||
}
|
||||
else if (product_specific_price.price && product_specific_price.price >= 0)
|
||||
var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate);
|
||||
|
||||
if (!displayPrice && !noTaxForThisProduct)
|
||||
productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var
|
||||
else
|
||||
productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var
|
||||
|
||||
productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction;
|
||||
var reduction = 0;
|
||||
if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
|
||||
{
|
||||
reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate);
|
||||
reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price;
|
||||
if (reduction_price && (displayPrice || noTaxForThisProduct))
|
||||
reduction = ps_round(reduction / tax, 6);
|
||||
|
||||
}
|
||||
else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
|
||||
{
|
||||
if (product_specific_price.reduction_type == 'amount')
|
||||
reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
|
||||
else
|
||||
reduction_price = 0;
|
||||
|
||||
if (product_specific_price.reduction_type == 'percentage')
|
||||
reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction);
|
||||
|
||||
reduction = reduction_price + reduction_percent;
|
||||
if (reduction_price && (displayPrice || noTaxForThisProduct))
|
||||
reduction = ps_round(reduction / tax, 6);
|
||||
}
|
||||
|
||||
if (selectedCombination.specific_price)
|
||||
{
|
||||
if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage')
|
||||
{
|
||||
$('#reduction_amount').hide();
|
||||
$('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');
|
||||
$('#reduction_percent').show();
|
||||
} else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) {
|
||||
$('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank));
|
||||
$('#reduction_percent').hide();
|
||||
$('#reduction_amount').show();
|
||||
} else {
|
||||
$('#reduction_percent').hide();
|
||||
$('#reduction_amount').hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
|
||||
$('#discount_reduced_price,#old_price').show();
|
||||
else
|
||||
$('#discount_reduced_price,#old_price').hide();
|
||||
if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage')
|
||||
$('#reduction_percent').show();
|
||||
else
|
||||
$('#reduction_percent').hide();
|
||||
if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price']))
|
||||
$('#not_impacted_by_discount').show();
|
||||
else
|
||||
$('#not_impacted_by_discount').hide();
|
||||
|
||||
productPriceDisplay -= reduction;
|
||||
productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);
|
||||
|
||||
var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
|
||||
productPriceDisplay += ecotaxAmount;
|
||||
productPriceWithoutReductionDisplay += ecotaxAmount;
|
||||
|
||||
var our_price = '';
|
||||
if (productPriceDisplay > 0) {
|
||||
our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank);
|
||||
} else {
|
||||
our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank);
|
||||
}
|
||||
$('#our_price_display').text(our_price);
|
||||
$('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank));
|
||||
|
||||
if (productPriceWithoutReductionDisplay > productPriceDisplay)
|
||||
$('#old_price,#old_price_display,#old_price_display_taxes').show();
|
||||
else
|
||||
$('#old_price,#old_price_display,#old_price_display_taxes').hide();
|
||||
// Special feature: "Display product price tax excluded on product page"
|
||||
var productPricePretaxed = '';
|
||||
if (!noTaxForThisProduct)
|
||||
productPricePretaxed = productPriceDisplay / tax;
|
||||
else
|
||||
productPricePretaxed = productPriceDisplay;
|
||||
$('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, currencyFormat, currencySign, currencyBlank));
|
||||
// Unit price
|
||||
productUnitPriceRatio = parseFloat(productUnitPriceRatio);
|
||||
if (productUnitPriceRatio > 0 )
|
||||
{
|
||||
newUnitPrice = (productPriceDisplay / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
|
||||
$('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
|
||||
// Ecotax
|
||||
ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
|
||||
$('#ecotax_price_display').text(formatCurrency(ecotaxAmount, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
}
|
||||
|
||||
//update display of the large image
|
||||
function displayImage(domAAroundImgThumb, no_animation)
|
||||
{
|
||||
if (typeof(no_animation) == 'undefined')
|
||||
no_animation = false;
|
||||
if (domAAroundImgThumb.attr('href'))
|
||||
{
|
||||
var newSrc = domAAroundImgThumb.attr('href').replace('thickbox', 'large');
|
||||
if ($('#bigpic').attr('src') != newSrc)
|
||||
{
|
||||
$('#bigpic').attr('src', newSrc).load(function() {
|
||||
if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
|
||||
$(this).attr('rel', domAAroundImgThumb.attr('href'));
|
||||
});
|
||||
}
|
||||
$('#views_block li a').removeClass('shown');
|
||||
$(domAAroundImgThumb).addClass('shown');
|
||||
}
|
||||
}
|
||||
|
||||
//update display of the discounts table
|
||||
function displayDiscounts(combination)
|
||||
{
|
||||
$('#quantityDiscount tbody tr').each(function() {
|
||||
if (($(this).attr('id') != 'quantityDiscount_0') &&
|
||||
($(this).attr('id') != 'quantityDiscount_' + combination) &&
|
||||
($(this).attr('id') != 'noQuantityDiscount'))
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
|
||||
if ($('#quantityDiscount_' + combination+',.quantityDiscount_' + combination).length != 0)
|
||||
{
|
||||
$('#quantityDiscount_' + combination+',.quantityDiscount_' + combination).show();
|
||||
$('#noQuantityDiscount').hide();
|
||||
}
|
||||
else
|
||||
$('#noQuantityDiscount').show();
|
||||
}
|
||||
|
||||
// Serialscroll exclude option bug ?
|
||||
function serialScrollFixLock(event, targeted, scrolled, items, position)
|
||||
{
|
||||
serialScrollNbImages = $('#thumbs_list li:visible').length;
|
||||
serialScrollNbImagesDisplayed = 3;
|
||||
|
||||
var leftArrow = position == 0 ? true : false;
|
||||
var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false;
|
||||
|
||||
$('#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
|
||||
$('#view_scroll_right').css('cursor', rightArrow ? 'default' : 'pointer').fadeTo(0, rightArrow ? 0 : 1).css('display', rightArrow ? 'none' : 'block');
|
||||
return true;
|
||||
}
|
||||
|
||||
// Change the current product images regarding the combination selected
|
||||
function refreshProductImages(id_product_attribute)
|
||||
{
|
||||
$('#thumbs_list_frame').scrollTo('li:eq(0)', 700, {axis:'x'});
|
||||
|
||||
id_product_attribute = parseInt(id_product_attribute);
|
||||
|
||||
if (id_product_attribute > 0 && typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
|
||||
{
|
||||
$('#thumbs_list li').hide();
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
|
||||
$('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show();
|
||||
if (parseInt($('#thumbs_list_frame >li:visible').length) < parseInt($('#thumbs_list_frame >li').length))
|
||||
$('#wrapResetImages').show('slow');
|
||||
else
|
||||
$('#wrapResetImages').hide('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#thumbs_list li').show();
|
||||
if (parseInt($('#thumbs_list_frame >li').length) == parseInt($('#thumbs_list_frame >li:visible').length))
|
||||
$('#wrapResetImages').hide('slow');
|
||||
}
|
||||
|
||||
var thumb_width = $('#thumbs_list_frame >li').width() + parseInt($('#thumbs_list_frame >li').css('marginRight')) + 1;
|
||||
|
||||
$('#thumbs_list_frame').width((parseInt((thumb_width) * $('#thumbs_list_frame >li').length)) + 'px');
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
serialScrollFixLock('', '', '', '', 0);// SerialScroll Bug on goto 0 ?
|
||||
}
|
||||
|
||||
//To do after loading HTML
|
||||
$(document).ready(function()
|
||||
{
|
||||
//init the serialScroll for thumbs
|
||||
$('#thumbs_list').serialScroll({
|
||||
items:'li:visible',
|
||||
prev:'#view_scroll_left',
|
||||
next:'#view_scroll_right',
|
||||
axis:'x',
|
||||
offset:0,
|
||||
start:0,
|
||||
stop:true,
|
||||
onBefore:serialScrollFixLock,
|
||||
duration:700,
|
||||
step: 2,
|
||||
lazy: true,
|
||||
lock: false,
|
||||
force:false,
|
||||
cycle:false
|
||||
});
|
||||
|
||||
$('#thumbs_list').trigger('goto', 1);// SerialScroll Bug on goto 0 ?
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
|
||||
//hover 'other views' images management
|
||||
$('#views_block li a').hover(
|
||||
function(){displayImage($(this));},
|
||||
function(){}
|
||||
);
|
||||
|
||||
//set jqZoom parameters if needed
|
||||
if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
|
||||
{
|
||||
$('#bigpic').attr('rel', $('#bigpic').attr('src').replace('large', 'thickbox'));
|
||||
$('img.jqzoom').jqueryzoom({
|
||||
xzoom: 200, //zooming div default width(default width value is 200)
|
||||
yzoom: 200, //zooming div default width(default height value is 200)
|
||||
offset: 21 //zooming div default offset(default offset value is 10)
|
||||
//position: "right" //zooming div position(default position value is "right")
|
||||
});
|
||||
}
|
||||
//add a link on the span 'view full size' and on the big image
|
||||
$('#view_full_size, #image-block img').click(function(){
|
||||
$('#views_block .shown').click();
|
||||
});
|
||||
|
||||
//catch the click on the "more infos" button at the top of the page
|
||||
$('#short_description_block .button').click(function(){
|
||||
$('#more_info_tab_more_info').click();
|
||||
$.scrollTo( '#more_info_tabs', 1200 );
|
||||
});
|
||||
|
||||
// Hide the customization submit button and display some message
|
||||
$('#customizedDatas input').click(function() {
|
||||
$('#customizedDatas input').hide();
|
||||
$('#ajax-loader').fadeIn();
|
||||
$('#customizedDatas').append(uploading_in_progress);
|
||||
});
|
||||
|
||||
original_url = window.location + '';
|
||||
first_url_check = true;
|
||||
checkUrl();
|
||||
initLocationChange();
|
||||
|
||||
//init the price in relation of the selected attributes
|
||||
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
|
||||
findCombination(true);
|
||||
else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
|
||||
refreshProductImages(0);
|
||||
|
||||
$('#resetImages').click(function() {
|
||||
refreshProductImages(0);
|
||||
});
|
||||
|
||||
$('.thickbox').fancybox({
|
||||
'hideOnContentClick': true,
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic'
|
||||
});
|
||||
});
|
||||
|
||||
function saveCustomization()
|
||||
{
|
||||
$('#quantityBackup').val($('#quantity_wanted').val());
|
||||
customAction = $('#customizationForm').attr('action');
|
||||
$('body select[id^="group_"]').each(function() {
|
||||
customAction = customAction.replace(new RegExp(this.id + '=\\d+'), this.id +'=' + this.value);
|
||||
});
|
||||
$('#customizationForm').attr('action', customAction);
|
||||
$('#customizationForm').submit();
|
||||
}
|
||||
|
||||
function submitPublishProduct(url, redirect, token)
|
||||
{
|
||||
var id_product = $('#admin-action-product-id').val();
|
||||
|
||||
$.ajaxSetup({async: false});
|
||||
$.post(url + '/index.php', {
|
||||
action:'publishProduct',
|
||||
id_product: id_product,
|
||||
status: 1,
|
||||
redirect: redirect,
|
||||
ajax: 1,
|
||||
tab: 'AdminProducts',
|
||||
token: token
|
||||
},
|
||||
function(data)
|
||||
{
|
||||
if (data.indexOf('error') === -1)
|
||||
document.location.href = data;
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkMinimalQuantity(minimal_quantity)
|
||||
{
|
||||
if ($('#quantity_wanted').val() < minimal_quantity)
|
||||
{
|
||||
$('#quantity_wanted').css('border', '1px solid red');
|
||||
$('#minimal_quantity_wanted_p').css('color', 'red');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#quantity_wanted').css('border', '1px solid #BDC2C9');
|
||||
$('#minimal_quantity_wanted_p').css('color', '#374853');
|
||||
}
|
||||
}
|
||||
|
||||
function colorPickerClick(elt)
|
||||
{
|
||||
id_attribute = $(elt).attr('id').replace('color_', '');
|
||||
$(elt).parent().parent().children().removeClass('selected');
|
||||
$(elt).fadeTo('fast', 1, function(){
|
||||
$(this).fadeTo('fast', 0, function(){
|
||||
$(this).fadeTo('fast', 1, function(){
|
||||
$(this).parent().addClass('selected');
|
||||
});
|
||||
});
|
||||
});
|
||||
$(elt).parent().parent().parent().children('.color_pick_hidden,#color_pick_hidden').val(id_attribute);
|
||||
findCombination(false);
|
||||
}
|
||||
|
||||
|
||||
function getProductAttribute()
|
||||
{
|
||||
// get product attribute id
|
||||
product_attribute_id = $('#idCombination').val();
|
||||
product_id = $('#product_page_product_id').val();
|
||||
|
||||
// get every attributes values
|
||||
request = '';
|
||||
//create a temporary 'tab_attributes' array containing the choices of the customer
|
||||
var tab_attributes = [];
|
||||
$('#attributes select, #attributes input[type=hidden], #attributes input[type=radio]:checked').each(function(){
|
||||
tab_attributes.push($(this).val());
|
||||
});
|
||||
|
||||
// build new request
|
||||
for (var i in attributesCombinations)
|
||||
for (var a in tab_attributes)
|
||||
if (attributesCombinations[i]['id_attribute'] === tab_attributes[a])
|
||||
request += '/'+attributesCombinations[i]['group'] + attribute_anchor_separator + attributesCombinations[i]['attribute'];
|
||||
request = request.replace(request.substring(0, 1), '#/');
|
||||
url = window.location + '';
|
||||
|
||||
// redirection
|
||||
if (url.indexOf('#') != -1)
|
||||
url = url.substring(0, url.indexOf('#'));
|
||||
|
||||
// set ipa to the customization form
|
||||
$('#customizationForm').attr('action', $('#customizationForm').attr('action') + request);
|
||||
window.location = url + request;
|
||||
}
|
||||
|
||||
function initLocationChange(time)
|
||||
{
|
||||
if(!time) time = 500;
|
||||
setInterval(checkUrl, time);
|
||||
}
|
||||
|
||||
function checkUrl()
|
||||
{
|
||||
if (original_url != window.location || first_url_check)
|
||||
{
|
||||
first_url_check = false;
|
||||
url = window.location + '';
|
||||
// if we need to load a specific combination
|
||||
if (url.indexOf('#/') != -1)
|
||||
{
|
||||
// get the params to fill from a "normal" url
|
||||
params = url.substring(url.indexOf('#') + 1, url.length);
|
||||
tabParams = params.split('/');
|
||||
tabValues = [];
|
||||
if (tabParams[0] == '')
|
||||
tabParams.shift();
|
||||
for (var i in tabParams)
|
||||
tabValues.push(tabParams[i].split(attribute_anchor_separator));
|
||||
product_id = $('#product_page_product_id').val();
|
||||
// fill html with values
|
||||
$('.color_pick').removeClass('selected');
|
||||
$('.color_pick').parent().parent().children().removeClass('selected');
|
||||
count = 0;
|
||||
for (var z in tabValues)
|
||||
for (var a in attributesCombinations)
|
||||
if (attributesCombinations[a]['group'] === decodeURIComponent(tabValues[z][0])
|
||||
&& attributesCombinations[a]['attribute'] === tabValues[z][1])
|
||||
{
|
||||
count++;
|
||||
// add class 'selected' to the selected color
|
||||
$('#color_' + attributesCombinations[a]['id_attribute']).addClass('selected');
|
||||
$('#color_' + attributesCombinations[a]['id_attribute']).parent().addClass('selected');
|
||||
$('input:radio[value=' + attributesCombinations[a]['id_attribute'] + ']').attr('checked', true);
|
||||
$('input:hidden[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
|
||||
$('select[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
|
||||
}
|
||||
// find combination
|
||||
if (count >= 0)
|
||||
{
|
||||
findCombination(false);
|
||||
original_url = url;
|
||||
}
|
||||
// no combination found = removing attributes from url
|
||||
else
|
||||
window.location = url.substring(0, url.indexOf('#'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$('document').ready(function(){
|
||||
reloadProductComparison();
|
||||
});
|
||||
|
||||
reloadProductComparison = function() {
|
||||
$('a.cmp_remove').click(function(){
|
||||
|
||||
var idProduct = $(this).attr('rel').replace('ajax_id_product_', '');
|
||||
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||
async: false,
|
||||
cache: false,
|
||||
success: function(){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('input:checkbox.comparator').click(function(){
|
||||
|
||||
var idProduct = $(this).attr('value').replace('comparator_item_', '');
|
||||
var checkbox = $(this);
|
||||
|
||||
if(checkbox.is(':checked'))
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=add&id_product=' + idProduct,
|
||||
async: true,
|
||||
cache: false,
|
||||
success: function(data){
|
||||
if (data === '0')
|
||||
{
|
||||
checkbox.attr('checked', false);
|
||||
alert(max_item);
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
checkbox.attr('checked', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||
async: true,
|
||||
cache: false,
|
||||
success: function(data){
|
||||
if (data === '0')
|
||||
checkbox.attr('checked', true);
|
||||
},
|
||||
error: function(){
|
||||
checkbox.attr('checked', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.quick-view').hover(function() {
|
||||
$.fancybox({
|
||||
'type': 'iframe',
|
||||
'href': this.href+'&content_only=1'
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
nb_move_available = null;
|
||||
current_move = 0;
|
||||
next_scene_is_at_right = true;
|
||||
|
||||
function loadScene(id_scene){
|
||||
$('#scenes').find('.screen_scene:visible').fadeTo(300, 0, function(){
|
||||
$(this).hide();
|
||||
$('#scenes').find('#screen_scene_' + id_scene).css('opacity', '0').show().fadeTo(500, 1);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSceneMove(){
|
||||
if (next_scene_is_at_right) current_move++;
|
||||
else current_move--;
|
||||
if (current_move === nb_move_available - 1) $('#scenes .next').fadeOut();
|
||||
else $('#scenes .next:hidden').fadeIn().css('display','block');
|
||||
if (current_move === 0) $('#scenes .prev').fadeOut().css('display','block');
|
||||
else $('#scenes .prev').fadeIn().css('display','block');
|
||||
return true;
|
||||
}
|
||||
|
||||
$(function () {
|
||||
/* calcul nb of click to see every scenes */
|
||||
var ul_width = parseInt($('#scenes_list ul').width());
|
||||
var div_width = parseInt($('#scenes_list').width());
|
||||
nb_move_available = Math.ceil((ul_width-div_width)/li_width)+1;
|
||||
if (nb_move_available < 2)
|
||||
$('#scenes .next').hide();
|
||||
|
||||
/* set cluetip parameters */
|
||||
$('a.cluetip')
|
||||
.cluetip({
|
||||
local:true,
|
||||
cursor: 'pointer',
|
||||
attribute:'accesskey',
|
||||
cluetipClass: 'product_scene',
|
||||
dropShadow: false,
|
||||
dropShadowSteps: 0,
|
||||
showTitle: false,
|
||||
tracking: true,
|
||||
sticky: false,
|
||||
mouseOutClose: true,
|
||||
closeText: i18n_scene_close,
|
||||
fx: {
|
||||
open: 'fadeIn',
|
||||
openSpeed: 'fast'
|
||||
}
|
||||
})
|
||||
.css('opacity', 0.8);
|
||||
|
||||
/* set serialscroll parameters */
|
||||
$('#scenes_list').serialScroll({
|
||||
items:'a',
|
||||
duration:1000,
|
||||
lock:false,
|
||||
axis:'x',
|
||||
cycle:false,
|
||||
force:true,
|
||||
lazy:true,
|
||||
step:1,
|
||||
onBefore:onSceneMove
|
||||
});
|
||||
$('#scenes_list').trigger( 'goto', 0);
|
||||
|
||||
});
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function initMarkers()
|
||||
{
|
||||
searchUrl += '?ajax=1&all=1';
|
||||
downloadUrl(searchUrl, function(data) {
|
||||
var xml = parseXml(data);
|
||||
var markerNodes = xml.documentElement.getElementsByTagName('marker');
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
for (var i = 0; i < markerNodes.length; i++)
|
||||
{
|
||||
var name = markerNodes[i].getAttribute('name');
|
||||
var address = markerNodes[i].getAttribute('address');
|
||||
var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
|
||||
var other = markerNodes[i].getAttribute('other');
|
||||
var id_store = markerNodes[i].getAttribute('id_store');
|
||||
var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
|
||||
var latlng = new google.maps.LatLng(
|
||||
parseFloat(markerNodes[i].getAttribute('lat')),
|
||||
parseFloat(markerNodes[i].getAttribute('lng')));
|
||||
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
||||
bounds.extend(latlng);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchLocations()
|
||||
{
|
||||
$('#stores_loader').show();
|
||||
var address = document.getElementById('addressInput').value;
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
geocoder.geocode({address: address}, function(results, status) {
|
||||
if (status === google.maps.GeocoderStatus.OK)
|
||||
searchLocationsNear(results[0].geometry.location);
|
||||
else
|
||||
alert(address+' '+translation_6);
|
||||
$('#stores_loader').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function clearLocations(n)
|
||||
{
|
||||
infoWindow.close();
|
||||
for (var i = 0; i < markers.length; i++)
|
||||
markers[i].setMap(null);
|
||||
|
||||
markers.length = 0;
|
||||
|
||||
locationSelect.innerHTML = '';
|
||||
var option = document.createElement('option');
|
||||
option.value = 'none';
|
||||
if (!n)
|
||||
option.innerHTML = translation_1;
|
||||
else
|
||||
{
|
||||
if (n === 1)
|
||||
option.innerHTML = '1'+' '+translation_2;
|
||||
else
|
||||
option.innerHTML = n+' '+translation_3;
|
||||
}
|
||||
locationSelect.appendChild(option);
|
||||
$('#stores-table tr.node').remove();
|
||||
}
|
||||
|
||||
function searchLocationsNear(center)
|
||||
{
|
||||
var radius = document.getElementById('radiusSelect').value;
|
||||
var searchUrl = baseUri+'?controller=stores&ajax=1&latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;
|
||||
downloadUrl(searchUrl, function(data) {
|
||||
var xml = parseXml(data);
|
||||
var markerNodes = xml.documentElement.getElementsByTagName('marker');
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
|
||||
clearLocations(markerNodes.length);
|
||||
for (var i = 0; i < markerNodes.length; i++)
|
||||
{
|
||||
var name = markerNodes[i].getAttribute('name');
|
||||
var address = markerNodes[i].getAttribute('address');
|
||||
var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
|
||||
var other = markerNodes[i].getAttribute('other');
|
||||
var distance = parseFloat(markerNodes[i].getAttribute('distance'));
|
||||
var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
|
||||
var phone = markerNodes[i].getAttribute('phone');
|
||||
var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
|
||||
var latlng = new google.maps.LatLng(
|
||||
parseFloat(markerNodes[i].getAttribute('lat')),
|
||||
parseFloat(markerNodes[i].getAttribute('lng')));
|
||||
|
||||
createOption(name, distance, i);
|
||||
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
||||
bounds.extend(latlng);
|
||||
|
||||
$('table#stores-table').find('tbody').append('<tr ><td class="num">'+parseInt(i + 1)+'</td><td class="name">'+(has_store_picture == 1 ? '<img src="'+img_store_dir+parseInt(id_store)+'-stores_default.jpg" alt="" />' : '')+'<span>'+name+'</span></td><td class="address">'+address+(phone !== '' ? ''+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
|
||||
$('#stores-table').show();
|
||||
}
|
||||
|
||||
if (markerNodes.length)
|
||||
{
|
||||
map.fitBounds(bounds);
|
||||
var listener = google.maps.event.addListener(map, "idle", function() {
|
||||
if (map.getZoom() > 13) map.setZoom(13);
|
||||
google.maps.event.removeListener(listener);
|
||||
});
|
||||
}
|
||||
locationSelect.style.visibility = 'visible';
|
||||
$(locationSelect).parent().parent().addClass('active').show();
|
||||
locationSelect.onchange = function() {
|
||||
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
|
||||
google.maps.event.trigger(markers[markerNum], 'click');
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createMarker(latlng, name, address, other, id_store, has_store_picture)
|
||||
{
|
||||
var html = '<b>'+name+'</b><br/>'+address+(has_store_picture === 1 ? '<br /><br /><img src="'+img_store_dir+parseInt(id_store)+'-medium_default.jpg" alt="" />' : '')+other+'<br /><a href="http://maps.google.com/maps?saddr=&daddr='+latlng+'" target="_blank">'+translation_5+'<\/a>';
|
||||
var image = new google.maps.MarkerImage(img_ps_dir+logo_store);
|
||||
var marker = '';
|
||||
|
||||
if (hasStoreIcon)
|
||||
marker = new google.maps.Marker({ map: map, icon: image, position: latlng });
|
||||
else
|
||||
marker = new google.maps.Marker({ map: map, position: latlng });
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
infoWindow.setContent(html);
|
||||
infoWindow.open(map, marker);
|
||||
});
|
||||
markers.push(marker);
|
||||
}
|
||||
|
||||
function createOption(name, distance, num)
|
||||
{
|
||||
var option = document.createElement('option');
|
||||
option.value = num;
|
||||
option.innerHTML = name+' ('+distance.toFixed(1)+' '+distance_unit+')';
|
||||
locationSelect.appendChild(option);
|
||||
}
|
||||
|
||||
function downloadUrl(url, callback)
|
||||
{
|
||||
var request = window.ActiveXObject ?
|
||||
new ActiveXObject('Microsoft.XMLHTTP') :
|
||||
new XMLHttpRequest();
|
||||
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState === 4) {
|
||||
request.onreadystatechange = doNothing;
|
||||
callback(request.responseText, request.status);
|
||||
}
|
||||
};
|
||||
|
||||
request.open('GET', url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function parseXml(str)
|
||||
{
|
||||
if (window.ActiveXObject) {
|
||||
var doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||
doc.loadXML(str);
|
||||
return doc;
|
||||
}
|
||||
else if (window.DOMParser) {
|
||||
return (new DOMParser()).parseFromString(str, 'text/xml');
|
||||
}
|
||||
}
|
||||
|
||||
function doNothing() {}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
map = new google.maps.Map(document.getElementById('map'), {
|
||||
center: new google.maps.LatLng(defaultLat, defaultLong),
|
||||
zoom: 10,
|
||||
mapTypeId: 'roadmap',
|
||||
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
|
||||
});
|
||||
infoWindow = new google.maps.InfoWindow();
|
||||
|
||||
locationSelect = document.getElementById('locationSelect');
|
||||
locationSelect.onchange = function() {
|
||||
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
|
||||
if (markerNum !== 'none')
|
||||
google.maps.event.trigger(markers[markerNum], 'click');
|
||||
};
|
||||
|
||||
$('#addressInput').keypress(function(e) {
|
||||
code = e.keyCode ? e.keyCode : e.which;
|
||||
if(code.toString() === 13)
|
||||
searchLocations();
|
||||
});
|
||||
|
||||
|
||||
initMarkers();
|
||||
});
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function ps_round(value, precision)
|
||||
{
|
||||
if (typeof(roundMode) === 'undefined')
|
||||
roundMode = 2;
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 2;
|
||||
|
||||
method = roundMode;
|
||||
if (method === 0)
|
||||
return ceilf(value, precision);
|
||||
else if (method === 1)
|
||||
return floorf(value, precision);
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
return Math.round(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function ceilf(value, precision)
|
||||
{
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 0;
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
tmp = value * precisionFactor;
|
||||
tmp2 = tmp.toString();
|
||||
if (tmp2[tmp2.length - 1] === 0)
|
||||
return value;
|
||||
return Math.ceil(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function floorf(value, precision)
|
||||
{
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 0;
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
tmp = value * precisionFactor;
|
||||
tmp2 = tmp.toString();
|
||||
if (tmp2[tmp2.length - 1] === 0)
|
||||
return value;
|
||||
return Math.floor(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function formatedNumberToFloat(price, currencyFormat, currencySign)
|
||||
{
|
||||
price = price.replace(currencySign, '');
|
||||
if (currencyFormat === 1)
|
||||
return parseFloat(price.replace(',', '').replace(' ', ''));
|
||||
else if (currencyFormat === 2)
|
||||
return parseFloat(price.replace(' ', '').replace(',', '.'));
|
||||
else if (currencyFormat === 3)
|
||||
return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
|
||||
else if (currencyFormat === 4)
|
||||
return parseFloat(price.replace(',', '').replace(' ', ''));
|
||||
return price;
|
||||
}
|
||||
|
||||
//return a formatted price
|
||||
function formatCurrency(price, currencyFormat, currencySign, currencyBlank)
|
||||
{
|
||||
// if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)
|
||||
blank = '';
|
||||
price = parseFloat(price.toFixed(6));
|
||||
price = ps_round(price, priceDisplayPrecision);
|
||||
if (currencyBlank > 0)
|
||||
blank = ' ';
|
||||
if (currencyFormat == 1)
|
||||
return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
|
||||
if (currencyFormat == 2)
|
||||
return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
|
||||
if (currencyFormat == 3)
|
||||
return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
|
||||
if (currencyFormat == 4)
|
||||
return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
|
||||
if (currencyFormat == 5)
|
||||
return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign);
|
||||
return price;
|
||||
}
|
||||
|
||||
//return a formatted number
|
||||
function formatNumber(value, numberOfDecimal, thousenSeparator, virgule)
|
||||
{
|
||||
value = value.toFixed(numberOfDecimal);
|
||||
var val_string = value+'';
|
||||
var tmp = val_string.split('.');
|
||||
var abs_val_string = (tmp.length === 2) ? tmp[0] : val_string;
|
||||
var deci_string = ('0.' + (tmp.length === 2 ? tmp[1] : 0)).substr(2);
|
||||
var nb = abs_val_string.length;
|
||||
|
||||
for (var i = 1 ; i < 4; i++)
|
||||
if (value >= Math.pow(10, (3 * i)))
|
||||
abs_val_string = abs_val_string.substring(0, nb - (3 * i)) + thousenSeparator + abs_val_string.substring(nb - (3 * i));
|
||||
|
||||
if (parseInt(numberOfDecimal) === 0)
|
||||
return abs_val_string;
|
||||
return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
|
||||
}
|
||||
|
||||
//change the text of a jQuery element with a sliding effect (velocity could be a number in ms, 'slow' or 'fast', effect1 and effect2 could be slide, fade, hide, show)
|
||||
function updateTextWithEffect(jQueryElement, text, velocity, effect1, effect2, newClass)
|
||||
{
|
||||
if(jQueryElement.text() !== text)
|
||||
if(effect1 === 'fade')
|
||||
jQueryElement.fadeOut(velocity, function(){
|
||||
$(this).addClass(newClass);
|
||||
if(effect2 === 'fade') $(this).text(text).fadeIn(velocity);
|
||||
else if(effect2 === 'slide') $(this).text(text).slideDown(velocity);
|
||||
else if(effect2 === 'show') $(this).text(text).show(velocity, function(){});
|
||||
});
|
||||
else if(effect1 === 'slide')
|
||||
jQueryElement.slideUp(velocity, function(){
|
||||
$(this).addClass(newClass);
|
||||
if(effect2 === 'fade') $(this).text(text).fadeIn(velocity);
|
||||
else if(effect2 === 'slide') $(this).text(text).slideDown(velocity);
|
||||
else if(effect2 === 'show') $(this).text(text).show(velocity);
|
||||
});
|
||||
else if(effect1 === 'hide')
|
||||
jQueryElement.hide(velocity, function(){
|
||||
$(this).addClass(newClass);
|
||||
if(effect2 === 'fade') $(this).text(text).fadeIn(velocity);
|
||||
else if(effect2 === 'slide') $(this).text(text).slideDown(velocity);
|
||||
else if(effect2 === 'show') $(this).text(text).show(velocity);
|
||||
});
|
||||
}
|
||||
|
||||
//show a JS debug
|
||||
function dbg(value)
|
||||
{
|
||||
var active = false;//true for active
|
||||
var firefox = true;//true if debug under firefox
|
||||
|
||||
if (active)
|
||||
if (firefox)
|
||||
console.log(value);
|
||||
else
|
||||
alert(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function : print_r()
|
||||
* Arguments: The data - array,hash(associative array),object
|
||||
* The level - OPTIONAL
|
||||
* Returns : The textual representation of the array.
|
||||
* This function was inspired by the print_r function of PHP.
|
||||
* This will accept some data as the argument and return a
|
||||
* text that will be a more readable version of the
|
||||
* array/hash/object that is given.
|
||||
*/
|
||||
function print_r(arr, level)
|
||||
{
|
||||
var dumped_text = "";
|
||||
if (!level)
|
||||
level = 0;
|
||||
|
||||
//The padding given at the beginning of the line.
|
||||
var level_padding = "";
|
||||
for (var j = 0 ; j < level + 1; j++)
|
||||
level_padding += " ";
|
||||
|
||||
if (typeof(arr) === 'object')
|
||||
{ //Array/Hashes/Objects
|
||||
for (var item in arr)
|
||||
{
|
||||
var value = arr[item];
|
||||
if (typeof(value) === 'object') { //If it is an array,
|
||||
dumped_text += level_padding + "'" + item + "' ...\n";
|
||||
dumped_text += dump(value,level+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //Stings/Chars/Numbers etc.
|
||||
dumped_text = "===>" + arr + "<===("+typeof(arr)+")";
|
||||
}
|
||||
return dumped_text;
|
||||
}
|
||||
|
||||
//verify if value is in the array
|
||||
function in_array(value, array)
|
||||
{
|
||||
for (var i in array)
|
||||
if (array[i] === value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$.fn.checkboxChange = function(fnChecked, fnUnchecked) {
|
||||
if ($(this).prop('checked') && fnChecked)
|
||||
fnChecked.call(this);
|
||||
else if(fnUnchecked)
|
||||
fnUnchecked.call(this);
|
||||
|
||||
if (!$(this).attr('eventCheckboxChange'))
|
||||
{
|
||||
$(this).live('change', function() { $(this).checkboxChange(fnChecked, fnUnchecked); });
|
||||
$(this).attr('eventCheckboxChange', true);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// Use it to simulate target blank link
|
||||
$(function(){
|
||||
$('a.js-new-window').click(function(){
|
||||
window.open(this.href);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* TotalStorage
|
||||
*
|
||||
* Copyright (c) 2012 Jared Novack & Upstatement (upstatement.com)
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Total Storage is the conceptual the love child of jStorage by Andris Reinman,
|
||||
* and Cookie by Klaus Hartl -- though this is not connected to either project.
|
||||
*
|
||||
* @name $.totalStorage
|
||||
* @cat Plugins/Cookie
|
||||
* @author Jared Novack/jared@upstatement.com
|
||||
* @version 1.1.2
|
||||
* @url http://upstatement.com/blog/2012/01/jquery-local-storage-done-right-and-easy/
|
||||
*/
|
||||
(function($){var ls=window.localStorage;var supported;if(typeof ls=='undefined'||typeof window.JSON=='undefined'){supported=false;}else{supported=true;}
|
||||
$.totalStorage=function(key,value,options){return $.totalStorage.impl.init(key,value);}
|
||||
$.totalStorage.setItem=function(key,value){return $.totalStorage.impl.setItem(key,value);}
|
||||
$.totalStorage.getItem=function(key){return $.totalStorage.impl.getItem(key);}
|
||||
$.totalStorage.getAll=function(){return $.totalStorage.impl.getAll();}
|
||||
$.totalStorage.deleteItem=function(key){return $.totalStorage.impl.deleteItem(key);}
|
||||
$.totalStorage.impl={init:function(key,value){if(typeof value!='undefined'){return this.setItem(key,value);}else{return this.getItem(key);}},setItem:function(key,value){if(!supported){try{$.cookie(key,value);return value;}catch(e){console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');}}
|
||||
var saver=JSON.stringify(value);ls.setItem(key,saver);return this.parseResult(saver);},getItem:function(key){if(!supported){try{return this.parseResult($.cookie(key));}catch(e){return null;}}
|
||||
return this.parseResult(ls.getItem(key));},deleteItem:function(key){if(!supported){try{$.cookie(key,null);return true;}catch(e){return false;}}
|
||||
ls.removeItem(key);return true;},getAll:function(){var items=new Array();if(!supported){try{var pairs=document.cookie.split(";");for(var i=0;i<pairs.length;i++){var pair=pairs[i].split('=');var key=pair[0];items.push({key:key,value:this.parseResult($.cookie(key))});}}catch(e){return null;}}else{for(var i in ls){if(i.length){items.push({key:i,value:this.parseResult(ls.getItem(i))});}}}
|
||||
return items;},parseResult:function(res){var ret;try{ret=JSON.parse(res);if(ret=='true'){ret=true;}
|
||||
if(ret=='false'){ret=false;}
|
||||
if(parseFloat(ret)==ret&&typeof ret!="object"){ret=parseFloat(ret);}}catch(e){}
|
||||
return ret;}}})(jQuery);
|
||||
@@ -0,0 +1,63 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
bindStateInputAndUpdate();
|
||||
});
|
||||
|
||||
function bindStateInputAndUpdate()
|
||||
{
|
||||
$('.id_state, .dni, .postcode').css({'display':'none'});
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
|
||||
$('select#id_country').change(function(){
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
|
||||
if ($('select#id_country_invoice').length !== 0)
|
||||
{
|
||||
$('select#id_country_invoice').change(function(){
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
});
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
}
|
||||
}
|
||||
|
||||
function updateState(suffix)
|
||||
{
|
||||
$('select#id_state'+(suffix !== undefined ? '_'+suffix : '')+' option:not(:first-child)').remove();
|
||||
var states = countries[$('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val()];
|
||||
if(typeof(states) !== 'undefined')
|
||||
{
|
||||
$(states).each(function (key, item){
|
||||
$('select#id_state'+(suffix !== undefined ? '_'+suffix : '')).append('<option value="'+item.id+'"'+ (idSelectedCountry === item.id ? ' selected="selected"' : '') + '>'+item.name+'</option>');
|
||||
});
|
||||
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');;
|
||||
}
|
||||
else
|
||||
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
|
||||
function updateNeedIDNumber(suffix)
|
||||
{
|
||||
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
|
||||
if ($.inArray(idCountry, countriesNeedIDNumber) >= 0)
|
||||
$('.dni'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
|
||||
else
|
||||
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
|
||||
function updateZipCode(suffix)
|
||||
{
|
||||
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
|
||||
if (countriesNeedZipCode[idCountry] !== 0)
|
||||
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
|
||||
else
|
||||
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//animate the opening of the branch (span.grower jQueryElement)
|
||||
function openBranch(jQueryElement, noAnimation) {
|
||||
jQueryElement.addClass('OPEN').removeClass('CLOSE');
|
||||
if(noAnimation)
|
||||
jQueryElement.parent().find('ul:first').show();
|
||||
else
|
||||
jQueryElement.parent().find('ul:first').slideDown();
|
||||
}
|
||||
//animate the closing of the branch (span.grower jQueryElement)
|
||||
function closeBranch(jQueryElement, noAnimation) {
|
||||
jQueryElement.addClass('CLOSE').removeClass('OPEN');
|
||||
if(noAnimation)
|
||||
jQueryElement.parent().find('ul:first').hide();
|
||||
else
|
||||
jQueryElement.parent().find('ul:first').slideUp();
|
||||
}
|
||||
|
||||
//animate the closing or opening of the branch (ul jQueryElement)
|
||||
function toggleBranch(jQueryElement, noAnimation) {
|
||||
if(jQueryElement.hasClass('OPEN'))
|
||||
closeBranch(jQueryElement, noAnimation);
|
||||
else
|
||||
openBranch(jQueryElement, noAnimation);
|
||||
}
|
||||
|
||||
//when the page is loaded...
|
||||
$(document).ready(function () {
|
||||
//to do not execute this script as much as it's called...
|
||||
if(!$('ul.tree.dhtml').hasClass('dynamized'))
|
||||
{
|
||||
//add growers to each ul.tree elements
|
||||
$('ul.tree.dhtml ul').prev().before("<span class='grower OPEN'> </span>");
|
||||
|
||||
//dynamically add the '.last' class on each last item of a branch
|
||||
$('ul.tree.dhtml ul li:last-child, ul.tree.dhtml li:last-child').addClass('last');
|
||||
|
||||
//collapse every expanded branch
|
||||
$('ul.tree.dhtml span.grower.OPEN').addClass('CLOSE').removeClass('OPEN').parent().find('ul:first').hide();
|
||||
$('ul.tree.dhtml').show();
|
||||
|
||||
//open the tree for the selected branch
|
||||
$('ul.tree.dhtml .selected').parents().each( function() {
|
||||
if ($(this).is('ul'))
|
||||
toggleBranch($(this).prev().prev(), true);
|
||||
});
|
||||
toggleBranch( $('ul.tree.dhtml .selected').prev(), true);
|
||||
|
||||
//add a fonction on clicks on growers
|
||||
$('ul.tree.dhtml span.grower').click(function(){
|
||||
toggleBranch($(this));
|
||||
});
|
||||
//mark this 'ul.tree' elements as already 'dynamized'
|
||||
$('ul.tree.dhtml').addClass('dynamized');
|
||||
|
||||
$('ul.tree.dhtml').removeClass('dhtml');
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user