revert modif on product.js

This commit is contained in:
vAugagneur
2012-12-17 18:05:22 +01:00
parent 4785acb7f9
commit a7ad0d9b30
+37 -39
View File
@@ -33,8 +33,8 @@ var colors = [];
//check if a function exists //check if a function exists
function function_exists(function_name) function function_exists(function_name)
{ {
if (typeof function_name === 'string') if (typeof function_name == 'string')
return (typeof window[function_name] === 'function'); return (typeof window[function_name] == 'function');
return (function_name instanceof Function); return (function_name instanceof Function);
} }
@@ -118,7 +118,7 @@ function findCombination(firstTime)
selectedCombination['ecotax'] = default_eco_tax; selectedCombination['ecotax'] = default_eco_tax;
//show the large image in relation to the selected combination //show the large image in relation to the selected combination
if (combinations[combination]['image'] && combinations[combination]['image'] !== -1) if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
displayImage( $('#thumb_'+combinations[combination]['image']).parent() ); displayImage( $('#thumb_'+combinations[combination]['image']).parent() );
//show discounts values according to the selected combination //show discounts values according to the selected combination
@@ -131,7 +131,7 @@ function findCombination(firstTime)
//update the display //update the display
updateDisplay(); updateDisplay();
if(typeof(firstTime) !== 'undefined' && firstTime) if(typeof(firstTime) != 'undefined' && firstTime)
refreshProductImages(0); refreshProductImages(0);
else else
refreshProductImages(combinations[combination]['idCombination']); refreshProductImages(combinations[combination]['idCombination']);
@@ -147,7 +147,7 @@ function findCombination(firstTime)
//update display of the availability of the product AND the prices of the product //update display of the availability of the product AND the prices of the product
function updateDisplay() function updateDisplay()
{ {
if (!selectedCombination['unavailable'] && quantityAvailable > 0 && parseInt(productAvailableForOrder) === 1) if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1)
{ {
//show the choice of quantities //show the choice of quantities
$('#quantity_wanted_p:hidden').show('slow'); $('#quantity_wanted_p:hidden').show('slow');
@@ -163,13 +163,12 @@ function updateDisplay()
$('#availability_date_value').hide(); $('#availability_date_value').hide();
//availability value management //availability value management
if (availableNowValue !== '') if (availableNowValue != '')
{ {
//update the availability statut of the product //update the availability statut of the product
$('#availability_value').removeClass('warning_inline'); $('#availability_value').removeClass('warning_inline');
$('#availability_value').text(availableNowValue); $('#availability_value').text(availableNowValue);
if(stock_management === 1) if(stock_management == 1)
$('#availability_statut:hidden').show(); $('#availability_statut:hidden').show();
} }
else else
@@ -207,7 +206,7 @@ function updateDisplay()
else else
{ {
//show the hook out of stock //show the hook out of stock
if (productAvailableForOrder === 1) if (productAvailableForOrder == 1)
{ {
$('#oosHook').show(); $('#oosHook').show();
if ($('#oosHook').length > 0 && function_exists('oosHookJsCode')) if ($('#oosHook').length > 0 && function_exists('oosHookJsCode'))
@@ -232,7 +231,7 @@ function updateDisplay()
$('#availability_value').text(doesntExist).addClass('warning_inline'); $('#availability_value').text(doesntExist).addClass('warning_inline');
$('#oosHook').hide(); $('#oosHook').hide();
} }
if(stock_management === 1) if(stock_management == 1)
$('#availability_statut:hidden').show(); $('#availability_statut:hidden').show();
//display availability date //display availability date
@@ -257,14 +256,14 @@ function updateDisplay()
} }
} }
//show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible //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) if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder == 1)
{ {
$('#add_to_cart:hidden').fadeIn(600); $('#add_to_cart:hidden').fadeIn(600);
if (availableLaterValue !== '') if (availableLaterValue != '')
{ {
$('#availability_value').text(availableLaterValue); $('#availability_value').text(availableLaterValue);
if(stock_management === 1) if(stock_management == 1)
$('#availability_statut:hidden').show('slow'); $('#availability_statut:hidden').show('slow');
} }
else else
@@ -273,11 +272,11 @@ function updateDisplay()
else else
{ {
$('#add_to_cart:visible').fadeOut(600); $('#add_to_cart:visible').fadeOut(600);
if(stock_management === 1) if(stock_management == 1)
$('#availability_statut:hidden').show('slow'); $('#availability_statut:hidden').show('slow');
} }
if (productAvailableForOrder === 0) if (productAvailableForOrder == 0)
$('#availability_statut:visible').hide(); $('#availability_statut:visible').hide();
} }
@@ -293,7 +292,7 @@ function updateDisplay()
$('#product_reference:visible').hide('slow'); $('#product_reference:visible').hide('slow');
//update display of the the prices in relation to tax, discount, ecotax, and currency criteria //update display of the the prices in relation to tax, discount, ecotax, and currency criteria
if (!selectedCombination['unavailable'] && productShowPrice === 1) if (!selectedCombination['unavailable'] && productShowPrice == 1)
{ {
var priceTaxExclWithoutGroupReduction = ''; var priceTaxExclWithoutGroupReduction = '';
@@ -313,12 +312,12 @@ function updateDisplay()
if (selectedCombination.specific_price) if (selectedCombination.specific_price)
{ {
display_specific_price = selectedCombination.specific_price['price']; display_specific_price = selectedCombination.specific_price['price'];
if (selectedCombination['specific_price'].reduction_type === 'percentage') if (selectedCombination['specific_price'].reduction_type == 'percentage')
{ {
$('#reduction_amount').hide(); $('#reduction_amount').hide();
$('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%'); $('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');
$('#reduction_percent').show(); $('#reduction_percent').show();
} else if (selectedCombination['specific_price'].reduction_type === 'amount' && selectedCombination['specific_price'].reduction_price !== 0) { } else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) {
$('#reduction_amount_display').html('-' + formatCurrency(selectedCombination['specific_price'].reduction_price, currencyFormat, currencySign, currencyBlank)); $('#reduction_amount_display').html('-' + formatCurrency(selectedCombination['specific_price'].reduction_price, currencyFormat, currencySign, currencyBlank));
$('#reduction_percent').hide(); $('#reduction_percent').hide();
$('#reduction_amount').show(); $('#reduction_amount').show();
@@ -330,16 +329,16 @@ function updateDisplay()
else else
{ {
display_specific_price = product_specific_price['price']; display_specific_price = product_specific_price['price'];
if (product_specific_price['reduction_type'] === 'percentage') if (product_specific_price['reduction_type'] == 'percentage')
$('#reduction_percent_display').html(product_specific_price['specific_price'].reduction_percent); $('#reduction_percent_display').html(product_specific_price['specific_price'].reduction_percent);
} }
if (product_specific_price['reduction_type'] !== '' || selectedCombination['specific_price'].reduction_type !== '') if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
$('#discount_reduced_price,#old_price').show(); $('#discount_reduced_price,#old_price').show();
else else
$('#discount_reduced_price,#old_price').hide(); $('#discount_reduced_price,#old_price').hide();
if (product_specific_price['reduction_type'] === 'percentage' || selectedCombination['specific_price'].reduction_type === 'percentage') if (product_specific_price['reduction_type'] == 'percentage' || selectedCombination['specific_price'].reduction_type == 'percentage')
$('#reduction_percent').show(); $('#reduction_percent').show();
else else
$('#reduction_percent').hide(); $('#reduction_percent').hide();
@@ -404,7 +403,6 @@ function updateDisplay()
$('#old_price,#old_price_display,#old_price_display_taxes').show(); $('#old_price,#old_price_display,#old_price_display_taxes').show();
else else
$('#old_price,#old_price_display,#old_price_display_taxes').hide(); $('#old_price,#old_price_display,#old_price_display_taxes').hide();
// Special feature: "Display product price tax excluded on product page" // Special feature: "Display product price tax excluded on product page"
var productPricePretaxed = ''; var productPricePretaxed = '';
if (!noTaxForThisProduct) if (!noTaxForThisProduct)
@@ -429,17 +427,17 @@ function updateDisplay()
//update display of the large image //update display of the large image
function displayImage(domAAroundImgThumb, no_animation) function displayImage(domAAroundImgThumb, no_animation)
{ {
if (typeof(no_animation) === 'undefined') if (typeof(no_animation) == 'undefined')
no_animation = false; no_animation = false;
if (domAAroundImgThumb.attr('href')) if (domAAroundImgThumb.attr('href'))
{ {
var newSrc = domAAroundImgThumb.attr('href').replace('thickbox','large'); var newSrc = domAAroundImgThumb.attr('href').replace('thickbox','large');
if ($('#bigpic').attr('src') !== newSrc) if ($('#bigpic').attr('src') != newSrc)
{ {
$('#bigpic').fadeOut((no_animation ? 0 : 'fast'), function(){ $('#bigpic').fadeOut((no_animation ? 0 : 'fast'), function(){
$(this).attr('src', newSrc).show(); $(this).attr('src', newSrc).show();
if (typeof(jqZoomEnabled) !== 'undefined' && jqZoomEnabled) if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
$(this).attr('alt', domAAroundImgThumb.attr('href')); $(this).attr('alt', domAAroundImgThumb.attr('href'));
}); });
} }
@@ -452,13 +450,13 @@ function displayImage(domAAroundImgThumb, no_animation)
function displayDiscounts(combination) function displayDiscounts(combination)
{ {
$('#quantityDiscount tbody tr').each(function() { $('#quantityDiscount tbody tr').each(function() {
if (($(this).attr('id') !== 'quantityDiscount_0') && if (($(this).attr('id') != 'quantityDiscount_0') &&
($(this).attr('id') !== 'quantityDiscount_'+combination) && ($(this).attr('id') != 'quantityDiscount_'+combination) &&
($(this).attr('id') !== 'noQuantityDiscount')) ($(this).attr('id') != 'noQuantityDiscount'))
$(this).fadeOut('slow'); $(this).fadeOut('slow');
}); });
if ($('#quantityDiscount_'+combination).length !== 0) { if ($('#quantityDiscount_'+combination).length != 0) {
$('#quantityDiscount_'+combination).show(); $('#quantityDiscount_'+combination).show();
$('#noQuantityDiscount').hide(); $('#noQuantityDiscount').hide();
} else } else
@@ -471,7 +469,7 @@ function serialScrollFixLock(event, targeted, scrolled, items, position)
serialScrollNbImages = $('#thumbs_list li:visible').length; serialScrollNbImages = $('#thumbs_list li:visible').length;
serialScrollNbImagesDisplayed = 3; serialScrollNbImagesDisplayed = 3;
var leftArrow = position === 0 ? true : false; var leftArrow = position == 0 ? true : false;
var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false; var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false;
$('#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1); $('#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
@@ -486,7 +484,7 @@ function refreshProductImages(id_product_attribute)
$('#thumbs_list li').hide(); $('#thumbs_list li').hide();
id_product_attribute = parseInt(id_product_attribute); id_product_attribute = parseInt(id_product_attribute);
if (typeof(combinationImages) !== 'undefined' && typeof(combinationImages[id_product_attribute]) !== 'undefined') if (typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
{ {
for (var i = 0; i < combinationImages[id_product_attribute].length; i++) for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
$('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show(); $('#thumbnail_' + parseInt(combinationImages[id_product_attribute][i])).show();
@@ -536,7 +534,7 @@ $(document).ready(function()
); );
//set jqZoom parameters if needed //set jqZoom parameters if needed
if (typeof(jqZoomEnabled) !== 'undefined' && jqZoomEnabled) if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
{ {
$('img.jqzoom').jqueryzoom({ $('img.jqzoom').jqueryzoom({
xzoom: 200, //zooming div default width(default width value is 200) xzoom: 200, //zooming div default width(default width value is 200)
@@ -564,9 +562,9 @@ $(document).ready(function()
}); });
//init the price in relation of the selected attributes //init the price in relation of the selected attributes
if (typeof productHasAttributes !== 'undefined' && productHasAttributes) if (typeof productHasAttributes != 'undefined' && productHasAttributes)
findCombination(true); findCombination(true);
else if (typeof productHasAttributes !== 'undefined' && !productHasAttributes) else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
refreshProductImages(0); refreshProductImages(0);
$('#resetImages').click(function() { $('#resetImages').click(function() {
@@ -674,11 +672,11 @@ function getProductAttribute()
url = window.location+''; url = window.location+'';
// redirection // redirection
if (url.indexOf('#') !== -1) if (url.indexOf('#') != -1)
url = url.substring(0, url.indexOf('#')); url = url.substring(0, url.indexOf('#'));
// set ipa to the customization form // set ipa to the customization form
$('#customizationForm').attr('action', $('#customizationForm').attr('action')+request); $('#customizationForm').attr('action', $('#customizationForm').attr('action')+request)
window.location = url+request; window.location = url+request;
} }
@@ -695,13 +693,13 @@ function checkUrl()
first_url_check = false; first_url_check = false;
url = window.location+''; url = window.location+'';
// if we need to load a specific combination // if we need to load a specific combination
if (url.indexOf('#/') !== -1) if (url.indexOf('#/') != -1)
{ {
// get the params to fill from a "normal" url // get the params to fill from a "normal" url
params = url.substring(url.indexOf('#') + 1, url.length); params = url.substring(url.indexOf('#') + 1, url.length);
tabParams = params.split('/'); tabParams = params.split('/');
tabValues = []; tabValues = [];
if (tabParams[0] === '') if (tabParams[0] == '')
tabParams.shift(); tabParams.shift();
for (var i in tabParams) for (var i in tabParams)
tabValues.push(tabParams[i].split('-')); tabValues.push(tabParams[i].split('-'));
@@ -734,4 +732,4 @@ function checkUrl()
window.location = url.substring(0, url.indexOf('#')); window.location = url.substring(0, url.indexOf('#'));
} }
} }
} }