[+] FO : Missing old default templates
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function submitPublishCMS(url, redirect, token)
|
||||
{
|
||||
var id_cms = $('#admin-action-cms-id').val();
|
||||
|
||||
$.ajaxSetup({async: false});
|
||||
$.post(url+'/index.php', {
|
||||
action: 'PublishCMS',
|
||||
id_cms: id_cms,
|
||||
status: 1,
|
||||
redirect: redirect,
|
||||
ajax: 1,
|
||||
tab: 'AdminCmsContent',
|
||||
token: token
|
||||
},
|
||||
function(data)
|
||||
{
|
||||
if (data.indexOf('error') === -1)
|
||||
document.location.href = data;
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
$('select[name=id_order]').change(function () {
|
||||
showProductSelect($(this).attr('value'));
|
||||
});
|
||||
showProductSelect($('select[name=id_order]').attr('value'));
|
||||
});
|
||||
|
||||
function showProductSelect(id_order)
|
||||
{
|
||||
$('.product_select').hide().attr('disabled', 'disabled');
|
||||
$('#'+id_order+'_order_products').show().removeAttr('disabled');
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
//show the order-details with ajax
|
||||
function showOrder(mode, var_content, file)
|
||||
{
|
||||
$.get(
|
||||
file,
|
||||
((mode === 1) ? {'id_order': var_content, 'ajax': true} : {'id_order_return': var_content, 'ajax': true}),
|
||||
function(data)
|
||||
{
|
||||
$('#block-order-detail').fadeOut('slow', function()
|
||||
{
|
||||
$(this).html(data);
|
||||
/* if return is allowed*/
|
||||
if ($('#order-detail-content .order_cb').length > 0)
|
||||
{
|
||||
//return slip : check or uncheck every checkboxes
|
||||
$('#order-detail-content th input[type=checkbox]').click(function()
|
||||
{
|
||||
$('#order-detail-content td input[type=checkbox]').each(function()
|
||||
{
|
||||
this.checked = $('#order-detail-content th input[type=checkbox]').is(':checked');
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
});
|
||||
//return slip : enable or disable 'global' quantity editing
|
||||
$('#order-detail-content td input[type=checkbox]').click(function()
|
||||
{
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
//return slip : limit quantities
|
||||
$('#order-detail-content td .order_qte_input').keyup(function()
|
||||
{
|
||||
var maxQuantity = parseInt($(this).parent().find('.order_qte_span').text());
|
||||
var quantity = parseInt($(this).val());
|
||||
if (isNaN($(this).val()) && $(this).val() !== '')
|
||||
{
|
||||
$(this).val(maxQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (quantity > maxQuantity)
|
||||
$(this).val(maxQuantity);
|
||||
else if (quantity < 1)
|
||||
$(this).val(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('form#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow', function() {
|
||||
$.scrollTo(this, 1200);
|
||||
resizeAddressesBox();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateOrderLineDisplay(domCheckbox)
|
||||
{
|
||||
var lineQuantitySpan = $(domCheckbox).parent().parent().find('.order_qte_span');
|
||||
var lineQuantityInput = $(domCheckbox).parent().parent().find('.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";
|
||||
$('#sendOrderMessage').find('input, textarea, select').each(function(){
|
||||
paramString += '&' + $(this).attr('name') + '=' + encodeURIComponent($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: $('#sendOrderMessage').attr("action") + '?rand=' + new Date().getTime(),
|
||||
data: paramString,
|
||||
success: function (msg){
|
||||
$('#block-order-detail').fadeOut('slow', function() {
|
||||
$(this).html(msg);
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow');
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,618 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registred Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
var ajaxQueries = new Array();
|
||||
var ajaxLoaderOn = 0;
|
||||
var sliderList = new Array();
|
||||
var slidersInit = false;
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
cancelFilter();
|
||||
openCloseFilter();
|
||||
|
||||
// Click on color
|
||||
$('#layered_form input[type=button], #layered_form label.layered_color').live('click', function()
|
||||
{
|
||||
if (!$('input[name='+$(this).attr('name')+'][type=hidden]').length)
|
||||
$('<input />').attr('type', 'hidden').attr('name', $(this).attr('name')).val($(this).attr('rel')).appendTo('#layered_form');
|
||||
else
|
||||
$('input[name='+$(this).attr('name')+'][type=hidden]').remove();
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
// Click on checkbox
|
||||
$('#layered_form input[type=checkbox], #layered_form input[type=radio], #layered_form select').live('change', function()
|
||||
{
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
// Changing content of an input text
|
||||
$('#layered_form input.layered_input_range').live('keyup', function()
|
||||
{
|
||||
if ($(this).attr('timeout_id'))
|
||||
window.clearTimeout($(this).attr('timeout_id'));
|
||||
|
||||
// IE Hack, setTimeout do not acept the third parameter
|
||||
var reference = this;
|
||||
|
||||
$(this).attr('timeout_id', window.setTimeout(function(it) {
|
||||
if (!$(it).attr('id'))
|
||||
it = reference;
|
||||
|
||||
var filter = $(it).attr('id').replace(/^layered_(.+)_range_.*$/, '$1');
|
||||
|
||||
var value_min = parseInt($('#layered_'+filter+'_range_min').val());
|
||||
if (isNaN(value_min))
|
||||
value_min = 0;
|
||||
$('#layered_'+filter+'_range_min').val(value_min);
|
||||
|
||||
var value_max = parseInt($('#layered_'+filter+'_range_max').val());
|
||||
if (isNaN(value_max))
|
||||
value_max = 0;
|
||||
$('#layered_'+filter+'_range_max').val(value_max);
|
||||
|
||||
if (value_max < value_min) {
|
||||
$('#layered_'+filter+'_range_max').val($(it).val());
|
||||
$('#layered_'+filter+'_range_min').val($(it).val());
|
||||
}
|
||||
reloadContent();
|
||||
}, 500, this));
|
||||
});
|
||||
|
||||
$('#layered_block_left .radio').live('click', function() {
|
||||
var name = $(this).attr('name');
|
||||
$.each($(this).parent().parent().find('input[type=button]'), function (it, item) {
|
||||
if ($(item).hasClass('on') && $(item).attr('name') != name) {
|
||||
$(item).click();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
// Click on label
|
||||
$('#layered_block_left label a').live({
|
||||
click: function() {
|
||||
var disable = $(this).parent().parent().find('input').attr('disabled');
|
||||
if (disable == ''
|
||||
|| typeof(disable) == 'undefined'
|
||||
|| disable == false)
|
||||
{
|
||||
$(this).parent().parent().find('input').click();
|
||||
reloadContent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
layered_hidden_list = {};
|
||||
$('.hide-action').live('click', function() {
|
||||
if (typeof(layered_hidden_list[$(this).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(this).parent().find('ul').attr('id')] == false)
|
||||
{
|
||||
layered_hidden_list[$(this).parent().find('ul').attr('id')] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
layered_hidden_list[$(this).parent().find('ul').attr('id')] = false;
|
||||
}
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
$('.hide-action').each(function() {
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
|
||||
// To be sure there is no other events attached to the selectPrductSort, change the ID
|
||||
var id = 1;
|
||||
while ($('#selectPrductSort').length) { // Because ids are duplicated
|
||||
// Unbind event change on #selectPrductSort
|
||||
$('#selectPrductSort').unbind('change');
|
||||
$('#selectPrductSort').attr('onchange', '');
|
||||
$('#selectPrductSort').addClass('selectProductSort');
|
||||
$('#selectPrductSort').attr('id', 'selectPrductSort'+id);
|
||||
$('label[for=selectPrductSort]').attr('for', 'selectPrductSort'+id);
|
||||
id++;
|
||||
}
|
||||
|
||||
// Since 1.5, event is add to .selectProductSort and not to #selectPrductSort
|
||||
setTimeout(function() {
|
||||
$('.selectProductSort').unbind('change');
|
||||
}, 100);
|
||||
|
||||
$('.selectProductSort').live('change', function(event) {
|
||||
$('.selectProductSort').val($(this).val());
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
$('.js-nb_item').unbind('change').attr('onchange', '');
|
||||
|
||||
$('.js-nb_item').live('change', function(event) {
|
||||
$('.js-nb_item').val($(this).val());
|
||||
reloadContent();
|
||||
});
|
||||
|
||||
paginationButton();
|
||||
initLayered();
|
||||
});
|
||||
|
||||
function hideFilterValueAction(it)
|
||||
{
|
||||
if (typeof(layered_hidden_list[$(it).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(it).parent().find('ul').attr('id')] == false)
|
||||
{
|
||||
$(it).parent().find('.hiddable').hide();
|
||||
$(it).parent().find('.hide-action.less').hide();
|
||||
$(it).parent().find('.hide-action.more').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(it).parent().find('.hiddable').show();
|
||||
$(it).parent().find('.hide-action.less').show();
|
||||
$(it).parent().find('.hide-action.more').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function addSlider(type, data, unit, format)
|
||||
{
|
||||
sliderList.push({
|
||||
type: type,
|
||||
data: data,
|
||||
unit: unit,
|
||||
format: format
|
||||
});
|
||||
}
|
||||
|
||||
function initSliders()
|
||||
{
|
||||
$(sliderList).each(function(i, slider){
|
||||
$('#layered_'+slider['type']+'_slider').slider(slider['data']);
|
||||
|
||||
var from = '';
|
||||
var to = '';
|
||||
switch (slider['format'])
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
from = blocklayeredFormatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 0), slider['format'], slider['unit']);
|
||||
to = blocklayeredFormatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 1), slider['format'], slider['unit']);
|
||||
break;
|
||||
case 5:
|
||||
from = $('#layered_'+slider['type']+'_slider').slider('values', 0)+slider['unit']
|
||||
to = $('#layered_'+slider['type']+'_slider').slider('values', 1)+slider['unit'];
|
||||
break;
|
||||
}
|
||||
$('#layered_'+slider['type']+'_range').html(from+' - '+to);
|
||||
});
|
||||
}
|
||||
|
||||
function initLayered()
|
||||
{
|
||||
initSliders();
|
||||
initLocationChange();
|
||||
updateProductUrl();
|
||||
if (window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
|
||||
{
|
||||
var params = window.location.href.split('#')[1];
|
||||
reloadContent('&selected_filters='+params);
|
||||
}
|
||||
}
|
||||
|
||||
function paginationButton() {
|
||||
$('div.pagination a').not(':hidden').each(function () {
|
||||
if ($(this).attr('href').search('&p=') == -1) {
|
||||
var page = 1;
|
||||
}
|
||||
else {
|
||||
var page = $(this).attr('href').replace(/^.*&p=(\d+).*$/, '$1');
|
||||
}
|
||||
var location = window.location.href.replace(/#.*$/, '');
|
||||
$(this).attr('href', location+current_friendly_url.replace(/\/page-(\d+)/, '')+'/page-'+page);
|
||||
});
|
||||
$('div.pagination li').not('.current, .disabled').each(function () {
|
||||
var nbPage = 0;
|
||||
if ($(this).hasClass('pagination_next'))
|
||||
nbPage = parseInt($('div.pagination li.current').children().html())+ 1;
|
||||
else if ($(this).hasClass('pagination_previous'))
|
||||
nbPage = parseInt($('div.pagination li.current').children().html())- 1;
|
||||
|
||||
$(this).children().click(function () {
|
||||
if (nbPage == 0)
|
||||
p = parseInt($(this).html()) + parseInt(nbPage);
|
||||
else
|
||||
p = nbPage;
|
||||
p = '&p='+ p;
|
||||
reloadContent(p);
|
||||
nbPage = 0;
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function cancelFilter()
|
||||
{
|
||||
$('#enabled_filters a').live('click', function(e)
|
||||
{
|
||||
if ($(this).attr('rel').search(/_slider$/) > 0)
|
||||
{
|
||||
if ($('#'+$(this).attr('rel')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel')).slider('values' , 0, $('#'+$(this).attr('rel')).slider('option' , 'min' ));
|
||||
$('#'+$(this).attr('rel')).slider('values' , 1, $('#'+$(this).attr('rel')).slider('option' , 'max' ));
|
||||
$('#'+$(this).attr('rel')).slider('option', 'slide')(0,{values:[$('#'+$(this).attr('rel')).slider( 'option' , 'min' ), $('#'+$(this).attr('rel')).slider( 'option' , 'max' )]});
|
||||
}
|
||||
else if($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).attr('limitValue'));
|
||||
$('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).attr('limitValue'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($('option#'+$(this).attr('rel')).length)
|
||||
{
|
||||
$('#'+$(this).attr('rel')).parent().val('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+$(this).attr('rel')).attr('checked', false);
|
||||
$('.'+$(this).attr('rel')).attr('checked', false);
|
||||
$('#layered_form input[type=hidden][name='+$(this).attr('rel')+']').remove();
|
||||
}
|
||||
}
|
||||
reloadContent();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
function openCloseFilter()
|
||||
{
|
||||
$('#layered_form span.layered_close a').live('click', function(e)
|
||||
{
|
||||
if ($(this).html() == '<')
|
||||
{
|
||||
$('#'+$(this).attr('rel')).show();
|
||||
$(this).html('v');
|
||||
$(this).parent().removeClass('closed');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+$(this).attr('rel')).hide();
|
||||
$(this).html('<');
|
||||
$(this).parent().addClass('closed');
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
function stopAjaxQuery() {
|
||||
if (typeof(ajaxQueries) == 'undefined')
|
||||
ajaxQueries = new Array();
|
||||
for(i = 0; i < ajaxQueries.length; i++)
|
||||
ajaxQueries[i].abort();
|
||||
ajaxQueries = new Array();
|
||||
}
|
||||
|
||||
function reloadContent(params_plus)
|
||||
{
|
||||
stopAjaxQuery();
|
||||
|
||||
if (!ajaxLoaderOn)
|
||||
{
|
||||
$('#product_list').prepend($('#layered_ajax_loader').html());
|
||||
$('#product_list').css('opacity', '0.7');
|
||||
ajaxLoaderOn = 1;
|
||||
}
|
||||
|
||||
data = $('#layered_form').serialize();
|
||||
$('.layered_slider').each( function () {
|
||||
var sliderStart = $(this).slider('values', 0);
|
||||
var sliderStop = $(this).slider('values', 1);
|
||||
if (typeof(sliderStart) == 'number' && typeof(sliderStop) == 'number')
|
||||
data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop;
|
||||
});
|
||||
|
||||
$(['price', 'weight']).each(function(it, sliderType)
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_range_min').length)
|
||||
{
|
||||
data += '&layered_'+sliderType+'_slider='+$('#layered_'+sliderType+'_range_min').val()+'_'+$('#layered_'+sliderType+'_range_max').val();
|
||||
}
|
||||
});
|
||||
|
||||
$('#layered_form .select option').each( function () {
|
||||
if($(this).attr('id') && $(this).parent().val() == $(this).val())
|
||||
{
|
||||
data += '&'+$(this).attr('id') + '=' + $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('.selectProductSort').length && $('.selectProductSort').val())
|
||||
{
|
||||
if ($('.selectProductSort').val().search(/orderby=/) > 0)
|
||||
{
|
||||
// Old ordering working
|
||||
var splitData = [
|
||||
$('.selectProductSort').val().match(/orderby=(\w*)/)[1],
|
||||
$('.selectProductSort').val().match(/orderway=(\w*)/)[1]
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// New working for default theme 1.4 and theme 1.5
|
||||
var splitData = $('.selectProductSort').val().split(':');
|
||||
}
|
||||
data += '&orderby='+splitData[0]+'&orderway='+splitData[1];
|
||||
}
|
||||
if ($('.js-nb_item').length)
|
||||
{
|
||||
data += '&n='+$('.js-nb_item').val();
|
||||
}
|
||||
|
||||
var slideUp = true;
|
||||
if (params_plus == undefined)
|
||||
{
|
||||
params_plus = '';
|
||||
slideUp = false;
|
||||
}
|
||||
|
||||
// Get nb items per page
|
||||
var n = '';
|
||||
$('div.pagination .js-nb_item').children().each(function(it, option) {
|
||||
if (option.selected)
|
||||
n = '&n='+option.value;
|
||||
});
|
||||
|
||||
ajaxQuery = $.ajax(
|
||||
{
|
||||
type: 'GET',
|
||||
url: baseDir + 'modules/blocklayered/blocklayered-ajax.php',
|
||||
data: data+params_plus+n,
|
||||
dataType: 'json',
|
||||
cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example
|
||||
success: function(result)
|
||||
{
|
||||
$('#layered_block_left').replaceWith(utf8_decode(result.filtersBlock));
|
||||
|
||||
$('.category-product-count').html(result.categoryCount);
|
||||
|
||||
if (result.productList)
|
||||
$('#product_list').replaceWith(utf8_decode(result.productList));
|
||||
else
|
||||
$('#product_list').html('');
|
||||
|
||||
$('#product_list').css('opacity', '1');
|
||||
if ($.browser.msie) // Fix bug with IE8 and aliasing
|
||||
$('#product_list').css('filter', '');
|
||||
|
||||
if (result.pagination.search(/[^\s]/) >= 0) {
|
||||
if ($(result.pagination).find('ul.pagination').length)
|
||||
{
|
||||
$('div.pagination').show();
|
||||
$('ul.pagination').each(function () {
|
||||
$(this).replaceWith($(result.pagination).find('ul.pagination'));
|
||||
});
|
||||
}
|
||||
else if (!$('ul.pagination').length)
|
||||
{
|
||||
$('div.pagination').show();
|
||||
$('div.pagination').each(function () {
|
||||
$(this).html($(result.pagination));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('ul.pagination').html('');
|
||||
$('div.pagination').hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('ul.pagination').html('');
|
||||
$('div.pagination').hide();
|
||||
}
|
||||
|
||||
paginationButton();
|
||||
ajaxLoaderOn = 0;
|
||||
|
||||
// On submiting nb items form, relaod with the good nb of items
|
||||
$('div.pagination form').submit(function() {
|
||||
val = $('div.pagination .js-nb_item').val();
|
||||
$('div.pagination .js-nb_item').children().each(function(it, option) {
|
||||
if (option.value == val)
|
||||
$(option).attr('selected', true);
|
||||
else
|
||||
$(option).removeAttr('selected');
|
||||
});
|
||||
// Reload products and pagination
|
||||
reloadContent();
|
||||
return false;
|
||||
});
|
||||
if (typeof(ajaxCart) != "undefined")
|
||||
ajaxCart.overrideButtonsInThePage();
|
||||
|
||||
if (typeof(reloadProductComparison) == 'function')
|
||||
reloadProductComparison();
|
||||
initSliders();
|
||||
|
||||
// Currente page url
|
||||
if (typeof(current_friendly_url) == 'undefined')
|
||||
current_friendly_url = '#';
|
||||
|
||||
// Get all sliders value
|
||||
$(['price', 'weight']).each(function(it, sliderType)
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_slider').length)
|
||||
{
|
||||
// Check if slider is enable & if slider is used
|
||||
if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object')
|
||||
{
|
||||
if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min')
|
||||
|| $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max'))
|
||||
current_friendly_url += '/'+sliderType+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1)
|
||||
}
|
||||
}
|
||||
else if ($('#layered_'+sliderType+'_range_min').length)
|
||||
{
|
||||
current_friendly_url += '/'+sliderType+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val();
|
||||
}
|
||||
});
|
||||
if (current_friendly_url == '#')
|
||||
current_friendly_url = '#/';
|
||||
window.location = current_friendly_url;
|
||||
lockLocationChecking = true;
|
||||
|
||||
if(slideUp)
|
||||
$.scrollTo('#product_list', 400);
|
||||
updateProductUrl();
|
||||
|
||||
$('.hide-action').each(function() {
|
||||
hideFilterValueAction(this);
|
||||
});
|
||||
}
|
||||
});
|
||||
ajaxQueries.push(ajaxQuery);
|
||||
}
|
||||
|
||||
function initLocationChange(func, time)
|
||||
{
|
||||
if(!time) time = 500;
|
||||
var current_friendly_url = getUrlParams();
|
||||
setInterval(function()
|
||||
{
|
||||
if(getUrlParams() != current_friendly_url && !lockLocationChecking)
|
||||
{
|
||||
// Don't reload page if current_friendly_url and real url match
|
||||
if (current_friendly_url.replace(/^#(\/)?/, '') == getUrlParams().replace(/^#(\/)?/, ''))
|
||||
return;
|
||||
|
||||
lockLocationChecking = true;
|
||||
reloadContent('&selected_filters='+getUrlParams().replace(/^#/, ''));
|
||||
}
|
||||
else {
|
||||
lockLocationChecking = false;
|
||||
current_friendly_url = getUrlParams();
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
|
||||
function getUrlParams()
|
||||
{
|
||||
var params = current_friendly_url;
|
||||
if(window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')
|
||||
params = '#'+window.location.href.split('#')[1];
|
||||
return params;
|
||||
}
|
||||
|
||||
function updateProductUrl()
|
||||
{
|
||||
// Adding the filters to URL product
|
||||
if (typeof(param_product_url) != 'undefined' && param_product_url != '' && param_product_url !='#') {
|
||||
$.each($('ul#product_list li.ajax_block_product .product_img_link,'+
|
||||
'ul#product_list li.ajax_block_product h3 a,'+
|
||||
'ul#product_list li.ajax_block_product .product_desc a,'+
|
||||
'ul#product_list li.ajax_block_product .lnk_view'), function() {
|
||||
$(this).attr('href', $(this).attr('href') + param_product_url);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy of the php function utf8_decode()
|
||||
*/
|
||||
function utf8_decode (utfstr) {
|
||||
var res = '';
|
||||
for (var i = 0; i < utfstr.length;) {
|
||||
var c = utfstr.charCodeAt(i);
|
||||
|
||||
if (c < 128)
|
||||
{
|
||||
res += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if((c > 191) && (c < 224))
|
||||
{
|
||||
var c1 = utfstr.charCodeAt(i+1);
|
||||
res += String.fromCharCode(((c & 31) << 6) | (c1 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var c1 = utfstr.charCodeAt(i+1);
|
||||
var c2 = utfstr.charCodeAt(i+2);
|
||||
res += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted price
|
||||
* Copy from tools.js
|
||||
*/
|
||||
function blocklayeredFormatCurrency(price, currencyFormat, currencySign, currencyBlank)
|
||||
{
|
||||
// if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)
|
||||
blank = '';
|
||||
price = parseFloat(price.toFixed(6));
|
||||
price = ps_round(price, priceDisplayPrecision);
|
||||
if (currencyBlank > 0)
|
||||
blank = ' ';
|
||||
if (currencyFormat == 1)
|
||||
return currencySign + blank + blocklayeredFormatNumber(price, priceDisplayPrecision, ',', '.');
|
||||
if (currencyFormat == 2)
|
||||
return (blocklayeredFormatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
|
||||
if (currencyFormat == 3)
|
||||
return (currencySign + blank + blocklayeredFormatNumber(price, priceDisplayPrecision, '.', ','));
|
||||
if (currencyFormat == 4)
|
||||
return (blocklayeredFormatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted number
|
||||
* Copy from tools.js
|
||||
*/
|
||||
function blocklayeredFormatNumber(value, numberOfDecimal, thousenSeparator, virgule)
|
||||
{
|
||||
value = value.toFixed(numberOfDecimal);
|
||||
var val_string = value+'';
|
||||
var tmp = val_string.split('.');
|
||||
var abs_val_string = (tmp.length == 2) ? tmp[0] : val_string;
|
||||
var deci_string = ('0.' + (tmp.length == 2 ? tmp[1] : 0)).substr(2);
|
||||
var nb = abs_val_string.length;
|
||||
|
||||
for (var i = 1 ; i < 4; i++)
|
||||
if (value >= Math.pow(10, (3 * i)))
|
||||
abs_val_string = abs_val_string.substring(0, nb - (3 * i)) + thousenSeparator + abs_val_string.substring(nb - (3 * i));
|
||||
|
||||
if (parseInt(numberOfDecimal) == 0)
|
||||
return abs_val_string;
|
||||
return abs_val_string + virgule + (deci_string > 0 ? deci_string : '00');
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
if (typeof(formatedAddressFieldsValuesList) !== 'undefined')
|
||||
updateAddressesDisplay(true);
|
||||
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 && ($('#multishipping_mode_checkbox:checked').length === 0))
|
||||
{
|
||||
if ($('#multishipping_mode_checkbox:checked').length === 0) {
|
||||
$('#address_invoice_form:visible').hide('fast');
|
||||
}
|
||||
$('ul#address_invoice').html($('ul#address_delivery').html());
|
||||
$('ul#address_invoice li.address_title').html(txtInvoiceTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#address_invoice_form:hidden').show('fast');
|
||||
if ($('#id_address_invoice').val())
|
||||
updateAddressDisplay('invoice');
|
||||
else
|
||||
{
|
||||
$('ul#address_invoice').html($('ul#address_delivery').html());
|
||||
$('ul#address_invoice li.address_title').html(txtInvoiceTitle);
|
||||
}
|
||||
}
|
||||
if(!first_view)
|
||||
{
|
||||
if (orderProcess === 'order')
|
||||
updateAddresses();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateAddressDisplay(addressType)
|
||||
{
|
||||
if (formatedAddressFieldsValuesList.length <= 0)
|
||||
return false;
|
||||
|
||||
var idAddress = parseInt($('#id_address_' + addressType + '').val());
|
||||
buildAddressBlock(idAddress, addressType, $('#address_' + addressType));
|
||||
|
||||
// change update link
|
||||
var link = $('ul#address_' + addressType + ' li.address_update a').attr('href');
|
||||
var expression = /id_address=\d+/;
|
||||
if (link)
|
||||
{
|
||||
link = link.replace(expression, 'id_address=' + idAddress);
|
||||
$('ul#address_' + addressType + ' li.address_update a').attr('href', link);
|
||||
}
|
||||
resizeAddressesBox();
|
||||
}
|
||||
|
||||
function updateAddresses()
|
||||
{
|
||||
var idAddress_delivery = parseInt($('#id_address_delivery').val());
|
||||
var idAddress_invoice = $('input[type=checkbox]#addressesAreEquals:checked').length === 1 ? idAddress_delivery : parseInt($('#id_address_invoice').val());
|
||||
|
||||
if(isNaN(idAddress_delivery) == false && isNaN(idAddress_invoice) == false)
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseUri + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: {
|
||||
processAddress: true,
|
||||
step: 2,
|
||||
ajax: 'true',
|
||||
controller: 'order',
|
||||
'multi-shipping': $('#id_address_delivery:hidden').length,
|
||||
id_address_delivery: idAddress_delivery,
|
||||
id_address_invoice: idAddress_invoice,
|
||||
token: static_token
|
||||
},
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
resizeAddressesBox();
|
||||
}
|
||||
@@ -0,0 +1,868 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function updateCarrierList(json)
|
||||
{
|
||||
var html = json.carrier_block;
|
||||
|
||||
// @todo check with theme 1.4
|
||||
//if ($('#HOOK_EXTRACARRIER').length == 0 && json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined)
|
||||
// html += json.HOOK_EXTRACARRIER;
|
||||
|
||||
$('#carrier_area').replaceWith(html);
|
||||
bindInputs();
|
||||
/* update hooks for carrier module */
|
||||
$('#HOOK_BEFORECARRIER').html(json.HOOK_BEFORECARRIER);
|
||||
}
|
||||
|
||||
function updatePaymentMethods(json)
|
||||
{
|
||||
$('#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
|
||||
$('#opc_payment_methods-content #HOOK_PAYMENT').html(json.HOOK_PAYMENT);
|
||||
}
|
||||
|
||||
function updatePaymentMethodsDisplay()
|
||||
{
|
||||
var checked = '';
|
||||
if ($('#cgv:checked').length !== 0)
|
||||
checked = 1;
|
||||
else
|
||||
checked = 0;
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow', function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
updatePaymentMethods(json);
|
||||
}
|
||||
});
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function updateAddressSelection()
|
||||
{
|
||||
var idAddress_delivery = ($('#opc_id_address_delivery').length == 1 ? $('#opc_id_address_delivery').val() : $('#id_address_delivery').val());
|
||||
var idAddress_invoice = ($('#opc_id_address_invoice').length == 1 ? $('#opc_id_address_invoice').val() : ($('#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : idAddress_delivery)));
|
||||
|
||||
$('#opc_account-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'allow_refresh=1&ajax=true&method=updateAddressesSelected&id_address_delivery=' + idAddress_delivery + '&id_address_invoice=' + idAddress_invoice + '&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
// Update all product keys with the new address id
|
||||
$('#cart_summary .address_'+deliveryAddress).each(function() {
|
||||
$(this)
|
||||
.removeClass('address_'+deliveryAddress)
|
||||
.addClass('address_'+idAddress_delivery);
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
if ($(this).find('.cart_unit span').length > 0 && $(this).find('.cart_unit span').attr('id').length > 0)
|
||||
$(this).find('.cart_unit span').attr('id', $(this).find('.cart_unit span').attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
|
||||
if ($(this).find('.cart_total span').length > 0 && $(this).find('.cart_total span').attr('id').length > 0)
|
||||
$(this).find('.cart_total span').attr('id', $(this).find('.cart_total span').attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
|
||||
if ($(this).find('.cart_quantity_input').length > 0 && $(this).find('.cart_quantity_input').attr('name').length > 0)
|
||||
{
|
||||
var name = $(this).find('.cart_quantity_input').attr('name')+'_hidden';
|
||||
$(this).find('.cart_quantity_input').attr('name', $(this).find('.cart_quantity_input').attr('name').replace(/_\d+$/, '_'+idAddress_delivery));
|
||||
if ($(this).find('[name='+name+']').length > 0)
|
||||
$(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_delete')
|
||||
.attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_down')
|
||||
.attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
|
||||
if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0)
|
||||
{
|
||||
$(this).find('.cart_quantity_up')
|
||||
.attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
|
||||
.attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
|
||||
}
|
||||
});
|
||||
|
||||
// Update global var deliveryAddress
|
||||
deliveryAddress = idAddress_delivery;
|
||||
if (window.ajaxCart !== undefined)
|
||||
{
|
||||
$('#cart_block_list dd, #cart_block_list dt').each(function(){
|
||||
if (typeof($(this).attr('id')) != 'undefined')
|
||||
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + idAddress_delivery));
|
||||
});
|
||||
}
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(jsonData.gift_price);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCarrierListAndUpdate()
|
||||
{
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getCarrierList&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
updateCarrierList(jsonData);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierSelectionAndGift()
|
||||
{
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
if ($(this).prop('checked'))
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&';
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
if ($('input#gift:checked').length)
|
||||
{
|
||||
gift = 1;
|
||||
giftMessage = encodeURIComponent($('#gift_message').val());
|
||||
}
|
||||
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
refreshDeliveryOptions();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmFreeOrder()
|
||||
{
|
||||
if ($('#opc_new_account-overlay').length !== 0)
|
||||
$('#opc_new_account-overlay').fadeIn('slow');
|
||||
else
|
||||
$('#opc_account-overlay').fadeIn('slow');
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$('#confirmOrder').attr('disabled', 'disabled');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "html",
|
||||
data: 'ajax=true&method=makeFreeOrder&token=' + static_token ,
|
||||
success: function(html)
|
||||
{
|
||||
$('#confirmOrder').attr('disabled', '');
|
||||
var array_split = html.split(':');
|
||||
if (array_split[0] == 'freeorder')
|
||||
{
|
||||
if (isGuest)
|
||||
document.location.href = guestTrackingUrl+'?id_order='+encodeURIComponent(array_split[1])+'&email='+encodeURIComponent(array_split[2]);
|
||||
else
|
||||
document.location.href = historyUrl;
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to confirm the order \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveAddress(type)
|
||||
{
|
||||
if (type !== 'delivery' && type !== 'invoice')
|
||||
return false;
|
||||
|
||||
var params = 'firstname='+encodeURIComponent($('#firstname'+(type == 'invoice' ? '_invoice' : '')).val())+'&lastname='+encodeURIComponent($('#lastname'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'company='+encodeURIComponent($('#company'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'vat_number='+encodeURIComponent($('#vat_number'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'dni='+encodeURIComponent($('#dni'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'address1='+encodeURIComponent($('#address1'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'address2='+encodeURIComponent($('#address2'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'postcode='+encodeURIComponent($('#postcode'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'city='+encodeURIComponent($('#city'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'id_country='+encodeURIComponent($('#id_country'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
if ($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val())
|
||||
params += 'id_state='+encodeURIComponent($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'other='+encodeURIComponent($('#other'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'phone='+encodeURIComponent($('#phone'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
params += 'alias='+encodeURIComponent($('#alias'+(type == 'invoice' ? '_invoice' : '')).val())+'&';
|
||||
if (type == 'delivery' && $('#opc_id_address_delivery').val() != undefined && parseInt($('#opc_id_address_delivery').val()) > 0)
|
||||
params += 'opc_id_address_delivery='+encodeURIComponent($('#opc_id_address_delivery').val())+'&';
|
||||
if (type == 'invoice' && $('#opc_id_address_invoice').val() != undefined && parseInt($('#opc_id_address_invoice').val()) > 0)
|
||||
params += 'opc_id_address_invoice='+encodeURIComponent($('#opc_id_address_invoice').val())+'&';
|
||||
// Clean the last &
|
||||
params = params.substr(0, params.length-1);
|
||||
|
||||
var result = false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: addressUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&submitAddress=true&type='+type+'&'+params+'&token=' + static_token,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
{
|
||||
i = i+1;
|
||||
tmp += '<li>'+jsonData.errors[error]+'</li>';
|
||||
}
|
||||
tmp += '</ol>';
|
||||
var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
|
||||
$('#opc_account_errors').slideUp('fast', function(){
|
||||
$(this).html(errors).slideDown('slow', function(){
|
||||
$.scrollTo('#opc_account_errors', 800);
|
||||
});
|
||||
});
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update addresses id
|
||||
$('input#opc_id_address_delivery').val(jsonData.id_address_delivery);
|
||||
$('input#opc_id_address_invoice').val(jsonData.id_address_invoice);
|
||||
result = true;
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function updateNewAccountToAddressBlock()
|
||||
{
|
||||
$('#opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=getAddressBlockAndCarriersAndPayments&token=' + static_token ,
|
||||
success: function(json)
|
||||
{
|
||||
isLogged = 1;
|
||||
if (json.no_address == 1)
|
||||
document.location.href = addressUrl;
|
||||
|
||||
$('#opc_new_account').fadeOut('fast', function() {
|
||||
$('#opc_new_account').html(json.order_opc_adress);
|
||||
// update block user info
|
||||
if (json.block_user_info !== '' && $('#header_user').length == 1)
|
||||
{
|
||||
var elt = $(json.block_user_info).find('#header_user_info').html();
|
||||
$('#header_user_info').fadeOut('nortmal', function() {
|
||||
$(this).html(elt).fadeIn();
|
||||
});
|
||||
}
|
||||
$('#opc_new_account').fadeIn('fast', function() {
|
||||
//After login, the products are automatically associated to an address
|
||||
$.each(json.summary.products, function() {
|
||||
updateAddressId(this.id_product, this.id_product_attribute, '0', this.id_address_delivery);
|
||||
});
|
||||
updateAddressesDisplay(true);
|
||||
updateCarrierList(json.carrier_data);
|
||||
updateCarrierSelectionAndGift();
|
||||
updatePaymentMethods(json);
|
||||
if ($('#gift-price').length == 1)
|
||||
$('#gift-price').html(json.gift_price);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT
|
||||
if ((!isLogged) || (isGuest))
|
||||
{
|
||||
if (guestCheckoutEnabled && !isLogged)
|
||||
{
|
||||
$('#opc_account_choice').show();
|
||||
$('#opc_account_form, #opc_invoice_address').hide();
|
||||
|
||||
$('#opc_createAccount').click(function() {
|
||||
$('.is_customer_param').show();
|
||||
$('#opc_account_form').slideDown('slow');
|
||||
$('#is_new_customer').val('1');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
$('#opc_guestCheckout').click(function() {
|
||||
$('.is_customer_param').hide();
|
||||
$('#opc_account_form').slideDown('slow');
|
||||
$('#is_new_customer').val('0');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
$('#new_account_title').html(txtInstantCheckout);
|
||||
$('#submitAccount').prop({id : 'submitGuestAccount', name : 'submitGuestAccount'});
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
}
|
||||
else if (isGuest)
|
||||
{
|
||||
$('.is_customer_param').hide();
|
||||
$('#opc_account_form').show('slow');
|
||||
$('#is_new_customer').val('0');
|
||||
$('#opc_account_choice, #opc_invoice_address').hide();
|
||||
$('#new_account_title').html(txtInstantCheckout);
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#opc_account_choice').hide();
|
||||
$('#is_new_customer').val('1');
|
||||
$('.is_customer_param, #opc_account_form').show();
|
||||
$('#opc_invoice_address').hide();
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
}
|
||||
|
||||
// LOGIN FORM
|
||||
$('#openLoginFormBlock').click(function() {
|
||||
$('#openNewAccountBlock').show();
|
||||
$(this).hide();
|
||||
$('#login_form_content').slideDown('slow');
|
||||
$('#new_account_form_content').slideUp('slow');
|
||||
return false;
|
||||
});
|
||||
// LOGIN FORM SENDING
|
||||
$('#SubmitLogin').click(function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: authenticationUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#login_passwd').val())+'&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += '<li>'+jsonData.errors[error]+'</li>';
|
||||
errors += '</ol>';
|
||||
$('#opc_login_errors').html(errors).slideDown('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
// update token
|
||||
static_token = jsonData.token;
|
||||
updateNewAccountToAddressBlock();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// INVOICE ADDRESS
|
||||
$('#invoice_address').click(function() {
|
||||
bindCheckbox();
|
||||
});
|
||||
|
||||
// VALIDATION / CREATION AJAX
|
||||
$('#submitAccount').click(function() {
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
|
||||
|
||||
var callingFile = '';
|
||||
var params = '';
|
||||
|
||||
if (parseInt($('#opc_id_customer').val()) == 0)
|
||||
{
|
||||
callingFile = authenticationUrl;
|
||||
params = 'submitAccount=true&';
|
||||
}
|
||||
else
|
||||
{
|
||||
callingFile = orderOpcUrl;
|
||||
params = 'method=editCustomer&';
|
||||
}
|
||||
|
||||
$('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() {
|
||||
if ($(this).is('input[type=checkbox]'))
|
||||
{
|
||||
if ($(this).is(':checked'))
|
||||
params += encodeURIComponent($(this).attr('name'))+'=1&';
|
||||
}
|
||||
else if ($(this).is('input[type=radio]'))
|
||||
{
|
||||
if ($(this).is(':checked'))
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
}
|
||||
else
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
});
|
||||
$('#opc_account_form select:visible').each(function() {
|
||||
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
|
||||
});
|
||||
params += 'customer_lastname='+encodeURIComponent($('#customer_lastname').val())+'&';
|
||||
params += 'customer_firstname='+encodeURIComponent($('#customer_firstname').val())+'&';
|
||||
params += 'alias='+encodeURIComponent($('#alias').val())+'&';
|
||||
params += 'other='+encodeURIComponent($('#other').val())+'&';
|
||||
params += 'is_new_customer='+encodeURIComponent($('#is_new_customer').val())+'&';
|
||||
// Clean the last &
|
||||
params = params.substr(0, params.length-1);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: callingFile + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&'+params+'&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var tmp = '';
|
||||
var i = 0;
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
{
|
||||
i = i+1;
|
||||
tmp += '<li>'+jsonData.errors[error]+'</li>';
|
||||
}
|
||||
tmp += '</ol>';
|
||||
var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
|
||||
$('#opc_account_errors').slideUp('fast', function(){
|
||||
$(this).html(errors).slideDown('slow', function(){
|
||||
$.scrollTo('#opc_account_errors', 800);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#opc_account_errors').slideUp('slow', function(){
|
||||
$(this).html('');
|
||||
});
|
||||
}
|
||||
|
||||
isGuest = parseInt($('#is_new_customer').val()) == 1 ? 0 : 1;
|
||||
// update addresses id
|
||||
if(jsonData.id_address_delivery !== undefined && jsonData.id_address_delivery > 0)
|
||||
$('#opc_id_address_delivery').val(jsonData.id_address_delivery);
|
||||
if(jsonData.id_address_invoice !== undefined && jsonData.id_address_invoice > 0)
|
||||
$('#opc_id_address_invoice').val(jsonData.id_address_invoice);
|
||||
|
||||
if (jsonData.id_customer !== undefined && jsonData.id_customer !== 0 && jsonData.isSaved)
|
||||
{
|
||||
// update token
|
||||
static_token = jsonData.token;
|
||||
|
||||
// It's not a new customer
|
||||
if ($('#opc_id_customer').val() !== '0')
|
||||
if (!saveAddress('delivery'))
|
||||
return false;
|
||||
|
||||
// update id_customer
|
||||
$('#opc_id_customer').val(jsonData.id_customer);
|
||||
|
||||
if ($('#invoice_address:checked').length !== 0)
|
||||
{
|
||||
if (!saveAddress('invoice'))
|
||||
return false;
|
||||
}
|
||||
|
||||
// update id_customer
|
||||
$('#opc_id_customer').val(jsonData.id_customer);
|
||||
|
||||
// force to refresh carrier list
|
||||
if (isGuest)
|
||||
{
|
||||
isLogged = 1;
|
||||
$('#opc_account_saved').fadeIn('slow');
|
||||
$('#submitAccount').hide();
|
||||
updateAddressSelection();
|
||||
}
|
||||
else
|
||||
updateNewAccountToAddressBlock();
|
||||
}
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
bindCheckbox();
|
||||
bindInputs();
|
||||
|
||||
$('#opc_account_form input,select,textarea').change(function() {
|
||||
if ($(this).is(':visible'))
|
||||
{
|
||||
$('#opc_account_saved').fadeOut('slow');
|
||||
$('#submitAccount').show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function bindCheckbox()
|
||||
{
|
||||
if ($('#invoice_address:checked').length > 0)
|
||||
{
|
||||
$('#opc_invoice_address').slideDown('slow');
|
||||
if ($('#company_invoice').val() == '')
|
||||
$('#vat_number_block_invoice').hide();
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
}
|
||||
else
|
||||
$('#opc_invoice_address').slideUp('slow');
|
||||
}
|
||||
|
||||
function bindInputs()
|
||||
{
|
||||
// Order message update
|
||||
$('#message').blur(function() {
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Recyclable checkbox
|
||||
$('#recyclable').click(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Gift checkbox update
|
||||
$('#gift').click(function() {
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
|
||||
// Gift message update
|
||||
$('#gift_message').change(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Term Of Service (TOS)
|
||||
$('#cgv').click(function() {
|
||||
updatePaymentMethodsDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
function multishippingMode(it)
|
||||
{
|
||||
if ($(it).prop('checked'))
|
||||
{
|
||||
$('#address_delivery, .address_delivery').hide();
|
||||
$('#address_invoice').removeClass('alternate_item').addClass('item');
|
||||
$('#multishipping_mode_box').addClass('on');
|
||||
$('.addressesAreEquals').hide();
|
||||
$('#address_invoice_form').show();
|
||||
|
||||
$('#link_multishipping_form').click(function() {return false;});
|
||||
$('.address_add a').attr('href', addressMultishippingUrl);
|
||||
|
||||
$('#link_multishipping_form').fancybox({
|
||||
'transitionIn': 'elastic',
|
||||
'transitionOut': 'elastic',
|
||||
'type': 'ajax',
|
||||
'beforeClose': function()
|
||||
{
|
||||
// Reload the cart
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
data: 'ajax=true&method=cartReload',
|
||||
dataType : 'html',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$('#cart_summary').replaceWith($(data).find('#cart_summary'));
|
||||
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el); } });
|
||||
}
|
||||
});
|
||||
updateCarrierSelectionAndGift();
|
||||
},
|
||||
'beforeLoad': function()
|
||||
{
|
||||
// Removing all ids on the cart to avoid conflic with the new one on the fancybox
|
||||
// This action could "break" the cart design, if css rules use ids of the cart
|
||||
$.each($('#cart_summary *'), function(it, el) {
|
||||
$(el).attr('id', '');
|
||||
});
|
||||
},
|
||||
'onComplete': function()
|
||||
{
|
||||
$('#fancybox-content .cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, false, this.el);} });
|
||||
cleanSelectAddressDelivery();
|
||||
$('#fancybox-content').append($('<div class="multishipping_close_container"><a id="multishipping-close" class="button_large" href="#">' + CloseTxt + '</a></div>'));
|
||||
$('#multishipping-close').click(function() {
|
||||
var newTotalQty = 0;
|
||||
$('#fancybox-content .cart_quantity_input').each(function(){
|
||||
newTotalQty += parseInt($(this).val());
|
||||
});
|
||||
if (newTotalQty !== totalQty) {
|
||||
if(!confirm(QtyChanged)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$.fancybox.close();
|
||||
return false;
|
||||
});
|
||||
totalQty = 0;
|
||||
$('#fancybox-content .cart_quantity_input').each(function(){
|
||||
totalQty += parseInt($(this).val());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#address_delivery, .address_delivery').show();
|
||||
$('#address_invoice').removeClass('item').addClass('alternate_item');
|
||||
$('#multishipping_mode_box').removeClass('on');
|
||||
$('.addressesAreEquals').show();
|
||||
if ($('.addressesAreEquals').find('input:checked').length)
|
||||
$('#address_invoice_form').hide();
|
||||
else
|
||||
$('#address_invoice_form').show();
|
||||
$('.address_add a').attr('href', addressUrl);
|
||||
|
||||
// Disable multi address shipping
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax=true&method=noMultiAddressDelivery'
|
||||
});
|
||||
|
||||
// Reload the cart
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'ajax=true&method=cartReload',
|
||||
dataType : 'html',
|
||||
success: function(data) {
|
||||
$('#cart_summary').replaceWith($(data).find('#cart_summary'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// If the multishipping mode is off assure us the checkbox "I want to specify a delivery address for each products I order." is unchecked.
|
||||
$('#multishipping_mode_checkbox').attr('checked', false);
|
||||
// If the multishipping mode is on, check the box "I want to specify a delivery address for each products I order.".
|
||||
if (typeof(multishipping_mode) !== 'undefined' && multishipping_mode)
|
||||
{
|
||||
$('#multishipping_mode_checkbox').click();
|
||||
$('.addressesAreEquals').hide().find('input').attr('checked', false);
|
||||
}
|
||||
if (typeof(open_multishipping_fancybox) !== 'undefined' && open_multishipping_fancybox)
|
||||
$('#link_multishipping_form').click();
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
$('document').ready(function(){
|
||||
reloadProductComparison();
|
||||
});
|
||||
|
||||
reloadProductComparison = function() {
|
||||
$('a.cmp_remove').click(function(){
|
||||
|
||||
var idProduct = $(this).attr('rel').replace('ajax_id_product_', '');
|
||||
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||
async: false,
|
||||
cache: false,
|
||||
success: function(){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('input:checkbox.comparator').click(function(){
|
||||
|
||||
var idProduct = $(this).attr('value').replace('comparator_item_', '');
|
||||
var checkbox = $(this);
|
||||
|
||||
if(checkbox.is(':checked'))
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=add&id_product=' + idProduct,
|
||||
async: true,
|
||||
cache: false,
|
||||
success: function(data){
|
||||
if (data === '0')
|
||||
{
|
||||
checkbox.attr('checked', false);
|
||||
alert(max_item);
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
checkbox.attr('checked', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$.ajax({
|
||||
url: 'index.php?controller=products-comparison&ajax=1&action=remove&id_product=' + idProduct,
|
||||
async: true,
|
||||
cache: false,
|
||||
success: function(data){
|
||||
if (data === '0')
|
||||
checkbox.attr('checked', true);
|
||||
},
|
||||
error: function(){
|
||||
checkbox.attr('checked', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
nb_move_available = null;
|
||||
current_move = 0;
|
||||
next_scene_is_at_right = true;
|
||||
|
||||
function loadScene(id_scene){
|
||||
$('#scenes').find('.screen_scene:visible').fadeTo(300, 0, function(){
|
||||
$(this).hide();
|
||||
$('#scenes').find('#screen_scene_' + id_scene).css('opacity', '0').show().fadeTo(500, 1);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSceneMove(){
|
||||
if (next_scene_is_at_right) current_move++;
|
||||
else current_move--;
|
||||
if (current_move === nb_move_available - 1) $('#scenes .next').fadeOut();
|
||||
else $('#scenes .next:hidden').fadeIn().css('display','block');
|
||||
if (current_move === 0) $('#scenes .prev').fadeOut().css('display','block');
|
||||
else $('#scenes .prev').fadeIn().css('display','block');
|
||||
return true;
|
||||
}
|
||||
|
||||
$(function () {
|
||||
/* calcul nb of click to see every scenes */
|
||||
var ul_width = parseInt($('#scenes_list ul').width());
|
||||
var div_width = parseInt($('#scenes_list').width());
|
||||
nb_move_available = Math.ceil((ul_width-div_width)/li_width)+1;
|
||||
if (nb_move_available < 2)
|
||||
$('#scenes .next').hide();
|
||||
|
||||
/* set cluetip parameters */
|
||||
$('a.cluetip')
|
||||
.cluetip({
|
||||
local:true,
|
||||
cursor: 'pointer',
|
||||
attribute:'accesskey',
|
||||
cluetipClass: 'product_scene',
|
||||
dropShadow: false,
|
||||
dropShadowSteps: 0,
|
||||
showTitle: false,
|
||||
tracking: true,
|
||||
sticky: false,
|
||||
mouseOutClose: true,
|
||||
closeText: i18n_scene_close,
|
||||
fx: {
|
||||
open: 'fadeIn',
|
||||
openSpeed: 'fast'
|
||||
}
|
||||
})
|
||||
.css('opacity', 0.8);
|
||||
|
||||
/* set serialscroll parameters */
|
||||
$('#scenes_list').serialScroll({
|
||||
items:'a',
|
||||
duration:1000,
|
||||
lock:false,
|
||||
axis:'x',
|
||||
cycle:false,
|
||||
force:true,
|
||||
lazy:true,
|
||||
step:1,
|
||||
onBefore:onSceneMove
|
||||
});
|
||||
$('#scenes_list').trigger( 'goto', 0);
|
||||
|
||||
});
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function initMarkers()
|
||||
{
|
||||
searchUrl += '?ajax=1&all=1';
|
||||
downloadUrl(searchUrl, function(data) {
|
||||
var xml = parseXml(data);
|
||||
var markerNodes = xml.documentElement.getElementsByTagName('marker');
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
for (var i = 0; i < markerNodes.length; i++)
|
||||
{
|
||||
var name = markerNodes[i].getAttribute('name');
|
||||
var address = markerNodes[i].getAttribute('address');
|
||||
var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
|
||||
var other = markerNodes[i].getAttribute('other');
|
||||
var id_store = markerNodes[i].getAttribute('id_store');
|
||||
var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
|
||||
var latlng = new google.maps.LatLng(
|
||||
parseFloat(markerNodes[i].getAttribute('lat')),
|
||||
parseFloat(markerNodes[i].getAttribute('lng')));
|
||||
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
||||
bounds.extend(latlng);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchLocations()
|
||||
{
|
||||
$('#stores_loader').show();
|
||||
var address = document.getElementById('addressInput').value;
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
geocoder.geocode({address: address}, function(results, status) {
|
||||
if (status === google.maps.GeocoderStatus.OK)
|
||||
searchLocationsNear(results[0].geometry.location);
|
||||
else
|
||||
alert(address+' '+translation_6);
|
||||
$('#stores_loader').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function clearLocations(n)
|
||||
{
|
||||
infoWindow.close();
|
||||
for (var i = 0; i < markers.length; i++)
|
||||
markers[i].setMap(null);
|
||||
|
||||
markers.length = 0;
|
||||
|
||||
locationSelect.innerHTML = '';
|
||||
var option = document.createElement('option');
|
||||
option.value = 'none';
|
||||
if (!n)
|
||||
option.innerHTML = translation_1;
|
||||
else
|
||||
{
|
||||
if (n === 1)
|
||||
option.innerHTML = '1'+' '+translation_2;
|
||||
else
|
||||
option.innerHTML = n+' '+translation_3;
|
||||
}
|
||||
locationSelect.appendChild(option);
|
||||
$('#stores-table tr.node').remove();
|
||||
}
|
||||
|
||||
function searchLocationsNear(center)
|
||||
{
|
||||
var radius = document.getElementById('radiusSelect').value;
|
||||
var searchUrl = baseUri+'?controller=stores&ajax=1&latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;
|
||||
downloadUrl(searchUrl, function(data) {
|
||||
var xml = parseXml(data);
|
||||
var markerNodes = xml.documentElement.getElementsByTagName('marker');
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
|
||||
clearLocations(markerNodes.length);
|
||||
for (var i = 0; i < markerNodes.length; i++)
|
||||
{
|
||||
var name = markerNodes[i].getAttribute('name');
|
||||
var address = markerNodes[i].getAttribute('address');
|
||||
var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
|
||||
var other = markerNodes[i].getAttribute('other');
|
||||
var distance = parseFloat(markerNodes[i].getAttribute('distance'));
|
||||
var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
|
||||
var phone = markerNodes[i].getAttribute('phone');
|
||||
var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
|
||||
var latlng = new google.maps.LatLng(
|
||||
parseFloat(markerNodes[i].getAttribute('lat')),
|
||||
parseFloat(markerNodes[i].getAttribute('lng')));
|
||||
|
||||
createOption(name, distance, i);
|
||||
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
||||
bounds.extend(latlng);
|
||||
|
||||
$('#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+'</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, 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_store);
|
||||
var marker = '';
|
||||
|
||||
if (hasStoreIcon)
|
||||
marker = new google.maps.Marker({ map: map, icon: image, position: latlng });
|
||||
else
|
||||
marker = new google.maps.Marker({ map: map, position: latlng });
|
||||
google.maps.event.addListener(marker, 'click', function() {
|
||||
infoWindow.setContent(html);
|
||||
infoWindow.open(map, marker);
|
||||
});
|
||||
markers.push(marker);
|
||||
}
|
||||
|
||||
function createOption(name, distance, num)
|
||||
{
|
||||
var option = document.createElement('option');
|
||||
option.value = num;
|
||||
option.innerHTML = name+' ('+distance.toFixed(1)+' '+distance_unit+')';
|
||||
locationSelect.appendChild(option);
|
||||
}
|
||||
|
||||
function downloadUrl(url, callback)
|
||||
{
|
||||
var request = window.ActiveXObject ?
|
||||
new ActiveXObject('Microsoft.XMLHTTP') :
|
||||
new XMLHttpRequest();
|
||||
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState === 4) {
|
||||
request.onreadystatechange = doNothing;
|
||||
callback(request.responseText, request.status);
|
||||
}
|
||||
};
|
||||
|
||||
request.open('GET', url, true);
|
||||
request.send(null);
|
||||
}
|
||||
|
||||
function parseXml(str)
|
||||
{
|
||||
if (window.ActiveXObject) {
|
||||
var doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||
doc.loadXML(str);
|
||||
return doc;
|
||||
}
|
||||
else if (window.DOMParser) {
|
||||
return (new DOMParser()).parseFromString(str, 'text/xml');
|
||||
}
|
||||
}
|
||||
|
||||
function doNothing() {}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
map = new google.maps.Map(document.getElementById('map'), {
|
||||
center: new google.maps.LatLng(defaultLat, defaultLong),
|
||||
zoom: 10,
|
||||
mapTypeId: 'roadmap',
|
||||
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
|
||||
});
|
||||
infoWindow = new google.maps.InfoWindow();
|
||||
|
||||
locationSelect = document.getElementById('locationSelect');
|
||||
locationSelect.onchange = function() {
|
||||
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
|
||||
if (markerNum !== 'none')
|
||||
google.maps.event.trigger(markers[markerNum], 'click');
|
||||
};
|
||||
|
||||
$('#addressInput').keypress(function(e) {
|
||||
code = e.keyCode ? e.keyCode : e.which;
|
||||
if(code.toString() === 13)
|
||||
searchLocations();
|
||||
});
|
||||
|
||||
|
||||
initMarkers();
|
||||
});
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function ps_round(value, precision)
|
||||
{
|
||||
if (typeof(roundMode) === 'undefined')
|
||||
roundMode = 2;
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 2;
|
||||
|
||||
method = roundMode;
|
||||
if (method === 0)
|
||||
return ceilf(value, precision);
|
||||
else if (method === 1)
|
||||
return floorf(value, precision);
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
return Math.round(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function ceilf(value, precision)
|
||||
{
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 0;
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
tmp = value * precisionFactor;
|
||||
tmp2 = tmp.toString();
|
||||
if (tmp2[tmp2.length - 1] === 0)
|
||||
return value;
|
||||
return Math.ceil(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function floorf(value, precision)
|
||||
{
|
||||
if (typeof(precision) === 'undefined')
|
||||
precision = 0;
|
||||
precisionFactor = precision === 0 ? 1 : Math.pow(10, precision);
|
||||
tmp = value * precisionFactor;
|
||||
tmp2 = tmp.toString();
|
||||
if (tmp2[tmp2.length - 1] === 0)
|
||||
return value;
|
||||
return Math.floor(value * precisionFactor) / precisionFactor;
|
||||
}
|
||||
|
||||
function formatedNumberToFloat(price, currencyFormat, currencySign)
|
||||
{
|
||||
price = price.replace(currencySign, '');
|
||||
if (currencyFormat === 1)
|
||||
return parseFloat(price.replace(',', '').replace(' ', ''));
|
||||
else if (currencyFormat === 2)
|
||||
return parseFloat(price.replace(' ', '').replace(',', '.'));
|
||||
else if (currencyFormat === 3)
|
||||
return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
|
||||
else if (currencyFormat === 4)
|
||||
return parseFloat(price.replace(',', '').replace(' ', ''));
|
||||
return price;
|
||||
}
|
||||
|
||||
//return a formatted price
|
||||
function formatCurrency(price, currencyFormat, currencySign, currencyBlank)
|
||||
{
|
||||
// if you modified this function, don't forget to modify the PHP function displayPrice (in the Tools.php class)
|
||||
blank = '';
|
||||
price = parseFloat(price.toFixed(6));
|
||||
price = ps_round(price, priceDisplayPrecision);
|
||||
if (currencyBlank > 0)
|
||||
blank = ' ';
|
||||
if (currencyFormat == 1)
|
||||
return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
|
||||
if (currencyFormat == 2)
|
||||
return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
|
||||
if (currencyFormat == 3)
|
||||
return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
|
||||
if (currencyFormat == 4)
|
||||
return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
|
||||
if (currencyFormat == 5)
|
||||
return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.'));
|
||||
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);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$.fn.checkboxChange = function(fnChecked, fnUnchecked) {
|
||||
if ($(this).prop('checked') && fnChecked)
|
||||
fnChecked.call(this);
|
||||
else if(fnUnchecked)
|
||||
fnUnchecked.call(this);
|
||||
|
||||
if (!$(this).attr('eventCheckboxChange'))
|
||||
{
|
||||
$(this).live('change', function() { $(this).checkboxChange(fnChecked, fnUnchecked); });
|
||||
$(this).attr('eventCheckboxChange', true);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// Use it to simulate target blank link
|
||||
$(function(){
|
||||
$('a.js-new-window').click(function(){
|
||||
window.open(this.href);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,63 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
bindStateInputAndUpdate();
|
||||
});
|
||||
|
||||
function bindStateInputAndUpdate()
|
||||
{
|
||||
$('.id_state, .dni, .postcode').css({'display':'none'});
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
|
||||
$('select#id_country').change(function(){
|
||||
updateState();
|
||||
updateNeedIDNumber();
|
||||
updateZipCode();
|
||||
});
|
||||
|
||||
if ($('select#id_country_invoice').length !== 0)
|
||||
{
|
||||
$('select#id_country_invoice').change(function(){
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
});
|
||||
updateState('invoice');
|
||||
updateNeedIDNumber('invoice');
|
||||
updateZipCode('invoice');
|
||||
}
|
||||
}
|
||||
|
||||
function updateState(suffix)
|
||||
{
|
||||
$('select#id_state'+(suffix !== undefined ? '_'+suffix : '')+' option:not(:first-child)').remove();
|
||||
var states = countries[$('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val()];
|
||||
if(typeof(states) !== 'undefined')
|
||||
{
|
||||
$(states).each(function (key, item){
|
||||
$('select#id_state'+(suffix !== undefined ? '_'+suffix : '')).append('<option value="'+item.id+'"'+ (idSelectedCountry === item.id ? ' selected="selected"' : '') + '>'+item.name+'</option>');
|
||||
});
|
||||
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');;
|
||||
}
|
||||
else
|
||||
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
|
||||
function updateNeedIDNumber(suffix)
|
||||
{
|
||||
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
|
||||
if ($.inArray(idCountry, countriesNeedIDNumber) >= 0)
|
||||
$('.dni'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
|
||||
else
|
||||
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
|
||||
function updateZipCode(suffix)
|
||||
{
|
||||
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
|
||||
if (countriesNeedZipCode[idCountry] !== 0)
|
||||
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
|
||||
else
|
||||
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//animate the opening of the branch (span.grower jQueryElement)
|
||||
function openBranch(jQueryElement, noAnimation) {
|
||||
jQueryElement.addClass('OPEN').removeClass('CLOSE');
|
||||
if(noAnimation)
|
||||
jQueryElement.parent().find('ul:first').show();
|
||||
else
|
||||
jQueryElement.parent().find('ul:first').slideDown();
|
||||
}
|
||||
//animate the closing of the branch (span.grower jQueryElement)
|
||||
function closeBranch(jQueryElement, noAnimation) {
|
||||
jQueryElement.addClass('CLOSE').removeClass('OPEN');
|
||||
if(noAnimation)
|
||||
jQueryElement.parent().find('ul:first').hide();
|
||||
else
|
||||
jQueryElement.parent().find('ul:first').slideUp();
|
||||
}
|
||||
|
||||
//animate the closing or opening of the branch (ul jQueryElement)
|
||||
function toggleBranch(jQueryElement, noAnimation) {
|
||||
if(jQueryElement.hasClass('OPEN'))
|
||||
closeBranch(jQueryElement, noAnimation);
|
||||
else
|
||||
openBranch(jQueryElement, noAnimation);
|
||||
}
|
||||
|
||||
//when the page is loaded...
|
||||
$(document).ready(function () {
|
||||
//to do not execute this script as much as it's called...
|
||||
if(!$('ul.tree.dhtml').hasClass('dynamized'))
|
||||
{
|
||||
//add growers to each ul.tree elements
|
||||
$('ul.tree.dhtml ul').prev().before("<span class='grower OPEN'> </span>");
|
||||
|
||||
//dynamically add the '.last' class on each last item of a branch
|
||||
$('ul.tree.dhtml ul li:last-child, ul.tree.dhtml li:last-child').addClass('last');
|
||||
|
||||
//collapse every expanded branch
|
||||
$('ul.tree.dhtml span.grower.OPEN').addClass('CLOSE').removeClass('OPEN').parent().find('ul:first').hide();
|
||||
$('ul.tree.dhtml').show();
|
||||
|
||||
//open the tree for the selected branch
|
||||
$('ul.tree.dhtml .selected').parents().each( function() {
|
||||
if ($(this).is('ul'))
|
||||
toggleBranch($(this).prev().prev(), true);
|
||||
});
|
||||
toggleBranch( $('ul.tree.dhtml .selected').prev(), true);
|
||||
|
||||
//add a fonction on clicks on growers
|
||||
$('ul.tree.dhtml span.grower').click(function(){
|
||||
toggleBranch($(this));
|
||||
});
|
||||
//mark this 'ul.tree' elements as already 'dynamized'
|
||||
$('ul.tree.dhtml').addClass('dynamized');
|
||||
|
||||
$('ul.tree.dhtml').removeClass('dhtml');
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user