1(function ($) { 2 $(document).ready(function () { 3 4 //resetSearch(); 5 6 var $document = $(document), 7 $window = $(window), 8 $viewport = $('html, body'), 9 $html = $('html'), 10 $body = $('body'); 11 12 function __construct() { 13 $window.on('load', search_listings()); 14 $window.on('load', clicksearch()); 15 } 16 17 18 19 search_listings_ajax(); 20 search_listings_ajax_pagination(); 21 22 23 function clicksearch(){ 24 jQuery('.custom-select-list .custom-select-list-option').click(function(){ 25 var _url = jQuery(this).data('url'); 26 _url = _url.toLowerCase(); 27 if(_url=='all'){ 28 _url = window.location.origin + '/properties/'; 29 location.href = _url; 30 } 31 else{ 32 33 jQuery('div#search-property-page').hide(); 34 _url = window.location.origin + '/properties/' + _url; 35 location.href = _url; 36 37 } 38 }); 39 } 40 41 // function resetSearch(){ 42 // jQuery('#resetBtn').click(function(){ 43 // var url = jQuery(location).attr('href'); 44 // var curUrl = url.split('?')[0]; 45 // window.location.href = curUrl; 46 // }); 47 // } 48 49 function search_listings_ajax(page) { 50 if(jQuery('#search-property-page').length){ 51 jQuery('#search-property-page').html('' + 52 '<div class="listing-search-loader"></div>'); 53 54 55 jQuery.post( 56 ajax_object.ajax_url, 57 { 58 'action': 'search_listings_ajax', 59 'data': ((jQuery('#listing-search-form').length) ? jQuery('#listing-search-form').serialize() : ''), 60 'page': page 61 }, 62 function ($result) { 63 var data = jQuery.parseJSON($result), 64 target = jQuery('#search-property-page'); 65 66 if (data.html_listing_result && target.length) { 67 target.html(data.html_listing_result + data.html_listing_pagination); 68 } else { 69 console.log('There\'s an error on ajax returned data.'); 70 } 71 } 72 ); 73 } 74 } 75 76 77 function search_listings_ajax_pagination() 78 { 79 jQuery(document).on('click', '#sfj-pagination a', function(e){ 80 jQuery("html, body").animate({ scrollTop: 0 }, 100); 81 e.preventDefault(); 82 83 var page = (jQuery(this).attr('href')) ? jQuery(this).attr('href') : ''; 84 85 search_listings_ajax(page); 86 }); 87 } 88 89 90 /** Search Listings **/ 91 function search_listings() { 92 /** Input Range **/ 93 //__range(); 94 95 function __range() { 96 var $rangeslider = $('#listings-price'), 97 $minPrice = $('.selected-min-price'), 98 $maxPrice = $('.selected-max-price'); 99 100 $rangeslider.ionRangeSlider({ 101 type: 'double', 102 min: 0, 103 max: 300, 104 hide_min_max: true, 105 hide_from_to: true, 106 onFinish: function(){ 107 search_listings_ajax(); 108 } 109 }); 110 111 $rangeslider.on("change", function () { 112 var $this = $(this), 113 value = $this.prop("value").split(";"); 114 115 _minPrice = (value[0] < 1 ? value[0] : value[0] + 'M'); 116 _maxPrice = (value[1] < 1 ? value[1] : value[1] + 'M'); 117 $minPrice.text('$' + _minPrice); 118 $maxPrice.text('$' + _maxPrice); 119 }); 120 121 } 122 123 /** Select Replicate to HTML **/ 124 __select(); 125 126 function __select() { 127 var $select = $('.listings-search ._content select'); 128 129 $select.each(function () { 130 131 var $this = $(this), 132 $child = $this.children(), 133 $id = $this.attr('id'), 134 _html = '', 135 arr = {}, 136 selected_option_text = $this.find(":selected").text(); 137 138 $this.hide(); 139 140 _html += '<div class="custom-select" data-select="' + $id + '">'; 141 _html += '<div class="custom-selected">' + selected_option_text + '</div>'; 142 _html += '<div class="custom-select-list">'; 143 $child.each(function () { 144 var $children = $(this), 145 _tagname = $children.get(0).tagName; 146 147 /** Get child of group **/ 148 if (_tagname == 'OPTGROUP') { 149 _html += '<div class="custom-select-list-title"><span>' + $children.attr('label') + '</span>'; 150 $children.find('option').each(function () { 151 var $childGroup = $(this), 152 _val = $childGroup.attr('value'), 153 _url = _val.replace(/\ /g,'-'); 154 _text = $childGroup.text(); 155 156 if (_val != '') _html += '<div class="custom-select-list-option" data-url="' + _url + '" data-value="' + _val + '">' + _text + '</div>'; 157 }); 158 _html += '</div>'; 159 } else { 160 var _val = $children.attr('value'), 161 _url = _val.replace(/\ /g,'-'); 162 _text = $children.text(); 163 if (_val != '') _html += '<div class="custom-select-list-option" data-url="' + _url + '" data-value="' + _val + '">' + _text + '</div>'; 164 } 165 166 }); 167 168 _html += '</div>'; 169 _html += '</div>'; 170 171 $(_html).insertBefore($this); 172 }); 173 174 $select.parent().on('click', '.custom-selected', function () { 175 var $this = $(this), 176 $parent = $this.parent(), 177 $custom_list = $parent.find('.custom-select-list'); 178 179 if (!$custom_list.is(':visible')) {
180 closeAllList(); 181 $custom_list.show(); 182 $parent.css({zIndex: 100}); 183 } else { 184 closeAllList(); 185 } 186 187 }); 188 189 $select.parent().on('click', '.custom-select-list-option', function () { 190 var $this = $(this), 191 $parents = $this.parents('.custom-select'), 192 _selectId = $parents.data('select'), 193 _selectedVal = $this.data('value') 194 $display = $parents.find('.custom-selected'), 195 $custom_list = $parents.find('.custom-select-list'), 196 _search = false; 197 198 // Trigger ajax search on change of the search type, area and property type 199 if($('#' + _selectId).val() != _selectedVal){ 200 _search = true; 201 } 202 203 $('#' + _selectId).val(_selectedVal); 204 205 if(_search){ 206 search_listings_ajax(); 207 } 208 209 $display.text($this.text()); 210 $custom_list.hide(); 211 $parents.css({zIndex: 100}); 212 }); 213 214 $document.keyup(function (e) { 215 if (e.keyCode == 27) closeAllList(); 216 }); 217 218 $(document).on('click', function (e) { 219 if (!$(e.target).closest('.custom-select').length) { 220 if ($('.custom-select').is(":visible")) { 221 closeAllList(); 222 } 223 } 224 }); 225 226 function closeAllList() { 227 $('.custom-select-list').hide(); 228 $('.custom-select').css({zIndex: 0}); 229 } 230 } 231 } 232 233 /** Instantiate **/ 234 __construct(); 235 236 }); 237})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.