Files
bio-concept-pharma/web/modules/advansedcoupons/views/js/back.js
2019-11-17 19:14:07 +01:00

95 lines
3.3 KiB
JavaScript

/**
* 2007-2016 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 Anastasia Basova <site@web-esse.ru>
* @link http://web-esse.ru/
* @copyright 2007-2018 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 () {
var discount_type = new Array('acc', 'bthd', 'f_ord', 'ord');
for (i in discount_type)
{
toggleVoucherType(discount_type[i]);
toggleCartRuleFilter($('#cr_iscategory_' + discount_type[i]));
toggleCartRuleFilter($('#cr_iscountry_' + discount_type[i]));
$('#country_select_'+discount_type[i]+'_2 option').each(function(i) {
$(this).attr('selected', true);
});
$('#cr_iscategory_' + discount_type[i]).click(function() {toggleCartRuleFilter(this);});
$('#cr_iscountry_' + discount_type[i]).click(function() {toggleCartRuleFilter(this);});
$('#country_select_'+discount_type[i]+'_remove').click(function() {removeCartRuleOption(this);});
$('#country_select_'+discount_type[i]+'_add').click(function() {addCartRuleOption(this);});
//$('input[name=discount_type_' + discount_type[i] + ']').click(function() {toggleVoucherType(discount_type[i]);});
}
$('input[name=discount_type_acc]').click(function () {
toggleVoucherType('acc');
});
$('input[name=discount_type_bthd]').click(function () {
toggleVoucherType('bthd');
});
$('input[name=discount_type_f_ord]').click(function () {
toggleVoucherType('f_ord');
});
$('input[name=discount_type_ord]').click(function () {
toggleVoucherType('ord');
});
});
function toggleVoucherType(id)
{
if ($('input[name=discount_type_'+id+']:checked').val() == 2)
{
$('#discount_value_percentage_' + id).closest('.form-group').hide();
$('.discount_value_' + id).closest('.form-group').show();
}
else
{
$('#discount_value_percentage_' + id).closest('.form-group').show();
$('.discount_value_' + id).closest('.form-group').hide();
}
}
function toggleCartRuleFilter(id)
{
var t_id = $(id).data('idBlock');
if ($(id).prop('checked')) {
$('#'+t_id).show(400);
} else {
$('#'+t_id).hide(200);
}
}
function removeCartRuleOption(item)
{
var id = $(item).attr('id').replace('_remove', '');
$('#' + id + '_2 option:selected').remove().appendTo('#' + id + '_1');
}
function addCartRuleOption(item)
{
var id = $(item).attr('id').replace('_add', '');
$('#' + id + '_1 option:selected').remove().appendTo('#' + id + '_2');
}