[+] Project : default theme added

This commit is contained in:
mMarinetti
2011-12-02 15:24:40 +00:00
parent a2be24ee90
commit 7320307212
431 changed files with 21629 additions and 1679 deletions
+516
View File
@@ -0,0 +1,516 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6625 $
* @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 = new Array();
var selectedCombination = new Array();
var globalQuantity = new Number;
var colors = new Array();
//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)
{
globalQuantity += quantity;
var combination = new Array();
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;
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 = new Array();
$('div#attributes select').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'];
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() );
//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;
updateDisplay();
}
function updateColorSelect(id_attribute)
{
if (id_attribute == 0)
{
refreshProductImages(0);
return ;
}
// Visual effect
$('#color_'+id_attribute).fadeTo('fast', 1, function(){ $(this).fadeTo('slow', 0, function(){ $(this).fadeTo('slow', 1, function(){}); }); });
// Attribute selection
$('#group_'+id_color_default+' option[value='+id_attribute+']').attr('selected', 'selected');
$('#group_'+id_color_default+' option[value!='+id_attribute+']').removeAttr('selected');
findCombination();
}
//update display of the availability of the product AND the prices of the product
function updateDisplay()
{
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 value management
if (availableNowValue != '')
{
//update the availability statut of the product
$('#availability_value').removeClass('warning_inline');
$('#availability_value').text(availableNowValue);
$('#availability_statut:hidden').show();
}
else
{
//hide the availability value
$('#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();
}
$('#availability_statut:hidden').show();
//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);
$('p#availability_statut:hidden').show('slow');
}
else
$('p#availability_statut:visible').hide('slow');
}
else
{
$('#add_to_cart:visible').fadeOut(600);
$('p#availability_statut:hidden').show('slow');
}
if (productAvailableForOrder == 0)
$('p#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 combination_add_price = selectedCombination['price'] * group_reduction;
var tax = (taxRate / 100) + 1;
var taxExclPrice = (specific_price ? (specific_currency ? specific_price : specific_price * currencyRate) : productPriceTaxExcluded) + combination_add_price * currencyRate;
if (specific_price)
var productPriceWithoutReduction = productPriceTaxExcluded + combination_add_price * currencyRate;
if (!displayPrice && !noTaxForThisProduct)
{
var productPrice = ps_round(taxExclPrice * tax, 2);
if (specific_price)
productPriceWithoutReduction = ps_round(productPriceWithoutReduction * tax, 2);
}
else
{
var productPrice = ps_round(taxExclPrice, 2);
if (specific_price)
productPriceWithoutReduction = ps_round(productPriceWithoutReduction, 2);
}
var reduction = 0;
if (reduction_price || reduction_percent)
{
reduction = productPrice * (parseFloat(reduction_percent) / 100) + reduction_price;
if (reduction_price && (displayPrice || noTaxForThisProduct))
reduction = reduction / tax;
}
if (!specific_price)
productPriceWithoutReduction = productPrice;
productPrice -= reduction;
var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
productPrice += ecotaxAmount;
productPriceWithoutReduction += ecotaxAmount;
//productPrice = ps_round(productPrice * currencyRate, 2);
if (productPrice > 0)
$('#our_price_display').text(formatCurrency(productPrice, currencyFormat, currencySign, currencyBlank));
else
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
/* Special feature: "Display product price tax excluded on product page" */
if (!noTaxForThisProduct)
var productPricePretaxed = productPrice / tax;
else
var productPricePretaxed = productPrice;
$('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, currencyFormat, currencySign, currencyBlank));
/* Unit price */
productUnitPriceRatio = parseFloat(productUnitPriceRatio);
if (productUnitPriceRatio > 0 )
{
newUnitPrice = (productPrice / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
$('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
}
/* Ecotax */
var 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)
{
if (domAAroundImgThumb.attr('href'))
{
var newSrc = domAAroundImgThumb.attr('href').replace('thickbox','large');
if ($('#bigpic').attr('src') != newSrc)
{
$('#bigpic').fadeOut('fast', function(){
$(this).attr('src', newSrc).show();
if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
$(this).attr('alt', domAAroundImgThumb.attr('href'));
});
}
$('#views_block li a').removeClass('shown');
$(domAAroundImgThumb).addClass('shown');
}
}
// 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;
$('a#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
$('a#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'});
$('#thumbs_list li').hide();
id_product_attribute = parseInt(id_product_attribute);
if (typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
{
for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
$('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show();
}
if (i > 0)
{
var thumb_width = $('#thumbs_list_frame >li').width()+parseInt($('#thumbs_list_frame >li').css('marginRight'));
$('#thumbs_list_frame').width((parseInt((thumb_width)* i) + 3) + 'px'); // Bug IE6, needs 3 pixels more ?
}
else
{
$('#thumbnail_' + idDefaultImage).show();
displayImage($('#thumbnail_'+ idDefaultImage +' a'));
}
$('#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:'a#view_scroll_left',
next:'a#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)
{
$('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
$('span#view_full_size, div#image-block img').click(function(){
$('#views_block li a.shown').click();
});
//catch the click on the "more infos" button at the top of the page
$('div#short_description_block p a.button').click(function(){
$('#more_info_tab_more_info').click();
$.scrollTo( '#more_info_tabs', 1200 );
});
// Hide the customization submit button and display some message
$('p#customizedDatas input').click(function() {
$('p#customizedDatas input').hide();
$('#ajax-loader').fadeIn();
$('p#customizedDatas').append(uploading_in_progress);
});
//init the price in relation of the selected attributes
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
findCombination(true);
else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
refreshProductImages(0);
//
$('a#resetImages').click(function() {
updateColorSelect(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)
{
var id_product = $('#admin-action-product-id').val();
$.ajaxSetup({async: false});
$.post(url+'/ajax.php', { submitPublishProduct: '1', id_product: id_product, status: 1, redirect: redirect },
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');
}
}
+392
View File
@@ -0,0 +1,392 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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').click(function(){ upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false; });
$('.cart_quantity_down').unbind('click').click(function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; });
$('.cart_quantity_delete' ).unbind('click').click(function(){ deletProductFromSummary($(this).attr('id')); return false; });
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: updateQty });
});
function updateQty(val)
{
var id = $(this.el).attr('name');
var exp = new RegExp("^[0-9]+$");
if (exp.test(val) == true)
{
var hidden = $('input[name='+ id +'_hidden]').val();
var input = $('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
$('input[name='+ id +']').val($('input[name='+ id +'_hidden]').val());
}
function deletProductFromSummary(id)
{
var customizationId = 0;
var productId = 0;
var productAttributeId = 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')
customizationId = parseInt(ids[2]);
$.ajax({
type: 'GET',
url: baseDir + 'cart.php',
async: true,
cache: false,
dataType: 'json',
data: 'ajax=true&delete&summary&id_product='+productId+'&ipa='+productAttributeId+ ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
}
else
{
if (parseInt(jsonData.summary.products.length) == 0)
{
$('#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();
});
var exist = false;
for (i=0;i<jsonData.summary.products.length;i++)
if (jsonData.summary.products[i].id_product == productId)
exist = true;
// if all customization remove => delete product line
if (!exist)
$('#product_'+ productId+'_'+productAttributeId).fadeOut('slow', function() {
$(this).remove();
});
}
updateCartSummary(jsonData.summary);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
updateCustomizedDatas(jsonData.customizedDatas);
if (jsonData.carriers != null)
updateCarrierList(jsonData);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
function upQuantity(id, qty)
{
if(typeof(qty)=='undefined' || !qty)
qty = 1;
var customizationId = 0;
var productId = 0;
var productAttributeId = 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')
customizationId = parseInt(ids[2]);
$.ajax({
type: 'GET',
url: baseDir + 'cart.php',
async: true,
cache: false,
dataType: 'json',
data: 'ajax=true&add&summary&id_product='+productId+'&ipa='+productAttributeId + ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&qty='+qty+'&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
$('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val());
}
else
{
updateCustomizedDatas(jsonData.customizedDatas);
updateCartSummary(jsonData.summary);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null)
updateCarrierList(jsonData);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {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 ids = 0;
if (newVal > 0)
{
ids = id.split('_');
productId = parseInt(ids[0]);
if (typeof(ids[1]) != 'undefined')
productAttributeId = parseInt(ids[1]);
if (typeof(ids[2]) != 'undefined')
customizationId = parseInt(ids[2]);
$.ajax({
type: 'GET',
url: baseDir + 'cart.php',
async: true,
cache: false,
dataType: 'json',
data: 'ajax=true&add&summary&id_product='+productId+'&ipa='+productAttributeId+'&op=down' + ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&qty='+qty+'&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
$('input[name=quantity_'+ id +']').val($('input[name=quantity_'+ id +'_hidden]').val());
}
else
{
updateCustomizedDatas(jsonData.customizedDatas);
updateCartSummary(jsonData.summary);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if (jsonData.carriers != null)
updateCarrierList(jsonData);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
else
{
deletProductFromSummary(id);
}
}
function updateCartSummary(json)
{
// Update products prices + discount
var i;
var nbrProducts = 0;
for (i=0;i<json.products.length;i++)
{
key_for_blockcart = json.products[i].id_product+'_'+json.products[i].id_product_attribute;
if (json.products[i].id_product_attribute == 0)
key_for_blockcart = json.products[i].id_product;
$('#cart_block_product_'+key_for_blockcart+' span.quantity').html(json.products[i].cart_quantity);
if (priceDisplayMethod != 0)
{
$('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(json.products[i].total, currencyFormat, currencySign, currencyBlank));
$('#product_price_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute).html(formatCurrency(json.products[i].price, currencyFormat, currencySign, currencyBlank));
$('#total_product_price_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute).html(formatCurrency(json.products[i].total, currencyFormat, currencySign, currencyBlank));
}
else
{
$('#cart_block_product_'+key_for_blockcart+' span.price').html(formatCurrency(json.products[i].total_wt, currencyFormat, currencySign, currencyBlank));
$('#product_price_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute).html(formatCurrency(json.products[i].price_wt, currencyFormat, currencySign, currencyBlank));
$('#total_product_price_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute).html(formatCurrency(json.products[i].total_wt, currencyFormat, currencySign, currencyBlank));
}
nbrProducts += parseInt(json.products[i].cart_quantity);
if(json.products[i].id_customization == null)
{
$('input[name=quantity_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute+(json.products[i].id_customization != null ? '_'+json.products[i].id_customization : '')+']').val(json.products[i].cart_quantity);
$('input[name=quantity_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute+(json.products[i].id_customization != null ? '_'+json.products[i].id_customization : '')+'_hidden]').val(json.products[i].cart_quantity);
}
else
{
$('#cart_quantity_custom_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute).html(json.products[i].cart_quantity);
}
// Show / hide quantity button if minimal quantity
if (parseInt(json.products[i].minimal_quantity) == parseInt(json.products[i].cart_quantity) && json.products[i].minimal_quantity != 1)
$('#cart_quantity_down_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute+(json.products[i].id_customization != null ? '_'+json.products[i].id_customization : '')).fadeTo('slow',0.3);
else
$('#cart_quantity_down_'+json.products[i].id_product+'_'+json.products[i].id_product_attribute+(json.products[i].id_customization != null ? '_'+json.products[i].id_customization : '')).fadeTo('slow',1);
}
// Update discounts
if (json.discounts.length == 0)
{
$('.cart_discount').each(function(){$(this).remove()});
$('.cart_total_voucher').remove();
}
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 != '!')
$('#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
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));
}
$('#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').children('span').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));
if (json.total_shipping <= 0)
$('.cart_total_delivery').fadeOut();
else
{
$('.cart_total_delivery').fadeIn();
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));
}
}
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();
}
if (window.ajaxCart !== undefined)
ajaxCart.refresh();
}
function updateCustomizedDatas(json)
{
for(i in json)
for(j in json[i])
for(k in json[i][j])
{
$('input[name=quantity_'+i+'_'+j+'_'+k+'_hidden]').val(json[i][j][k]['quantity']);
$('input[name=quantity_'+i+'_'+j+'_'+k+']').val(json[i][j][k]['quantity']);
}
}
function updateHookShoppingCart(html)
{
$('#HOOK_SHOPPING_CART').html(html);
}
function updateHookShoppingCartExtra(html)
{
$('#HOOK_SHOPPING_CART_EXTRA').html(html);
}
+41
View File
@@ -0,0 +1,41 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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)
{
var id_cms = $('#admin-action-cms-id').val();
$.ajaxSetup({async: false});
$.post(url+'/ajax.php', { submitPublishCMS: '1', id_cms: id_cms, status: 1, redirect: redirect },
function(data)
{
if (data.indexOf('error') === -1)
document.location.href = data;
}
);
return true;
}
+128
View File
@@ -0,0 +1,128 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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)
{
var url;
if (file.match(/^https?:\/\//))
url = file;
else
url = baseDir + file + '.php';
$.get(
url,
((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 ($('div#order-detail-content table td.order_cb').length > 0)
{
//return slip : check or uncheck every checkboxes
$('form div#order-detail-content th input[type=checkbox]').click(function()
{
$('form div#order-detail-content td input[type=checkbox]').each(function()
{
this.checked = $('form div#order-detail-content th input[type=checkbox]').is(':checked');
updateOrderLineDisplay(this);
});
});
//return slip : enable or disable 'global' quantity editing
$('form div#order-detail-content td input[type=checkbox]').click(function()
{
updateOrderLineDisplay(this);
});
//return slip : limit quantities
$('form div#order-detail-content td input.order_qte_input').keyup(function()
{
var maxQuantity = parseInt($(this).parent().find('span.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);
}
});
}
//catch the submit event of sendOrderMessage form
$('form#sendOrderMessage').submit(function(){
return sendOrderMessage();
});
$(this).fadeIn('slow');
$.scrollTo(this, 1200);
resizeAddressesBox();
});
});
}
function updateOrderLineDisplay(domCheckbox){
var lineQuantitySpan = $(domCheckbox).parent().parent().find('span.order_qte_span');
var lineQuantityInput = $(domCheckbox).parent().parent().find('input.order_qte_input');
if($(domCheckbox).is(':checked'))
{
lineQuantitySpan.hide();
lineQuantityInput.show();
}
else
{
lineQuantityInput.hide();
lineQuantityInput.val(lineQuantitySpan.text());
lineQuantitySpan.show();
}
}
//send a message in relation to the order with ajax
function sendOrderMessage (){
paramString = "ajax=true";
$('form#sendOrderMessage').find('input, textarea').each(function(){
paramString += '&' + $(this).attr('name') + '=' + encodeURI($(this).val());
});
$.ajax({
type: "POST",
url: baseDir + "order-detail.php",
data: paramString,
success: function (msg){
$('#block-order-detail').fadeOut('slow', function() {
$(this).html(msg);
//catch the submit event of sendOrderMessage form
$('form#sendOrderMessage').submit(function(){
return sendOrderMessage();
});
$(this).fadeIn('slow');
});
}
});
return false;
}
+122
View File
@@ -0,0 +1,122 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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);
resizeAddressesBox();
});
//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)
{
$('#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 ($('select#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 = $('select#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+/;
link = link.replace(expression, 'id_address='+idAddress);
$('ul#address_' + addressType + ' li.address_update a').attr('href', link);
}
function updateAddresses()
{
var idAddress_delivery = $('select#id_address_delivery').val();
var idAddress_invoice = $('input[type=checkbox]#addressesAreEquals:checked').length == 1 ? idAddress_delivery : $('select#id_address_invoice').val();
$.ajax({
type: 'POST',
url: baseDir + 'order.php',
async: true,
cache: false,
dataType : "json",
data: 'processAddress=true&step=2&ajax=true&id_address_delivery=' + idAddress_delivery + '&id_address_invoice=' + idAddress_invoice+ '&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
resizeAddressesBox();
}
+681
View File
@@ -0,0 +1,681 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6772 $
* @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 carriers = json.carriers;
/* contains all carrier available for this address */
if (carriers.length == 0)
{
checkedCarrier = 0;
$('input[name=id_carrier]:checked').attr('checked', false);
$('#noCarrierWarning').show();
$('#extra_carrier').hide();
$('#recyclable_block').hide();
$('table#carrierTable:visible').hide();
}
else
{
checkedCarrier = json.checked;
var html = '';
for (i=0;i<carriers.length; i++)
{
var itemType = '';
if (i == 0)
itemType = 'first_item ';
else if (i == carriers.length-1)
itemType = 'last_item ';
if (i % 2)
itemType = itemType + 'alternate_item';
else
itemType = itemType + 'item';
var name = carriers[i].name;
if (carriers[i].img != '')
name = '<img src="'+carriers[i].img+'" alt="" />';
if (!(carriers[i].is_module && !isLogged))
var extraHtml = 'disabled="disabled"';
else if (checkedCarrier == carriers[i].id_carrier || carriers.length == 1)
var extraHtml = 'checked="checked"';
html = html +
'<tr class="'+itemType+'">'+
'<td class="carrier_action radio"><input type="radio" name="id_carrier" value="'+carriers[i].id_carrier+'" id="id_carrier'+carriers[i].id_carrier+'" onclick="updateCarrierSelectionAndGift();" '+extraHtml+' /></td>'+
'<td class="carrier_name"><label for="id_carrier'+carriers[i].id_carrier+'">'+name+'</label></td>'+
'<td class="carrier_infos">'+carriers[i].delay+'</td>'+
'<td class="carrier_price"><span class="price">'+formatCurrency(carriers[i].price, currencyFormat, currencySign, currencyBlank)+'</span>';
if (taxEnabled && displayPrice == 0)
html = html + ' ' + txtWithTax;
else
html = html + ' ' + txtWithoutTax;
html = html + '</td>'+
'</tr>';
}
if (json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined) html += json.HOOK_EXTRACARRIER;
$('#noCarrierWarning').hide();
$('#extra_carrier:hidden').show();
$('table#carrierTable tbody').html(html);
$('table#carrierTable:hidden').show();
$('#recyclable_block:hidden').show();
}
/* 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 div#HOOK_PAYMENT').html(json.HOOK_PAYMENT);
}
function updateAddressSelection()
{
var idAddress_delivery = ($('input#opc_id_address_delivery').length == 1 ? $('input#opc_id_address_delivery').val() : $('select#id_address_delivery').val());
var idAddress_invoice = ($('input#opc_id_address_invoice').length == 1 ? $('input#opc_id_address_invoice').val() : ($('input[type=checkbox]#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('select#id_address_invoice').length == 1 ? $('select#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',
url: orderOpcUrl,
async: true,
cache: false,
dataType : "json",
data: '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(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
}
else
{
updateCarrierList(jsonData);
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').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow');
$('#opc_payment_methods-overlay').fadeOut('slow');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
function getCarrierListAndUpdate()
{
$('#opc_delivery_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
async: true,
cache: false,
dataType : "json",
data: 'ajax=true&method=getCarrierList&token=' + static_token,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
}
else
updateCarrierList(jsonData);
$('#opc_delivery_methods-overlay').fadeOut('slow');
}
});
}
function updateCarrierSelectionAndGift()
{
var recyclablePackage = 0;
var gift = 0;
var giftMessage = '';
var idCarrier = 0;
if ($('input#recyclable:checked').length)
recyclablePackage = 1;
if ($('input#gift:checked').length)
{
gift = 1;
giftMessage = encodeURIComponent($('textarea#gift_message').val());
}
if ($('input[name=id_carrier]:checked').length)
{
idCarrier = $('input[name=id_carrier]:checked').val();
checkedCarrier = idCarrier;
}
$('#opc_payment_methods-overlay').fadeIn('slow');
$('#opc_delivery_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
async: false,
cache: false,
dataType : "json",
data: 'ajax=true&method=updateCarrierAndGetPayments&id_carrier=' + idCarrier + '&recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '';
for(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
}
else
{
updateCartSummary(jsonData.summary);
updatePaymentMethods(jsonData);
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
$('#opc_payment_methods-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
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').fadeIn('slow');
$('#opc_payment_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
async: true,
cache: false,
dataType : "html",
data: 'ajax=true&method=makeFreeOrder&token=' + static_token ,
success: function(html)
{
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) {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'+(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())+'&';
// Clean the last &
params = params.substr(0, params.length-1);
var result = false;
$.ajax({
type: 'POST',
url: addressUrl,
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(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').html(errors).slideDown('slow');
$.scrollTo('#opc_account_errors', 800);
$('#opc_new_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow');
$('#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) {alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
return result;
}
function updateNewAccountToAddressBlock()
{
$('#opc_new_account-overlay').fadeIn('slow');
$('#opc_delivery_methods-overlay').fadeIn('slow');
$('#opc_payment_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
async: true,
cache: false,
dataType : "json",
data: 'ajax=true&method=getAddressBlockAndCarriersAndPayments&token=' + static_token ,
success: function(json)
{
$('#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)
{
$('#header_user').fadeOut('slow', function() {
$(this).attr('id', 'header_user_old').after(json.block_user_info).fadeIn('slow');
$('#header_user_old').remove();
});
}
$('#opc_new_account').fadeIn('fast', function() {
updateCartSummary(json.summary);
updateAddressesDisplay(true);
updateCarrierList(json.carrier_list);
updatePaymentMethods(json);
if ($('#gift-price').length == 1)
$('#gift-price').html(json.gift_price);
$('#opc_delivery_methods-overlay').fadeOut('slow');
$('#opc_payment_methods-overlay').fadeOut('slow');
});
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
}
$(function() {
// GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT
if ((!isLogged) || (isGuest))
{
if (guestCheckoutEnabled && !isLogged)
{
$('#opc_account_choice').show();
$('#opc_account_form').hide();
$('#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').hide();
$('#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').hide();
$('#opc_invoice_address').hide();
$('#new_account_title').html(txtInstantCheckout);
updateState();
updateNeedIDNumber();
updateZipCode();
});
}
else if (isGuest)
{
$('.is_customer_param').hide();
$('#opc_account_form').show('slow');
$('#is_new_customer').val('0');
$('#opc_account_choice').hide();
$('#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').show();
$('#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',
url: authenticationUrl,
async: false,
cache: false,
dataType : "json",
data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#passwd').val())+'&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
for(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) {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() {
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');
});
// VALIDATION / CREATION AJAX
$('#submitAccount').click(function() {
$('#opc_new_account-overlay').fadeIn('slow');
$('#opc_delivery_methods-overlay').fadeIn('slow');
$('#opc_payment_methods-overlay').fadeIn('slow');
// RESET ERROR(S) MESSAGE(S)
$('#opc_account_errors').html('').slideUp('slow');
if ($('input#opc_id_customer').val() == 0)
{
var callingFile = authenticationUrl;
var params = 'submitAccount=true&';
}
else
{
var callingFile = orderOpcUrl;
var params = 'method=editCustomer&';
}
$('#opc_account_form input:visible').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',
url: callingFile,
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(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').html(errors).slideDown('slow');
$.scrollTo('#opc_account_errors', 800);
}
isGuest = ($('#is_new_customer').val() == 1 ? 0 : 1);
if (jsonData.id_customer != undefined && jsonData.id_customer != 0 && jsonData.isSaved)
{
// update token
static_token = jsonData.token;
// update addresses id
$('input#opc_id_address_delivery').val(jsonData.id_address_delivery);
$('input#opc_id_address_invoice').val(jsonData.id_address_invoice);
// It's not a new customer
if ($('input#opc_id_customer').val() != '0')
{
if (!saveAddress('delivery'))
return false;
}
// update id_customer
$('input#opc_id_customer').val(jsonData.id_customer);
if ($('#invoice_address:checked').length != 0)
{
if (!saveAddress('invoice'))
return false;
}
// update id_customer
$('input#opc_id_customer').val(jsonData.id_customer);
// force to refresh carrier list
if (isGuest)
{
$('#opc_account_saved').fadeIn('slow');
$('#submitAccount').hide();
updateAddressSelection();
}
else
updateNewAccountToAddressBlock();
}
$('#opc_new_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow');
$('#opc_payment_methods-overlay').fadeOut('slow');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
return false;
});
}
// Order message update
$('#message').blur(function() {
$('#opc_delivery_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
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(error in jsonData.errors)
//IE6 bug fix
if(error != 'indexOf')
errors += jsonData.errors[error] + "\n";
alert(errors);
}
else
$('#opc_delivery_methods-overlay').fadeOut('slow');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});
});
// Recyclable checkbox
$('input#recyclable').click(function() {
updateCarrierSelectionAndGift();
});
// Gift checkbox update
$('input#gift').click(function() {
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
else
$('p#gift_div').hide();
updateCarrierSelectionAndGift();
});
if ($('input#gift').is(':checked'))
$('p#gift_div').show();
else
$('p#gift_div').hide();
// Gift message update
$('textarea#gift_message').blur(function() {
updateCarrierSelectionAndGift();
});
// TOS
$('#cgv').click(function() {
if ($('#cgv:checked').length != 0)
var checked = 1;
else
var checked = 0;
$('#opc_payment_methods-overlay').fadeIn('slow');
$.ajax({
type: 'POST',
url: orderOpcUrl,
async: true,
cache: false,
dataType : "json",
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
success: function(json)
{
$('div#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
$('#opc_payment_methods-content div#HOOK_PAYMENT').html(json.HOOK_PAYMENT);
$('#opc_payment_methods-overlay').fadeOut('slow');
}
});
});
$('#opc_account_form input,select,textarea').change(function() {
if ($(this).is(':visible'))
{
$('#opc_account_saved').fadeOut('slow');
$('#submitAccount').show();
}
});
});
+662
View File
@@ -0,0 +1,662 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 7310 $
* @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 = new Array();
var selectedCombination = new Array();
var globalQuantity = new Number;
var colors = new Array();
//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 = new Array();
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'] = available_date;
combination['specific_price'] = new Array();
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 = new Array();
$('div#attributes select, div#attributes input[type=hidden], div#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() );
//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;
updateDisplay();
}
//update display of the availability of the product AND the prices of the product
function updateDisplay()
{
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();
//hide availability date
$('#availability_date_label').hide();
$('#availability_date_value').hide();
//availability value management
if (availableNowValue != '')
{
//update the availability statut of the product
$('#availability_value').removeClass('warning_inline');
$('#availability_value').text(availableNowValue);
$('#availability_statut:hidden').show();
}
else
{
//hide the availability value
$('#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();
}
$('#availability_statut:hidden').show();
//display availability date
if (selectedCombination.length)
{
var available_date = selectedCombination['available_date'];
tab_date = available_date.split('-');
var time_available = new Date(tab_date[2], tab_date[1], tab_date[0]);
time_available.setMonth(time_available.getMonth()-1);
var now = new Date();
// date displayed only if time_available
if (now.getTime() < time_available.getTime())
{
$('#availability_date_value').text(selectedCombination['available_date']);
$('#availability_date_label').show();
$('#availability_date_value').show();
}
else
{
$('#availability_date_label').hide();
$('#availability_date_value').hide();
}
}
//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);
$('p#availability_statut:hidden').show('slow');
}
else
$('p#availability_statut:visible').hide('slow');
}
else
{
$('#add_to_cart:visible').fadeOut(600);
$('p#availability_statut:hidden').show('slow');
}
if (productAvailableForOrder == 0)
$('p#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)
{
// 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)
if (!displayPrice && !noTaxForThisProduct)
{
var priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);
} else {
var priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);
}
var combination_add_price = selectedCombination['price'] * group_reduction;
var tax = (taxRate / 100) + 1;
var display_specific_price;
if (selectedCombination['specific_price'])
{
display_specific_price = selectedCombination['specific_price'].price;
if (selectedCombination['specific_price'].reduction_type == 'percentage')
{
$('#reduction_amount').hide();
$('#reduction_percent_display').html('-' + selectedCombination['specific_price'].reduction*100 + '%');
$('#reduction_percent').show();
} else if (selectedCombination['specific_price'].reduction_type == 'amount') {
$('#reduction_percent').hide();
$('#reduction_amount').show();
} else {
$('#reduction_percent').hide();
$('#reduction_amount').hide();
}
}
else
{
display_specific_price = specific_price;
if (display_specific_price)
{
if (product_specific_price.reduction_type == 'percentage')
{
$('#reduction_percent_display').html(product_specific_price['specific_price'].reduction*100);
$('#reduction_percent').show();
}
else
$('#reduction_percent').hide();
if (productPriceWithoutRedution < productPrice)
$('#old_price_display,#old_price_display_taxes').show();
}
}
if (display_specific_price)
$('#discount_reduced_price,#old_price,#not_impacted_by_discount, #old_price_display, #old_price_display_taxes').show();
else
$('#discount_reduced_price,#old_price,#not_impacted_by_discount,#old_price_display,#old_price_display_taxes').hide();
var taxExclPrice = (display_specific_price ? (specific_currency ? display_specific_price : display_specific_price * currencyRate) : priceTaxExclWithoutGroupReduction) + selectedCombination['price'] * currencyRate;
if (display_specific_price)
var productPriceWithoutReduction = priceTaxExclWithoutGroupReduction + selectedCombination['price'] * currencyRate;
if (!displayPrice && !noTaxForThisProduct)
{
var productPrice = taxExclPrice * tax;
if (display_specific_price)
productPriceWithoutReduction = ps_round(productPriceWithoutReduction * tax, 2);
}
else
{
var productPrice = ps_round(taxExclPrice, 2);
if (display_specific_price)
productPriceWithoutReduction = ps_round(productPriceWithoutReduction, 2);
}
var reduction = 0;
if (reduction_price || reduction_percent)
{
reduction = productPrice * (parseFloat(reduction_percent) / 100) + reduction_price;
if (reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
if (!display_specific_price)
productPriceWithoutReduction = productPrice * group_reduction;
productPrice -= reduction;
var tmp = productPrice * group_reduction;
productPrice = ps_round(productPrice * group_reduction, 2);
var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
productPrice += ecotaxAmount;
productPriceWithoutReduction += ecotaxAmount;
//productPrice = ps_round(productPrice * currencyRate, 2);
if (productPrice > 0)
$('#our_price_display').text(formatCurrency(productPrice, currencyFormat, currencySign, currencyBlank));
else
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
/* Special feature: "Display product price tax excluded on product page" */
if (!noTaxForThisProduct)
var productPricePretaxed = productPrice / tax;
else
var productPricePretaxed = productPrice;
$('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, currencyFormat, currencySign, currencyBlank));
/* Unit price */
productUnitPriceRatio = parseFloat(productUnitPriceRatio);
if (productUnitPriceRatio > 0 )
{
newUnitPrice = (productPrice / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
$('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
}
/* Ecotax */
var 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)
{
if (domAAroundImgThumb.attr('href'))
{
var newSrc = domAAroundImgThumb.attr('href').replace('thickbox','large');
if ($('#bigpic').attr('src') != newSrc)
{
$('#bigpic').fadeOut('fast', function(){
$(this).attr('src', newSrc).show();
if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
$(this).attr('alt', domAAroundImgThumb.attr('href'));
});
}
$('#views_block li a').removeClass('shown');
$(domAAroundImgThumb).addClass('shown');
}
}
// 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;
$('a#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
$('a#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'});
$('#thumbs_list li').hide();
id_product_attribute = parseInt(id_product_attribute);
if (typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
{
for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
$('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show();
}
if (i > 0)
{
var thumb_width = $('#thumbs_list_frame >li').width()+parseInt($('#thumbs_list_frame >li').css('marginRight'));
$('#thumbs_list_frame').width((parseInt((thumb_width)* i) + 3) + 'px'); // Bug IE6, needs 3 pixels more ?
}
else
{
$('#thumbnail_' + idDefaultImage).show();
displayImage($('#thumbnail_'+ idDefaultImage +' a'));
}
$('#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:'a#view_scroll_left',
next:'a#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)
{
$('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
$('span#view_full_size, div#image-block img').click(function(){
$('#views_block li a.shown').click();
});
//catch the click on the "more infos" button at the top of the page
$('div#short_description_block p a.button').click(function(){
$('#more_info_tab_more_info').click();
$.scrollTo( '#more_info_tabs', 1200 );
});
// Hide the customization submit button and display some message
$('p#customizedDatas input').click(function() {
$('p#customizedDatas input').hide();
$('#ajax-loader').fadeIn();
$('p#customizedDatas').append(uploading_in_progress);
});
//init the price in relation of the selected attributes
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
findCombination(true);
else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
refreshProductImages(0);
//
$('a#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)
{
var id_product = $('#admin-action-product-id').val();
$.ajaxSetup({async: false});
$.post(url+'/ajax.php', { submitPublishProduct: '1', id_product: id_product, status: 1, redirect: redirect },
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_', '');
$('.color_pick').removeClass('selected');
$(elt).fadeTo('fast', 1, function(){
$(this).fadeTo('slow', 0, function(){
$(this).fadeTo('slow', 1, function(){
$(this).addClass('selected');
});
});
});
$('#color_pick_hidden').val(id_attribute);
findCombination();
}
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 = new Array();
$('div#attributes select, div#attributes input[type=hidden], div#attributes input[type=radio]:checked').each(function(){
tab_attributes.push($(this).val());
});
// build new request
for (i in attributesCombinations)
for (a in tab_attributes)
if (attributesCombinations[i]['id_attribute'] == tab_attributes[a])
request += '&'+attributesCombinations[i]['group']+'='+attributesCombinations[i]['attribute'];
request = request.replace(request.substring(0, 1), '#');
url = window.location+'';
// redirection
if (url.indexOf('#') != -1)
url = url.substring(0, url.indexOf('#'));
window.location = url+request;
}
$(document).ready(function(){
url = window.location+'';
// if we need to load a specific combination
if (url.indexOf('#') != -1)
{
// get the params to fill
params = url.substring(url.indexOf('#') + 1, url.length);
tabParams = params.split('&');
tabValues = new Array();
for (i in tabParams)
tabValues.push(tabParams[i].split('='));
product_id = $('#product_page_product_id').val();
// fill html with values
$('.color_pick').removeClass('selected');
count = 0;
for (z in tabValues)
for (a in attributesCombinations)
if (attributesCombinations[a]['group'] == tabValues[z][0]
&& attributesCombinations[a]['attribute'] == tabValues[z][1])
{
count++;
// add class 'selected' to the selected color
$('#color_'+attributesCombinations[a]['id_attribute']).addClass('selected');
$('input:radio[value='+attributesCombinations[a]['id_attribute']+']').attr('checked', 'checked');
$('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 == tabValues.length)
findCombination();
// no combination found = removing attributes from url
else
window.location = url.substring(0, url.indexOf('#'));
}
});
+82
View File
@@ -0,0 +1,82 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6844 $
* @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,
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,
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,
success: function(data){
if (data == '0')
checkbox.attr('checked', true);
},
error: function(){
checkbox.attr('checked', true);
}
});
}
});
}
+92
View File
@@ -0,0 +1,92 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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);
});
+217
View File
@@ -0,0 +1,217 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6752 $
* @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, addressNoHtml, 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();
initMarkers();
}
function searchLocationsNear(center)
{
var radius = document.getElementById('radiusSelect').value;
var searchUrl = baseDir+'stores.php?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, addressNoHtml, other, id_store, has_store_picture);
bounds.extend(latlng);
$('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+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.onchange = function() {
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
google.maps.event.trigger(markers[markerNum], 'click');
};
});
}
function createMarker(latlng, name, address, addressNoHtml, 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.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_stores.gif');
if (hasStoreIcon)
var marker = new google.maps.Marker({ map: map, icon: image, position: latlng });
else
var 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();
});
+226
View File
@@ -0,0 +1,226 @@
/*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @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);
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;
}
function resizeAddressesBox(nameBox)
{
maxHeight = 0;
if (typeof(nameBox) == 'undefined')
nameBox = '.address';
$(nameBox).each(function()
{
$(this).css('height', 'auto');
currentHeight = $(this).height();
if (maxHeight < currentHeight)
maxHeight = currentHeight;
});
$(nameBox).height(maxHeight);
}
@@ -0,0 +1,61 @@
$(document).ready(function(){
$('select#id_country').change(function(){
updateState();
updateNeedIDNumber();
updateZipCode();
});
updateState();
updateNeedIDNumber();
updateZipCode();
if ($('select#id_country_invoice').length != 0)
{
$('select#id_country_invoice').change(function(){
updateState('invoice');
updateNeedIDNumber('invoice');
updateZipCode();
});
if ($('select#id_country_invoice:visible').length != 0)
{
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>');
});
$('p.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden').slideDown('slow');
}
else
$('p.id_state'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');
}
function updateNeedIDNumber(suffix)
{
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
if ($.inArray(idCountry, countriesNeedIDNumber) >= 0)
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');
else
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');
}
function updateZipCode(suffix)
{
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
if (countriesNeedZipCode[idCountry] != 0)
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');
else
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');
}
+57
View File
@@ -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');
}
});