| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template for Element Listings Search Form. |
| 4 |
* This is the template that elementor element, fields, search form |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
?> |
| 13 |
|
| 14 |
<?php |
| 15 |
global $wdk_button_search_defined; |
| 16 |
$wdk_button_search_defined=true; |
| 17 |
|
| 18 |
global $wdk_enable_search_fields_toggle; |
| 19 |
$wdk_enable_search_fields_toggle = false; |
| 20 |
|
| 21 |
|
| 22 |
$current_url = ''; |
| 23 |
|
| 24 |
$results_page = wmvc_show_data('conf_link', $settings); |
| 25 |
if(!is_array($results_page) && !empty($results_page)) { |
| 26 |
$results_page = get_permalink($results_page); |
| 27 |
} else { |
| 28 |
$results_page = get_permalink(wdk_get_option('wdk_results_page')); |
| 29 |
|
| 30 |
if (!wdk_get_option('wdk_is_results_page_require')) { |
| 31 |
$obj_id = get_queried_object_id(); |
| 32 |
$current_url = get_permalink( $obj_id ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
?> |
| 37 |
<div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>"> |
| 38 |
<div class="wdk-search-popup"> |
| 39 |
<button type="button" class="toggle-btn elementor-clickable" |
| 40 |
data-wdk-toggle="modal" data-wdk-target="#wdk_search_popup_modal_<?php echo esc_html($id_element); ?>" > |
| 41 |
<?php if(wmvc_show_data('text_toggle_button_icon_position', $settings) == 'left') :?> |
| 42 |
<?php \Elementor\Icons_Manager::render_icon( $settings['text_toggle_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_popup' ] ); ?> |
| 43 |
<?php endif;?> |
| 44 |
<?php echo esc_html(wmvc_show_data('text_toggle_button', $settings));?> |
| 45 |
<?php if(wmvc_show_data('text_toggle_button_icon_position', $settings) == 'right') :?> |
| 46 |
<?php \Elementor\Icons_Manager::render_icon( $settings['text_toggle_button_icon'], [ 'aria-hidden' => 'true', "class"=>'icon_popup' ] ); ?> |
| 47 |
<?php endif;?> |
| 48 |
</button> |
| 49 |
</div> |
| 50 |
|
| 51 |
<div class="wdk-modal wkd-fade wdk-search-popup-modal elementor-clickable nodetach" id="wdk_search_popup_modal_<?php echo esc_html($id_element); ?>" tabindex="-1" role="dialog" |
| 52 |
style="display: none;" aria-hidden="true"> |
| 53 |
<div class="modal-dialog modal-notice"> |
| 54 |
<form data-current-link="<?php echo esc_url($current_url);?>" data-scrollto="<?php echo esc_attr(wmvc_show_data('search_scroll', $settings));?>" class="wdk-search-form wdk-skip-empty |
| 55 |
<?php if(wmvc_show_data('auto_search_enable', $settings) == 'yes'):?> auto_search <?php endif;?> |
| 56 |
<?php if(!wdk_get_option('wdk_results_page')):?> wdk-result-page-notdefined <?php endif;?>" action="<?php echo esc_url($results_page);?>"> |
| 57 |
<div class="modal-content"> |
| 58 |
<div class="modal-header"> |
| 59 |
<h5 <?php $this->editing_element('text_popup', 'basic', array('class'=>'modal-title')); ?>><?php echo esc_html(wmvc_show_data('text_popup', $settings));?></h5> |
| 60 |
<button type="button" class="close" data-wdk-dismiss="modal" aria-hidden="true" > |
| 61 |
<span class="dashicons dashicons-no-alt"></span> |
| 62 |
</button> |
| 63 |
</div> |
| 64 |
<div class="modal-body"> |
| 65 |
<div class="wdk-row wdk-fields-list"> |
| 66 |
<?php wdk_generate_search_form_fields_elementor(wmvc_show_data('custom_fields', $settings), '', TRUE, $predefields_query); ?> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
<div class="modal-footer justify-content-center"> |
| 70 |
<?php foreach (wmvc_show_data('custom_buttons', $settings) as $key => $custom_button):?> |
| 71 |
<?php |
| 72 |
switch (wmvc_show_data('action_list_field_id', $custom_button)): |
| 73 |
case 'button_reset': |
| 74 |
echo '<button type="button" class="wdk-btn wdk-button-search-reset">'.(!empty(wmvc_show_data('placeholder', $custom_button)) ? wmvc_show_data('placeholder', $custom_button) : esc_html__('Reset', 'wpdirectorykit')).'</button>'; |
| 75 |
break; |
| 76 |
case 'button_search': |
| 77 |
echo '<button type="submit" class="wdk-btn wdk-button-search-start wdk-click-load-animation">'.(!empty(wmvc_show_data('placeholder', $custom_button)) ? wmvc_show_data('placeholder', $custom_button) : esc_html__('Search', 'wpdirectorykit')).'</button>'; |
| 78 |
break; |
| 79 |
case 'button_close': |
| 80 |
echo '<button type="button" class="wdk-btn wdk-button-close" data-wdk-dismiss="modal">'.(!empty(wmvc_show_data('placeholder', $custom_button)) ? wmvc_show_data('placeholder', $custom_button) : esc_html__('Close', 'wpdirectorykit')).'</button>'; |
| 81 |
break; |
| 82 |
|
| 83 |
default: |
| 84 |
# code... |
| 85 |
break; |
| 86 |
endswitch; |
| 87 |
?> |
| 88 |
<?php endforeach;?> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
</form> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|
| 95 |
<script> |
| 96 |
jQuery(document).ready(function($) { |
| 97 |
$("form.wdk-result-page-notdefined").on('submit', function() { |
| 98 |
wdk_log_notify('<?php echo esc_js(__('Results page not found, please configure results page', 'wpdirectorykit')); ?>', 'error'); |
| 99 |
return false; |
| 100 |
}); |
| 101 |
|
| 102 |
const search_highlight = (elem) => |
| 103 |
{ |
| 104 |
if(elem.is('select')) |
| 105 |
{ |
| 106 |
if(elem.val() == '' || elem.val() == 0 || elem.val() == null) |
| 107 |
{ |
| 108 |
// remove selector class |
| 109 |
elem.closest('.select-item').removeClass('sel_class'); |
| 110 |
elem.parent().removeClass('sel_class'); |
| 111 |
elem.removeClass('sel_class'); |
| 112 |
} |
| 113 |
else |
| 114 |
{ |
| 115 |
// add selector class |
| 116 |
elem.closest('.select-item').addClass('sel_class'); |
| 117 |
elem.parent().addClass('sel_class'); |
| 118 |
elem.addClass('sel_class'); |
| 119 |
} |
| 120 |
} |
| 121 |
else if(elem.attr('type') == 'text') |
| 122 |
{ |
| 123 |
if(elem.parent().find('.wdk_dropdown_tree').length > 0) // For treefield |
| 124 |
{ |
| 125 |
if(elem.val() != '' && elem.val() != null) |
| 126 |
{ |
| 127 |
// add selector class |
| 128 |
elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').addClass('sel_class'); |
| 129 |
elem.parent().find('.btn-group:first-child').addClass('sel_class'); |
| 130 |
} |
| 131 |
else |
| 132 |
{ |
| 133 |
// remove selector class |
| 134 |
elem.closest('.wdk_dropdown_tree_style').find('.wdk_dropdown_tree').removeClass('sel_class'); |
| 135 |
elem.parent().find('.btn-group:first-child').removeClass('sel_class'); |
| 136 |
} |
| 137 |
} |
| 138 |
else // For basic input |
| 139 |
{ |
| 140 |
if(elem.val() != '' && elem.val() != null) |
| 141 |
{ |
| 142 |
// add selector class |
| 143 |
elem.addClass('sel_class'); |
| 144 |
} |
| 145 |
else |
| 146 |
{ |
| 147 |
// remove selector class |
| 148 |
elem.removeClass('sel_class'); |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
// On change value, change field style |
| 155 |
$('#wdk_el_<?php echo esc_html($id_element);?>').find('input, select').each(function(i) |
| 156 |
{ |
| 157 |
$(this).on('change', function(){search_highlight($(this))}); |
| 158 |
search_highlight($(this)); |
| 159 |
}) |
| 160 |
<?php if($is_edit_mode):?> |
| 161 |
wdk_select_init(); |
| 162 |
|
| 163 |
if(typeof $.fn.fieldSliderRange == 'function' && typeof $.fn.ionRangeSlider == 'function') { |
| 164 |
$('.wdk-slider-range-field').fieldSliderRange(); |
| 165 |
} |
| 166 |
|
| 167 |
wdk_log_modal(); |
| 168 |
<?php endif;?> |
| 169 |
}); |
| 170 |
</script> |
| 171 |
</div> |
| 172 |
|