bebeboutik/modules/soflexibilite/js/configuration.js
Marion Muszynski ffbb3232b9 modif soflex
2016-05-09 17:43:57 +02:00

180 lines
6.2 KiB
JavaScript

/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from Common-Services Co., Ltd.
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe Common-Services Co., Ltd.
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la Common-Services Co. Ltd. est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @package So Colissimo Flexibilite
* @author Alexandre D.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @license Commercial license
* Support by mail : support.soflexibilite@common-services.com
*/
$(document).ready(function() {
function DisplayPrice(obj)
{
var price = obj.val();
if (price <= 0 || !price)
return;
price = parseFloat(price.replace(',', '.'));
if (isNaN(price))
price = 0;
price = price.toFixed(2);
obj.val(price);
}
$('.insurrance_conf').blur(function() {
DisplayPrice($(this));
});
$('#soflex_ws_checker').click(function() {
if (window.console)
console.log('Checking Web Service');
$('#wsFail, #wsSuccess').hide();
$('#soflex_ws_checker span').hide();
$('#soflex_ws_checker img').show();
$.ajax({
type: 'POST',
url: $('#soflexibilite_point_list_url').val(),
dataType: 'jsonp',
data: {
login : $('#user_login').val(),
pwd : $('#user_pwd').val(),
ws : $('#soflex_ws').val()
},
success: function(data) {
/*if (window.console)
console.log(data);*/
if ( data.status === true )
$('#wsSuccess').fadeIn('slow');
else
{
$('#wsFail').fadeIn('slow');
$('#ws_error_code').text(data.error_id);
$('#ws_error_msg').text(data.error);
}
$('#soflex_ws_checker span').show();
$('#soflex_ws_checker img').hide();
},
error: function(data) {
/*if (window.console)
console.log(data);*/
$('#wsFail').fadeIn('slow').prepend(data.responseText);
$('#soflex_ws_checker span').show();
$('#soflex_ws_checker img').hide();
}
});
});
$('#set_shipping_cost').click(function() {
if (!$('#soflexibilite_set_shiiping_cost_modal').length && confirm($('#soflexibilite_set_shiiping_cost_warning').val()))
setShippingCost();
});
$('#set_shipping_cost_modal_action').click(function () {
$('#soflexibilite_set_shiiping_cost_modal').modal('hide');
setShippingCost();
});
function setShippingCost() {
$('#set_shipping_yes, #set_shipping_no').hide();
$('#set_shipping_cost span').hide();
$('#set_shipping_cost img').show();
var set_shipping_cost_url = $('#soflexibilite_set_shiiping_cost_url').val();
$.ajax({
type: 'POST',
url: set_shipping_cost_url,
dataType: 'jsonp',
success: function(data) {
window.console && console.log(data);
$('#set_shipping_cost span').show();
$('#set_shipping_cost img').hide();
if (data.status === true)
$('#set_shipping_yes').fadeIn('slow');
else
$('#set_shipping_no').fadeIn('slow').find('pre').html(data.output ? data.output : 'N/A');
},
error: function(data) {
window.console && console.log(data);
$('#set_shipping_cost span').show();
$('#set_shipping_cost img').hide();
$('#set_shipping_no').fadeIn('slow').find('pre').html(data.responseText ? data.responseText : 'N/A');
}
});
}
if ($.fn.jquery === '1.11.0' && $('#conf-informations .alert-warning, #conf-informations .alert-danger, #conf-informations .warn, #conf-informations .error').length)
{
$('#menu-informations a').css({
"color": "red",
"font-weight": "bold"
}).find('span').append(' <img src="' + $('#images_url').val() + 'exclamation.png" alt="!" style="vertical-align: super;">');
setTimeout(function(){$('#menu-informations').click();}, 800);
}
$('#psinfo').unbind('click').click(function() {
$('#phpinfo_div').hide();
$('#psinfo_div').toggle();
});
$('#phpinfo').unbind('click').click(function() {
$('#psinfo_div').hide();
$('#phpinfo_div').toggle();
});
// qTip
if (typeof(jQuery.qtip) === 'function')
{
$('label[rel]').each(function () {
var target_glossary_key = $(this).attr('rel');
var target_glossary_div = $('#glossary div.' + target_glossary_key);
if (target_glossary_div && target_glossary_div.length) {
var title = $(this).text() || null;
var content = target_glossary_div.html().trim() || 'N/A';
$(this).addClass('tip').html('<span>' + title + '</span>').find('span').qtip({
content: {
text: content,
title: title
},
hide: {
fixed: true,
delay: 300
}
});
}
});
}
$('#conf-carriers sup')
});