jQuery(function($){ if (typeof wp != 'undefined' && typeof wp.i18n != 'undefined') { var {__, _x, _n, _nx} = wp.i18n; } else { var __ = _x = _n = _nx = function (s) { return s; }; } function submit_mimic(action, method, input) { 'use strict'; var form; form = $('
', { action: action, method: method, style: 'display: none;' }); if (typeof input !== 'undefined' && input !== null) { $.each(input, function (name, value) { $('', { type: 'hidden', name: name, value: value }).appendTo(form); }); } form.appendTo('body').submit(); } // Coditional rules via attributes WPD.Conditionals.init('div[tabid=1]'); WPD.Conditionals.init('div[tabid=5]'); WPD.Conditionals.init('div[tabid=304]'); WPD.Conditionals.init('div[tabid=404]'); WPD.Conditionals.init('div[tabid=405]'); WPD.Conditionals.init('div[tabid=608]'); // --- Safety check on max_input_vars if ( $('#asp_options_serialized').length > 0 ) { $('form[name="asp_data"]').submit(function(e){ if ( typeof(WD_Helpers.Base64) != "undefined" ) { // Send the back-up form instead, with 1 variable only e.preventDefault(); $('#asp_options_serialized').val( WD_Helpers.Base64.encode($('form[name="asp_data"]').serialize()) ); $('form[name="asp_data_serialized"]').submit(); } }); } // -- Input restrictions for text inputs $('#wpdreams input.wpd-integer-only').on("input keydown keyup mousedown mouseup select contextmenu drop paste", function() { if ( /[^0-9]|^0+(?!$)/g.test($(this).val()) ) { // Filter non-digits from input value. $(this).val( $(this).val().replace(/[^0-9]|^0+(?!$)/g, '') ); } }); // -- Reset search instance to defaults. $('#wpdreams input[name^=reset_][type=button].asp_submit.asp_submit_reset').on('click', function(){ var r = confirm("Are you sure you want to reset the options for this instance to defaults? All changes to this search will be lost!"); if ( r == true) { var name = $(this).attr('name'); var data = { 'asp_sett_nonce': $('#asp_sett_nonce').val() }; data[name] = name; submit_mimic('', 'post', data); } }); // --- SHORTCODES AND GENERATOR --- $('.asp_b_shortcodes_menu').on('click', function(){ $(this).parent().toggleClass('asp_open'); }); function sc_generate() { var items = []; var ratios = []; var sid = $('#wpd_shortcode_modal').attr('sid'); $('#wpd_shortcode_modal ul li').each(function(){ if ( !$(this).hasClass('hiddend') ) { items.push($(this).attr('item')); ratios.push($('input',this).val()); } }); var elements = items.join(','); if ( elements != "" ) elements = " elements='" + elements + "'"; var ratio = ratios.join('%,'); if ( ratio != "" ) ratio = " ratio='" + ratio + "%'"; $('#wpd_shortcode_modal textarea').val('[wd_asp' + elements + ratio + " id=" + sid + "]"); } $('#shortcode_generator').on('click', function(e){ e.preventDefault(); e.stopImmediatePropagation(); sc_generate(); $('#wpd_shortcode_modal').removeClass('hiddend'); $('#wpd_shortcode_modal_bg').css('display', 'block'); }); $('#wpd_shortcode_modal .wpd-modal-close, #wpd_shortcode_modal_bg').on('click', function(){ $('#wpd_shortcode_modal').addClass('hiddend'); $('#wpd_shortcode_modal_bg').css('display', 'none'); }); $('#wpd_shortcode_modal li a.deleteIcon').on('click', function(){ $(this).parent().addClass('hiddend'); $('#wpd_shortcode_modal button[item=' + $(this).parent().attr('item') + ']').removeAttr('disabled'); sc_generate(); }); $('#wpd_shortcode_modal li input').on('change', function(){ $(this).parent().parent().css('width', $(this).val() + "%"); sc_generate(); }); $('#wpd_shortcode_modal .wpd_generated_shortcode button').on('click', function(){ $(this).attr('disabled', 'disabled'); $('#wpd_shortcode_modal li[item=' + $(this).attr('item') + ']').detach().appendTo($("#wpd_shortcode_modal .sortablecontainer .ui-sortable")); $('#wpd_shortcode_modal li[item=' + $(this).attr('item') + ']').removeClass('hiddend'); sc_generate(); }); $("#wpd_shortcode_modal .sortablecontainer .ui-sortable").sortable({}, { update: function (event, ui) {} }).disableSelection(); $("#wpd_shortcode_modal .sortablecontainer .ui-sortable").on('sortupdate', function(event, ui) { sc_generate(); }); $('#wpd_shortcode_modal .wpd_generated_shortcode select').on('change', function(){ var items = ['search', 'settings', 'results']; var _val = $(this).val().split('|'); var elements = _val[0].split(','); var ratios = _val[1].split(','); $('#wpd_shortcode_modal li a.deleteIcon').trigger('click'); $.each(elements, function(i, v) { $('#wpd_shortcode_modal .wpd_generated_shortcode button[item='+ items[v] +']').trigger('click'); $('#wpd_shortcode_modal li[item=' + items[v] + '] input').val(ratios[i]).trigger('change'); }); sc_generate(); }); // -------------------------------- // --------------- Navigate to a tab on specific links ----------------- $(".item a.asp_to_tab").on("click", function(){ var tabid = $(this).attr("tabid"); $('.tabs a[tabid=' + Math.floor( tabid / 100 ) + ']').trigger('click'); $('.tabs a[tabid=' + tabid + ']').trigger('click'); if ( typeof $(this).data('asp-os-highlight') !== 'undefined' ) { $('.asp-os-highlighted').removeClass("asp-os-highlighted"); $("*[name='"+$(this).data('asp-os-highlight')+"']").closest('.item').addClass("asp-os-highlighted"); } }); // ---------------------------------------------------------------------- //var ajaxurl = '' + "/wp-content/plugins/ajax-search-pro/ajax_search.php"; $('.tabs a[tabid=6]').on('click', function() { $('.tabs a[tabid=601]').trigger('click'); }); $('.tabs a[tabid=1]').on('click', function() { $('.tabs a[tabid=101]').trigger('click'); }); $('.tabs a[tabid=2]').on('click', function() { $('.tabs a[tabid=201]').trigger('click'); }); $('.tabs a[tabid=4]').on('click', function() { $('.tabs a[tabid=401]').trigger('click'); }); $('.tabs a[tabid=3]').on('click', function() { $('.tabs a[tabid=301]').trigger('click'); }); $('.tabs a[tabid=5]').on('click', function() { $('.tabs a[tabid=501]').trigger('click'); }); $('.tabs a[tabid=7]').on('click', function() { $('.tabs a[tabid=701]').trigger('click'); }); $('.tabs a[tabid=8]').on('click', function() { $('.tabs a[tabid=801]').trigger('click'); }); $('.tabs a').on('click', function(){ $('#sett_tabid').val($(this).attr('tabid')); location.hash = $(this).attr('tabid'); }); /*$('select[name="cpt_display_mode"]').on('change', function(){ if ($(this).val() == "checkboxes") { $('input[name=cpt_cbx_show_select_all]') .closest('div').removeClass('disabled'); $('select[name="cpt_filter_default"]').attr('disabled', 'disabled'); } else { $('input[name=cpt_cbx_show_select_all]').val(0) .closest('div').addClass('disabled').find('.triggerer').trigger('click'); $('select[name="cpt_filter_default"]').removeAttr('disabled'); } }); $('select[name="cpt_display_mode"]').trigger('change');*/ $('input[name=cpt_cbx_show_select_all]').on('change', function(){ if ($(this).val() == 0) { $('input[name=cpt_cbx_show_select_all_text]').closest('div').addClass('disabled'); } else { $('input[name=cpt_cbx_show_select_all_text]').closest('div').removeClass('disabled'); } }); $('input[name=cpt_cbx_show_select_all]').trigger('change'); $('input[name=cpt_required]').on('change', function(){ if ($(this).val() == 0) { $('input[name=cpt_invalid_input_text]').closest('div').addClass('disabled'); } else { $('input[name=cpt_invalid_input_text]').closest('div').removeClass('disabled'); } }); $('input[name=cpt_required]').trigger('change'); // ---------------------- General/Sources 1 ------------------------ /*$('input[name="search_all_cf"]').on('change', function(){ if ($(this).val() == 1) $('input[name="customfields"]').parent().addClass('disabled'); else $('input[name="customfields"]').parent().removeClass('disabled'); }); $('input[name="search_all_cf"]').trigger('change');*/ // ----------------------------------------------------------------- // ---------------------- General/Behavior ------------------------ /*$('select[name=click_action], select[name=return_action]').on('change', function(){ var redirect = false; var elementor = false; $('select[name=click_action], select[name=return_action]').each(function(i, v) { if ( $(v).val() == 'custom_url' ) { redirect = true; } if ( $(v).val() == 'elementor_page' ) { elementor = true; } }); if ( redirect ) { $('input[name=redirect_url]').closest('.item').removeClass('hiddend'); } else { $('input[name=redirect_url]').closest('.item').addClass('hiddend'); } if ( elementor ) { $('input[name=redirect_elementor]').closest('.item').removeClass('hiddend'); } else { $('input[name=redirect_elementor]').closest('.item').addClass('hiddend'); } var $loc = $('select[name*=_action_location]', $(this).closest('.item')).parent(); if ( $(this).val() == 'ajax_search' || $(this).val() == 'nothing' || $(this).val() == 'same' ) { $loc.addClass('hiddend'); } else{ $loc.removeClass('hiddend'); } }); $('select[name=click_action]').trigger('change'); $('select[name=return_action]').trigger('change');*/ $('select[name=mob_click_action], select[name=mob_return_action]').on('change', function(){ var redirect = false; var elementor = false; $('select[name=mob_click_action], select[name=mob_return_action]').each(function(i, v) { if ( $(v).val() == 'custom_url' ) { redirect = true; } if ( $(v).val() == 'elementor_page' ) { elementor = true; } }); if ( redirect ) { $('input[name=mob_redirect_url]').closest('.item').removeClass('hiddend'); } else { $('input[name=mob_redirect_url]').closest('.item').addClass('hiddend'); } if ( elementor ) { $('input[name=mob_redirect_elementor]').closest('.item').removeClass('hiddend'); } else { $('input[name=mob_redirect_elementor]').closest('.item').addClass('hiddend'); } var $loc = $('select[name*=_action_location]', $(this).closest('.item')).parent(); if ( $(this).val() == 'ajax_search' || $(this).val() == 'nothing' || $(this).val() == 'same' ) { $loc.addClass('hiddend'); } else{ $loc.removeClass('hiddend'); } }); $('select[name=mob_click_action]').trigger('change'); $('select[name=mob_return_action]').trigger('change'); $('input[name="exactonly"]').on('change', function(){ if ($(this).val() == 0 || $('select[name="secondary_kw_logic"]').val() == 'none') { $('input[name="exact_m_secondary"]').val(0); $('input[name="exact_m_secondary"]').closest('div').find('.triggerer').trigger('click'); } }).trigger('change'); $('select[name="secondary_kw_logic"]').on('change', function(){ if ($(this).val() == 'none' || $('input[name="exactonly"]').val() == 0) { $('input[name="exact_m_secondary"]').val(0); $('input[name="exact_m_secondary"]').closest('div').find('.triggerer').trigger('click'); } }).trigger('change'); $('select[name="orderby_primary"]').on('change', function(){ if ($(this).val().indexOf('customf') == -1) { $('input[name="orderby_primary_cf"]').parent().addClass('hiddend'); $('select[name="orderby_primary_cf_type"]').parent().addClass('hiddend'); } else { $('input[name="orderby_primary_cf"]').parent().removeClass('hiddend'); $('select[name="orderby_primary_cf_type"]').parent().removeClass('hiddend'); } }); $('select[name="orderby_primary"]').trigger('change'); $('select[name="orderby_secondary"]').on('change', function(){ if ($(this).val().indexOf('customf') == -1) { $('input[name="orderby_secondary_cf"]').parent().addClass('hiddend'); $('select[name="orderby_secondary_cf_type"]').parent().addClass('hiddend'); } else { $('input[name="orderby_secondary_cf"]').parent().removeClass('hiddend'); $('select[name="orderby_secondary_cf_type"]').parent().removeClass('hiddend'); } }); $('select[name="orderby_secondary"]').trigger('change'); $('input[name="override_default_results"]').on('change', function(){ if ($(this).val() == 0) $('input[name="results_per_page"]').parent().addClass('disabled'); else $('input[name="results_per_page"]').parent().removeClass('disabled'); }); $('input[name="override_default_results"]').trigger('change'); $('input[name=res_live_search]').on('change', function(){ if ($(this).val() == 0) $('input[name="res_live_selector"]').closest('.item').addClass('disabled'); else $('input[name="res_live_selector"]').closest('.item').removeClass('disabled'); }); $('input[name=res_live_search]').trigger('change'); // ----------------------------------------------------------------- // ---------------------- General/User search ---------------------- /* $('select[name="user_orderby_primary"]').on('change', function(){ if ($(this).val().indexOf('customf') == -1) { $('input[name="user_orderby_primary_cf"]').parent().addClass('hiddend'); $('select[name="user_orderby_primary_cf_type"]').parent().addClass('hiddend'); } else { $('input[name="user_orderby_primary_cf"]').parent().removeClass('hiddend'); $('select[name="user_orderby_primary_cf_type"]').parent().removeClass('hiddend'); } }); $('select[name="user_orderby_primary"]').trigger('change'); $('select[name="user_orderby_secondary"]').on('change', function(){ if ($(this).val().indexOf('customf') == -1) { $('input[name="user_orderby_secondary_cf"]').parent().addClass('hiddend'); $('select[name="user_orderby_secondary_cf_type"]').parent().addClass('hiddend'); } else { $('input[name="user_orderby_secondary_cf"]').parent().removeClass('hiddend'); $('select[name="user_orderby_secondary_cf_type"]').parent().removeClass('hiddend'); } }); $('select[name="user_orderby_secondary"]').trigger('change');*/ // ----------------------------------------------------------------- // -------------------- Peepso ------------------------------------- $('input[name=peep_gs_public], input[name=peep_gs_closed], input[name=peep_gs_secret]').on('change', function(){ var enabled = $('input[name=peep_gs_public]').val() == 1 || $('input[name=peep_gs_closed]').val() == 1 || $('input[name=peep_gs_secret]').val() == 1; if ( enabled ) { $('input[name=peep_gs_title]').closest('.item').removeClass('disabled'); $('textarea[name=peep_gs_exclude]').closest('.item').removeClass('disabled'); } else { $('input[name=peep_gs_title]').closest('.item').addClass('disabled'); $('textarea[name=peep_gs_exclude]').closest('.item').addClass('disabled'); } }); $('input[name=peep_gs_public]').trigger('change'); $('input[name=peep_s_posts], input[name=peep_s_comments]').on('change', function(){ var enabled = $('input[name=peep_s_posts]').val() == 1 || $('input[name=peep_s_comments]').val() == 1; if ( enabled ) { $('input[name=peep_pc_follow]').closest('.item').removeClass('disabled'); $('input[name=peep_pc_secret]').closest('.item').removeClass('disabled'); } else { $('input[name=peep_pc_follow]').closest('.item').addClass('disabled'); $('input[name=peep_pc_secret]').closest('.item').addClass('disabled'); } }); $('input[name=peep_s_posts]').trigger('change'); // ----------------------------------------------------------------- // -------------------- Generic Filters ---------------------------- $('select[name=search_engine]').on('change', function() { $('a.asp_be_rel_subtab').addClass('tab_disabled'); if ( $(this).val() == 'index' ) { $('a.asp_be_rel_subtab.asp_be_rel_index').removeClass('tab_disabled'); $('#genericFilterErr').removeClass('hiddend'); } else { $('a.asp_be_rel_subtab.asp_be_rel_regular').removeClass('tab_disabled'); $('#genericFilterErr').addClass('hiddend'); } }); $('select[name=search_engine]').trigger('change'); $('input[name=date_filter_required]').on('change', function(){ if ( $(this).val() == 0 ) { $('input[name=date_filter_invalid_input_text]').closest('div').addClass('disabled'); } else { $('input[name=date_filter_invalid_input_text]').closest('div').removeClass('disabled'); } }).trigger('change'); // ----------------------------------------------------------------- // ----------------------- Date Filters ---------------------------- $('input[name=date_filter_from]').closest('.wd_DateFilter').find('select.wd_di_state').on('change', function(){ if ( $(this).val() == 'disabled' ) { $('input[name=date_filter_from_t]').closest('.item').addClass('disabled'); $('input[name=date_filter_from_format]').closest('.item').addClass('disabled'); } else { $('input[name=date_filter_from_t]').closest('.item').removeClass('disabled'); $('input[name=date_filter_from_format]').closest('.item').removeClass('disabled'); } }).trigger('change'); $('input[name=date_filter_to]').closest('.wd_DateFilter').find('select.wd_di_state').on('change', function(){ if ( $(this).val() == 'disabled' ) { $('input[name=date_filter_to_t]').closest('.item').addClass('disabled'); $('input[name=date_filter_to_format]').closest('.item').addClass('disabled'); } else { $('input[name=date_filter_to_t]').closest('.item').removeClass('disabled'); $('input[name=date_filter_to_format]').closest('.item').removeClass('disabled'); } }).trigger('change'); $('input[name=showsearchintaxonomies]').on('change', function(){ if ( $(this).val() == 0 ) { $(this).closest('div[tabid]').find('>.item').addClass('disabled'); $(this).closest('.item').removeClass('disabled'); } else { $(this).closest('div[tabid]').find('>.item').removeClass('disabled'); } }).trigger('change'); // ----------------------------------------------------------------- // ----------------------------------------------------------------- $('select[name="term_logic"]').on('change', function() { if ( $(this).val() == 'andex' ) $('#term_logic_MSG').removeClass("hiddend"); else $('#term_logic_MSG').addClass("hiddend"); }); $('select[name="term_logic"]').trigger('change'); // ------------------------- Custom Search Button ------------------ $('input[name=fe_search_button]').on('change', function(){ if ( $(this).val() == 0 ) { $('#fe_sb_functionality').addClass('disabled'); $('#fe_search_button').addClass('disabled'); } else { $('#fe_sb_functionality').removeClass('disabled'); $('#fe_search_button').removeClass('disabled'); } }); $('input[name=fe_search_button]').trigger('change'); $('select[name=fe_sb_action]').on('change', function(){ if ( $(this).val() == 'custom_url' ) { $('input[name=fe_sb_redirect_url]').closest('.item').removeClass('hiddend'); } else { $('input[name=fe_sb_redirect_url]').closest('.item').addClass('hiddend'); } if ( $(this).val() == 'elementor_page' ) { $('input[name=fe_sb_redirect_elementor]').closest('.item').removeClass('hiddend'); } else { $('input[name=fe_sb_redirect_elementor]').closest('.item').addClass('hiddend'); } var $loc = $(this).closest('.item').find('select[name=fe_sb_action_location]').parent(); if ( $(this).val() == 'ajax_search' ) { $loc.addClass('hiddend'); } else{ $loc.removeClass('hiddend'); } }); $('select[name=fe_sb_action]').trigger('change'); $('#fe_search_button *[isparam=1]').on('change keyup', function(){ var p = $('#fe_search_button'); var sb = $('#fe_sb_preview button'); var css = $('#fe_sb_css'); sb.val(p.find('input[name=fe_sb_text]').val()).text(p.find('input[name=fe_sb_text]').val()); $('#fe_sb_preview').css({ 'text-align': p.find('select[name=fe_sb_align]').val() }); sb.css({ 'background': p.find('input[name=fe_sb_bg]').val(), 'padding': p.find('input[name=fe_sb_padding]').val(), 'margin': p.find('input[name=fe_sb_margin]').val() }); var ccss = p.find('input[name=fe_sb_border]').val() + p.find('input[name=fe_sb_boxshadow]').val(); ccss += p.find('input[name=fe_sb_font]').val(); css.text('#fe_sb_preview button.asp_search_btn.asp_s_btn {' + ccss + '}'); }); $('select[name=fe_sb_align]').trigger('change'); $('#fe_sb_trigger, #fe_sb_preview').on('click', function(e){ e.preventDefault(); e.stopImmediatePropagation(); $('#fe_sb_popup').removeClass("hiddend"); $('#fe_sb_popup').css({ "top": $('#fe_sb_trigger').position().top - 50 }); if ( $('#fe_sb_popup').find('>div').length == 0 ) { var themes = JSON.parse( $('#fe_sb_themes').text() ); $.each(themes, function(key, theme){ if ( key == 'default') return true; // Continue else theme = $.extend(themes.default, theme); var n = $('