public static function javo_search_form_callback($atts, $content = '') { global $javo_tso, $javo_tso_map; self::$load_script = true; extract(shortcode_atts(array('action' => '', 'hide_field' => array()), $atts)); $errors = new wp_error(); $javo_query = new javo_ARRAY($_GET); $javo_redirect = home_url(); if ((int) $action > 0 && !is_archive() && !is_search()) { $javo_redirect = apply_filters('javo_wpml_link', $action); } $hide_field = @explode(',', $hide_field); if (!empty($hide_field)) { foreach ($hide_field as $idx => $item) { $hide_field[$item] = 'hide'; unset($hide_field[$idx]); } } $javo_setVisibleLocation = array(); $javo_this_onoff = new javo_ARRAY($hide_field); $javo_getCurrentPageArchive = is_archive() || is_search(); $javo_getVisibleLocationType = $javo_tso_map->get('tab_location_field', '') != 'select' ? 'gg_ac' : 'term'; if (!$javo_getCurrentPageArchive) { if ($javo_getVisibleLocationType == 'gg_ac') { $javo_setVisibleLocation['term'] = " hidden"; $javo_setVisibleLocation['gg_ac'] = ""; } else { $javo_setVisibleLocation['term'] = ""; $javo_setVisibleLocation['gg_ac'] = " hidden"; } } else { $javo_setVisibleLocation['term'] = ""; $javo_setVisibleLocation['gg_ac'] = " hidden"; } if ($javo_this_onoff->get('location', null) == 'hide') { $javo_setVisibleLocation['term'] = " hidden"; } if ($errors->get_error_code() != "") { ob_start(); echo "<div class='container'><div class='alert alert-warning' role='alert'>{$errors->get_error_message()}</div></div>"; return ob_get_clean(); } ob_start(); ?> <div class="container search-type-a-wrap"> <form role="form" data-javo-search-form> <div class="search-type-a-inner"> <div class="search-box-inline<?php echo $javo_this_onoff->get('keyword', null) == 'hide' ? ' hidden' : ''; ?> "> <input type="text" class="search-a-items form-control" name="s" placeholder="<?php _e('Keyword', 'javo_fr'); ?> " value="<?php echo $javo_query->get('s', null); ?> "> </div><!-- /.search-box-inline --> <div class="search-box-inline<?php echo $javo_this_onoff->get('category', null) == 'hide' ? ' hidden' : ''; ?> "> <select name="filter[item_category]" class="form-control"> <option value=""><?php _e('Category', 'javo_fr'); ?> </option> <?php echo apply_filters('javo_get_selbox_child_term_lists', 'item_category', null, 'select', $javo_query->get('category', 0), 0, 0); ?> </select> </div><!-- /.search-box-inline --> <div class="search-box-inline<?php echo $javo_setVisibleLocation['term']; ?> "> <select name="filter[item_location]" class="form-control"> <option value=""><?php _e('Location', 'javo_fr'); ?> </option> <?php echo apply_filters('javo_get_selbox_child_term_lists', 'item_location', null, 'select', $javo_query->get('location', 0), 0, 0); ?> </select> </div><!-- /.search-box-inline --> <div class="search-box-inline<?php echo $javo_setVisibleLocation['gg_ac']; ?> "> <input type="text" name="filter[location]" class="form-control"> </div><!-- /.col-md-2 --> <div class="search-box-inline"> <input type="submit" class="btn btn-block btn-primary admin-color-setting" value="<?php _e('Search', 'javo_fr'); ?> "> </div><!-- /.col-md-2 --> </div> <!-- search-type-a-inner --> </form> <fieldset> <input type="hidden" value="<?php echo (int) $action > 0 ? apply_filters('javo_wpml_link', $action) : null; ?> " data-javo-search-action-template-url> <input type="hidden" value="<?php echo (int) $action > 0 ? 'data-javo-patch-form-for-template' : 'data-javo-patch-form-for-result'; ?> " data-javo-search-form-action-type> </fieldset> <!-- Search Result Page --> <form action="<?php echo home_url('/'); ?> " method="get" data-javo-patch-form-for-result> <input type="hidden" name="post_type" value="item"> <input type="hidden" name="category" value="<?php echo $javo_query->get('category'); ?> " data-javo-sf-category> <input type="hidden" name="location" value="<?php echo $javo_query->get('location'); ?> " data-javo-sf-location> <input type="hidden" name="s" data-javo-sf-keyword> </form><!-- /data-javo-patch-form-for-result : Go to Archive Page --> <!-- Javo Map Template --> <form action="<?php echo $javo_redirect; ?> " method="post" data-javo-patch-form-for-template> <input type="hidden" name="category" value="<?php echo $javo_query->get('category'); ?> " data-javo-sf-category> <input type="hidden" name="location" value="<?php echo $javo_query->get('location'); ?> " data-javo-sf-location> <input type="hidden" name="radius_key"> <input type="hidden" name="keyword" data-javo-sf-keyword> </form><!-- /data-javo-patch-form-for-template : Go to Map --> </div> <!-- container search-type-a-wrap --> <script type="text/javascript"> jQuery(function($){ var javo_search_bar_script = { el:{ origin : '[data-javo-search-form]' , result : '[data-javo-patch-form-for-result]' , template : '[data-javo-patch-form-for-template]' , type : '[data-javo-search-form-action-type]' } , template_url: $('[data-javo-search-action-template-url]').val() , msg: function(str){ $.javo_msg({content:str, delay:10000}); } , init: function(){ var $cat = this.setAutoComplete('[name="filter[item_category]"]'); var $loc = this.setAutoComplete('[name="filter[item_location]"]'); var eloc = $( this.el.origin ).find( '[name="filter[location]"]' ); var javo_ac = new google.maps.places.Autocomplete( eloc[0] ); $(document) .on('submit', this.el.origin, this.submit) } , setAutoComplete: function(el){ $(this.el.origin).find(el).chosen(); return $(this.el.origin).find(el); } , submit: function(e){ e.preventDefault(); var o = javo_search_bar_script; var r = $( o.el.origin ); var t = $('[' + $(o.el.type).val() + ']'); t.find('[data-javo-sf-category]') .val( r.find('[name="filter[item_category]"]').val() ); t.find('[data-javo-sf-location]') .val( r.find('[name="filter[item_location]"]').val() ); t.find('[name="radius_key"]') .val( r.find('[name="filter[location]"]').val() ); t.find('[data-javo-sf-keyword]') .val( r.find('input[name="s"]').val() ); t.submit(); } } javo_search_bar_script.init(); }); </script> <?php return ob_get_clean(); }
public static function javo_search_form_callback($atts, $content = '') { self::$load_script = true; $javo_query = new javo_ARRAY($_GET); extract(shortcode_atts(array('action' => '', 'hide_field' => array(), 'display_border' => ''), $atts)); $javo_redirect = home_url(); if ((int) $action > 0 && !is_archive() && !is_search()) { $javo_redirect = apply_filters('javo_wpml_link', $action); } $javo_hide_el = (array) @explode(',', $hide_field); $javo_hide_el = (object) Array_flip($javo_hide_el); $javo_display_border = $display_border === 'hide' || is_search() || is_archive() ? ' border-none' : null; ob_start(); ?> <div class="container search-type-a-wrap"> <form role="form" data-javo-search-form class="search-type-a-form" method="get"> <div class="search-type-a-inner<?php echo $javo_display_border; ?> "> <?php if (!isset($javo_hide_el->keyword)) { ?> <div class="search-box-inline"> <input type = "text" class = "search-a-items form-control" name = "s" placeholder = "<?php _e('Keyword', 'javo_fr'); ?> " value = "<?php echo $javo_query->get('keyword', null); ?> " > </div><!-- /.search-box-inline --> <?php } ?> <?php if (!isset($javo_hide_el->category)) { ?> <div class="search-box-inline"> <select name="filter[item_category]" class="form-control"> <option value=""><?php _e('Category', 'javo_fr'); ?> </option> <?php echo apply_filters('javo_get_selbox_child_term_lists', 'item_category', null, 'select', $javo_query->get('category', 0), 0, 0); ?> </select> </div><!-- /.search-box-inline --> <?php } ?> <?php if (!isset($javo_hide_el->location)) { ?> <div class="search-box-inline"> <select name="filter[item_location]" class="form-control"> <option value=""><?php _e('Location', 'javo_fr'); ?> </option> <?php echo apply_filters('javo_get_selbox_child_term_lists', 'item_location', null, 'select', $javo_query->get('location', 0), 0, 0); ?> </select> </div><!-- /.search-box-inline --> <?php } ?> <?php if (!isset($javo_hide_el->google) && !is_archive() && !is_search()) { ?> <div class="search-box-inline javo-search-form-geoloc"> <input type="text" name="geoloc" class="form-control jv-search-location-input" > <i class="fa fa-map-marker javo-geoloc-trigger"></i> </div><!-- /.col-md-2 --> <?php } ?> <div class="search-box-inline"> <button type="submit" class="jv-submit-button btn btn-primary admin-color-setting" > <i class="fa fa-search"></i> <?php _e('Search', 'javo_fr'); ?> </button> </div><!-- /.col-md-2 --> </div> <!-- search-type-a-inner --> <fieldset> <input type = "hidden" value = "<?php echo (int) $action > 0 ? apply_filters('javo_wpml_link', $action) : null; ?> " javo-search-target > </fieldset> </form> <form class = "hidden" role="search"> <input type="hidden" name="post_type" value="item"> <input type="hidden" name="category"> <input type="hidden" name="location"> <input type="hidden" name="keyword"> <input type="hidden" name="geolocation"> <input type="hidden" name="radius_key"> <input type="hidden" name="s"> </form> </div> <!-- container search-type-a-wrap --> <script type="text/javascript"> jQuery( function( $ ) { var javo_search_form_func = function() { this.elements = { origin : 'form[data-javo-search-form]' , result : '[data-javo-patch-form-for-result]' , template : '[data-javo-patch-form-for-template]' , type : '[data-javo-search-form-action-type]' , geo_trig : '.javo-geoloc-trigger' } if( ! window.__JSF__INSTANCE__ ) { window.__JSF__INSTANCE__ = true; this .init() .methods(); } } javo_search_form_func.prototype = { constructor: javo_search_form_func , init : function() { this.setAutoCompleteObject(); return this; } , setAutoCompleteObject : function() { var form = $( this.elements.origin ); var term_elements = form.find( "select[name^='filter']" ); var geo_elment = form.find( "[name='geoloc']" )[0]; term_elements.chosen({ search_contains: 1 }); if( geo_elment ) new google.maps.places.Autocomplete( geo_elment ); } , methods : function() { $( document ) .on( 'submit' , this.elements.origin, this.submit ) .on( 'click' , this.elements.geo_trig, this.trigger_geo ); return this; } , trigger_geo : function( e ) { e.preventDefault(); var _form = $( this ).closest( 'form' ); var form = _form.next(); _form .find( '*' ) .addClass( 'disabled' ) .attr( 'disabled', true ); $( this ).addClass( 'fa-spin' ); form.find( "[name='geolocation']" ).val(1); _form.submit(); } , submit : function( e ) { e.preventDefault(); var _form = $( this ); var form = _form.next(); var __TAR__ = _form.find( '[javo-search-target]' ).val(); if( __TAR__ ) { // Template form .prop({ action : __TAR__, method: 'post' }) .find( "[name='s'], [name='post_type']" ) .remove(); } else { // Search Result form.prop({ action : '', method : 'get' }); } ; form .find( "[name='category']") .val( _form.find( "select[name='filter[item_category]']" ).val() ) ; form .find( "[name='location']") .val( _form.find( "select[name='filter[item_location]']" ).val() ) ; form .find( "[name='s'], [name='keyword']") .val( _form.find( "input[name='s']" ).val() ) ; form .find( "[name='radius_key']") .val( _form.find( "input[name='geoloc']" ).val() ) form.submit(); } }; new javo_search_form_func; }); </script> <?php return ob_get_clean(); }