/* * 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. */ var googleFontsJson = ''; jQuery(function($){ $('#add_google_font').click(function(){ var font_name = $('#google_font_select').val(); var inputGoogleFontName = $('#google_font_name'); var divGoogleFontName = $('#curr_google_font_name'); var variant = $('#google_font_weight').val(); var style = font_weight = font_style = ''; if (font_name == 0) font_name = 'inherit'; if (!variant) variant = 'regular'; var nameCut = inputGoogleFontName.val().split('¤'); if ($.inArray(font_name+':'+variant, nameCut)==-1) inputGoogleFontName.val(inputGoogleFontName.val() + font_name + ':' + variant + '¤'); var font_weight_arr = variant.match(/\d+/g); var font_style_arr = variant.match(/[^\d]+/g); if(font_weight_arr) font_weight = font_weight_arr[0]; if(font_style_arr) font_style = font_style_arr[0]; style = 'font-family:\''+font_name+'\';'; if (variant == 'regular') { //Cause 400 is the default value. // style += 'font-weight:400;'; } else { if (font_weight) style += 'font-weight:'+font_weight+';'; if (font_style) style += 'font-style:'+font_style+';'; } var identi = font_name.toLowerCase().replace(/\W/g,'_'); if(!$('#'+identi+'_li').size()) divGoogleFontName.append('
  •   style="'+style+'"
  • '); if(!$('#'+identi+'_link').size()) $('head').append(''); }); $('#curr_google_font_name').delegate('.delGoogleFont', 'click', function(){ delGoogleFont($(this).attr('name')); }); if(typeof(googleFontsString)!= 'undefined' && googleFontsString && !googleFontsJson) googleFontsJson = $.parseJSON(googleFontsString); $('#google_font_select').each(function(){ handle_font_change($(this)); return false; }); $('.st_delete_image').click(function(){ var self = $(this); var id_lang = self.data('lang'); var id = self.data('id'); $.getJSON(currentIndex+'&token='+token+'&configure=stbanner&id_st_banner='+id+'&id_lang='+id_lang+'&act=delete_image&ts='+new Date().getTime(), function(json){ if(json.r) { self.parent().siblings('.help-block').find('img').remove(); self.parent().remove(); } else alert('Error'); } ); return false; }); $('.delete_slider_image').click(function(){ var self = $(this); var s_id = self.data('s_id'), s_k = self.data('s_k'); // $.getJSON(currentIndex+'&token='+token+'&configure=stbanner&st_s_id='+s_id+'&st_s_k='+s_k+'&act=delete_slider_image&ts='+new Date().getTime(), function(json){ if(json.r) { self.closest('.image_thumb_block').empty(); } else alert('Error'); } ); return false; }); }); var delGoogleFont = function(id) { var div = $('#curr_google_font_name'); var name = $('#google_font_name'); // Cut hidden fields in array var nameCut = name.val().split('¤'); // Reset all hidden fields name.val(''); div.empty(); for (i in nameCut) { // If empty, error, next if (!nameCut[i]) continue ; // Add to hidden fields no selected products OR add to select field selected product if (nameCut[i] != id) { name.val(name.val()+nameCut[i]+'¤'); var selected_arr = nameCut[i].split(':'); var style = font_weight = font_style = ''; if(selected_arr[1]) { var font_weight_arr = selected_arr[1].match(/\d+/g); var font_style_arr = selected_arr[1].match(/[^\d]+/g); if(font_weight_arr) font_weight = font_weight_arr[0]; if(font_style_arr) font_style = font_style_arr[0]; style = 'font-family:\''+selected_arr[0]+'\';'; if (selected_arr[1] == 'regular') { //Cause 400 is the default value. // style += 'font-weight:400;'; } else { if (font_weight) style += 'font-weight:'+font_weight+';'; if (font_style) style += 'font-style:'+font_style+';'; } } div.append('
  •   style="'+style+'"
  • '); } } return false; }; var handle_font_change = function(that) { var selected_font = $(that).val(); var identi = $(that).attr('id'); var font_weight = font_style = 'normal'; var variant_dom = $('#'+identi.replace('_select','_weight')).empty(); var arr_default = {'700':'700', 'italic':'italic', '700italic':'700italic'}; var default_variant = 'regular'; if(selected_font!=0) { if(!$('#google_font_link').size()) $('head').append(''); var cf_key = selected_font.replace(/\s/g, '_'); var variant = ''; var arr_variants = {}; $.each(googleFontsJson[cf_key]['variants'], function(i,n){ arr_variants[n] = n; }); $.extend(arr_variants, arr_default); $.each(arr_variants, function(i,n){ var option_dom = $('