[+] FO : New Responsive, Bootstrap template
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user