/* * 2007-2017 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 ST-themes * @copyright 2007-2017 ST-themes * @license Use, by you or one client for one Prestashop instance. */ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else if (typeof module === 'object' && typeof module.exports === 'object') { factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { var functions = { update_source_code: function(adv_source_code, that){ adv_source_code.val($((typeof(adv_content_only)!=='undefined' && adv_content_only ? '.layered_content' : '.st_banner_block'), that).html().replace(/]*>/g, "").replace(/(?:\r\n|\r|\n)/g, "").replace(/\t/g, "")); }, text_val: function(element, that){ var text_val = element.val(); var target = $(element.data('target'), that); $(element.data('target'), that).html(text_val); if(text_val) target.removeClass('hidden'); else target.addClass('hidden'); }, button_val: function(element, that){ if(element.val()) $(element.data('target'), that).removeClass('hidden-xs-up').html(element.val()).parent('a').attr('title', element.val()); else $(element.data('target'), that).addClass('hidden-xs-up'); }, button_url_val: function(element, that, banner_url_val){ var target = $(element.data('target'), that); var url = element.val(); if(banner_url_val.val() || !url) { if(target.parent('a').length) target.unwrap(); } else { if(target.parent('a').length) target.parent('a').attr('href', url); else target.wrap( ''); } }, banner_url_val: function(element, that, adv_content, button_url_val){ var url = element.val(); if(url){ if(that.find('.style_button').parent('a').length) that.find('.style_button').unwrap(); if(adv_content.parent('a').length) adv_content.parent('a').attr('href', url); else adv_content.wrap( ''); } else{ if(adv_content.parent('a').length) adv_content.unwrap(); // $.each(button_url_val,function(){ var url = $(this).val(); if(url){ var target = $($(this).data('target'), that); if(target.parent('a').length) target.parent('a').attr('href', url); else target.wrap( ''); } else{ //useless var target = $($(this).data('target'), that); if(target.parent('a').length) target.unwrap(); } }); } }, banner_url_title_val: function(element, that){ $('.style_a_wrap', that).attr('title', element.val()); }, color_val: function(element, that){ $(element.data('target'), that).css(element.data("property"), element.val()); }, size_val: function(element, that){ var _val = element.val(); var property = element.data("property"); if(property == 'font-size' && element.data("unit")=='em') _val = Math.round(_val/12*100) / 100; $.each(property.split(' '),function(index, value){ if(element.data(' ') && _val===0) $(element.data('target'), that).css(value, '0'+element.data("unit")); else if(_val) $(element.data('target'), that).css(value, _val+element.data("unit")); else $(element.data('target'), that).css(value, ''); }); if(property == 'height' && element.data("line-height")) $(element.data('target'), that).css('line-height', (_val-parseInt(element.data("line-height")))+element.data("unit")); }, width_val: function(element, that){ var _val = parseInt(element.val()); $(element.data('target'), that).removeClass('width_100 width_90 width_80 width_70 width_60 width_50 width_40 width_30 width_20 width_10 width_91 width_81 width_71 width_61 width_51 width_41 width_31 width_21 width_11 width_92 width_82 width_72 width_62 width_52 width_42 width_32 width_22 width_12').addClass('width_'+_val); }, font_val: function(element, that, googleFontsJson){ var identi = element.attr('id'); var selected_font = element.val(); var font_weight = font_style = 'normal'; var variant_dom = $('#'+identi+'_weight').empty(); if(selected_font) { if(!$('#'+identi+'_link').size()) $('head').append(''); var cf_key = selected_font.replace(/\s/g, '_'); var variant = ''; $.each(googleFontsJson[cf_key]['variants'], function(i,n){ var option_dom = $('