PluginProbe
WP Directory Kit / 1.3.3
WP Directory Kit v1.3.3
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / public / js / wdk-dependfields-search.js

wdk-dependfields-search.js in WP Directory Kit 1.3.3, at public/js/wdk-dependfields-search.js

31 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function($){
2 wdk_dependfields_search_form();
3 });
4 const wdk_dependfields_search_form = ($selector = '.wdk-search', parent_field_selector = '.wdk-field') => {
5 var $ = jQuery;
6 var el_category,el_form, class_hide, hide_fields;
7 class_hide = 'wdk-depend-hidden';
8 el_form = jQuery($selector);
9 el_category = el_form.find('*[name="search_category"]');
10
11 el_category.on('change', function(){
12 hide_fields();
13 });
14
15 hide_fields = () => {
16 var value = el_category.val();
17 el_form.find('.'+class_hide).removeClass(class_hide)
18 if(value && typeof script_dependfields_search.hidden_fields[value] != 'undefined') {
19 el_form.find('*[name *="field_"]').each(function(){
20 var field_id = $(this).attr('name').substr(6);
21 if(script_dependfields_search.hidden_fields[value].indexOf(','+field_id+',') != -1) {
22 $(this).closest(parent_field_selector).addClass(class_hide);
23 }
24 });
25 }
26 };
27
28 /* init hide fields */
29 hide_fields();
30
31 }