jQuery(function($) { var reduxOptionSearch = function(){ jQuery('.redux_field_search').typeWatch({ callback:function( searchString ){ searchString = searchString.toLowerCase(); var searchArray = searchString.split(' '); var parent = $(this).parents('.redux-container:first'); var expanded_options = parent.find('.expand_options'); if (searchString != "") { if (!expanded_options.hasClass('expanded')) { expanded_options.click(); parent.find('.redux-main').addClass('redux-search'); } } else { if (expanded_options.hasClass('expanded')) { expanded_options.click(); parent.find('.redux-main').removeClass('redux-search'); } //parent.find('.redux-section-field, .redux-info-field, .redux-notice-field, .redux-container-group, .redux-section-desc, .redux-group-tab h3').show(); if($('.redux-group-tab-link-li.active').length>0){ var rel = $('.redux-group-tab-link-li.active a').attr('data-rel'); var selector = 'div#'+rel+'_section_group'; jQuery(selector).show(); jQuery(selector).css('display','block'); }else{ $('.redux-group-tab-link-li.activeChild').click(); $('div#'+rel+'_section_group').show(); $('#'+rel+'_section_group').css('display','block'); } } parent.find('.redux-field-container').each(function() { if (searchString != "") { parent.find('div.redux-group-tab').css('display','none'); $(this).parents('tr:first').hide(); } else { $(this).parents('tr:first').show(); } }); parent.find('.form-table tr').filter(function () { if(searchString==''){ $('.redux-tab-container').show(); $('.redux-tab-container').each(function(){ $(this).find('.redux-tab-selector:first').click(); }); return false; } var item = $(this); var isMatch = true, text = $(this).find('.redux_field_th').text().toLowerCase(); if ( !text || text == "" ) { return false; } $.each(searchArray, function (i, searchStr) { if (text.indexOf(searchStr) == -1) { isMatch = false; } }); if (isMatch) { $(this).show(); $(this).parents('div.redux-group-tab').css('display','block'); } return isMatch; }).show( function() { }); parent.find('.redux-group-tab').each(function() { if (searchString != "") { $(this).find("div.redux-section-field").each(function(){ var divSectionId = $(this).attr('id'); var splitResult = divSectionId.split("-"); splitResult.splice(1, 0, "table"); var divTableId = splitResult.join("-"); var totalTr = $("#"+divTableId).find('tr:visible').length; if(totalTr==0){ $(this).hide(); } }); } else { $(this).find("div.redux-section-field").each(function(){ var divSectionId = $(this).attr('id'); var splitResult = divSectionId.split("-"); splitResult.splice(1, 0, "table"); var divTableId = splitResult.join("-"); var totalTr = $("#"+divTableId).find('tr:visible').length; if(totalTr>0){ $(this).show(); } }); } }); // parent.find('.redux-group-tab') Closed }, wait:400, highlight:false, captureLength:0 }); } //option panel Section Division var optionSectionDevision = function(){ $('.afw-accordion-header').click(function(){ //Get Cookie Changes if ( $.cookie( "redux_current_section_customize" )){ var allReduxTabs = JSON.parse($.cookie( "redux_current_section_customize" )); }else{ var allReduxTabs = {}; } var section = $(this).attr("id"); section = section.replace("section-","section-table-"); if($("#"+section).is(':visible')){ $("#"+section).hide(); $(this).removeClass("afw-accordion-tab-open").addClass("afw-accordion-tab-close"); allReduxTabs[section] = 'hide'; }else{ $("#"+section).show(); $(this).removeClass("afw-accordion-tab-close").addClass("afw-accordion-tab-open"); allReduxTabs[section] = 'show'; } //Set Cookie Changes $.cookie( 'redux_current_section_customize', JSON.stringify(allReduxTabs), { expires: 7, path: '/' } ); }); //While loading at first time if($('.afw-accordion-header').length>0){ //console.log($.cookie( "redux_current_section_customize" )); if ( $.cookie( "redux_current_section_customize" ) ){ var tabsValue = JSON.parse($.cookie( "redux_current_section_customize" )); }else{ var tabsValue = ""; } $('.afw-accordion-header').each(function(){ var reduxAccordianHeader = $(this); var section = reduxAccordianHeader.attr("id"); section = section.replace("section-","section-table-"); if(tabsValue[section]){ var currentSettings = tabsValue[section]; if(currentSettings=='hide'){ reduxAccordianHeader.removeClass("afw-accordion-tab-open").addClass("afw-accordion-tab-close"); }else if(currentSettings=='show'){ reduxAccordianHeader.removeClass("afw-accordion-tab-close").addClass("afw-accordion-tab-open"); } } if(reduxAccordianHeader.hasClass('afw-accordion-tab-close')){ $("#"+section).hide(); }else if(reduxAccordianHeader.hasClass('afw-accordion-tab-open')){ $("#"+section).show(); } }) } }//Cloesed function = optionSectionDevision var hideReduxLeftTabs = function(){ jQuery('ul.redux-group-menu > li.redux-group-tab-link-li').siblings('.redux-group-tab-link-li').each(function(key,Data){ if(key>3 && jQuery(this).hasClass("otherSectionFields")){ jQuery(this).attr("style","display:none;"); } }); jQuery( '.redux-group-tab-link-a' ).click(function(){ if(jQuery(this).parent('li').hasClass('otherSectionFields')){ jQuery(this).parent('li.otherSectionFields').siblings('li.otherSectionFields').hide(); if(!jQuery(this).parent('li').is(':visible')){ jQuery(this).parent('li').show(); } }else{ jQuery(this).parent('li').siblings('li.otherSectionFields').hide(); jQuery(this).parent('li').siblings('li.active').show(); } }); } var showExtensionTabs = function(){ var currentTab = getQueryStringValue('tabid'); if(currentTab!="" && $("li."+currentTab).length>0){ $("li."+currentTab+" a").click(); } } var switchTextfunc = function(){ var switchText = $('.switch-text'); switchText.each(function(e,v){ if ( $(this).siblings('input').attr('value') == 1 ) { $(this).parent('div.switch-options').find('.switch-text-on').show(); } else if ( $(this).siblings('input').attr('value') == 0 ) { $(this).parent('div.switch-options').find('.switch-text-off').show(); } }); switchText.siblings('label').click(function(){ if ( $(this).siblings('input').attr('value') == 1 ) { $(this).parent().find('.switch-text-on').hide(); $(this).parent().find('.switch-text-off').show(); } else if ( $(this).siblings('input').attr('value') == 0 ) { $(this).parent().find('.switch-text-off').hide(); $(this).parent().find('.switch-text-on').show(); } }); } $(document).ready(function() { if(getQueryStringValue('page')=='amp_options'){ //Tab section implementation optionSectionDevision(); //To Show title on the top; In front of search bar if($( '.redux-group-tab-link-a' ).length){ redux_title_modify(); } //To Hide Leftsidebar option Below Extension hideReduxLeftTabs(); showExtensionTabs(); switchTextfunc(); } var gURL, gAPIkey, disableGFonts; gAPIkey = redux_data.google_font_api_key; disableGFonts = redux_data.amp_google_font_restrict; if(gAPIkey=='' || typeof gAPIkey == 'undefined'){ $('.ampforwp-google-font-restrict').css({'display':'none'}); } // Append data into selects ampforwp_font_generator(); function ampforwp_font_generator() { gAPIkey = redux_data.google_font_api_key; fontswitch = redux_data['ampforwp-google-font-switch']; if(fontswitch != 1){ return; } disableGFonts = redux_data.amp_google_font_restrict; if($("#google_font_api_key").length>0){ $("#google_font_api_key").after(""); } if(gAPIkey=='' || typeof gAPIkey == 'undefined'){ $('.ampforwp-google-font-restrict').css({'display':'none'}); } if ( ! gAPIkey){ gAPIkey = $('#google_font_api_key').val(); } if(gAPIkey=='' || typeof gAPIkey == 'undefined'){ $('#redux_builder_amp-google_font_api_key').append('

Could not connect to API, please double check your API key.

'); $('.ampforwp-google-font-class').css({'display':'none'}); return ; } if(disableGFonts==1){ gAPIkey=''; return; } gURL = "https://www.googleapis.com/webfonts/v1/webfonts?key=" + gAPIkey; if (localStorage.getItem("googlefontapidata") === null) { var gfontData = $.get( gURL ); gfontData.done(function( data ) { localStorage.setItem('googlefontapidata', JSON.stringify(data)); ampforwp_fonts_select_data(data); }); gfontData.fail(function(data) { $('#redux_builder_amp-google_font_api_key').append('

Could not connect to API, please double check your API key.

'); $('.ampforwp-google-font-class').css({'display':'none'}); }); gfontData.always(function(){ amp_font_selector_select_change(); }) }else{ data = localStorage.getItem("googlefontapidata"); ampforwp_fonts_select_data(JSON.parse(data)); amp_font_selector_select_change(); } } function ampforwp_fonts_select_data(data){ if(data && localStorage.getItem("googlefontapidata") != null ){ var values = Object.values(data.items); } var allFonts = []; for (var i = 0; i < values.length; i++) { allFonts.push({fontFamily: values[i].family }); } // Creating a select var s = $('