PageSourceSearch

https://fearless.cool/wp-content/cache/min/1/wp-content/plugins/je…/public/location-distance.js?ver=1784640000

js fearless.cool collected 2026-10-08 20:57:20 UTC 6,683 bytes, 37 lines download raw bytes

1(function($){"use strict";const initLocationDistanceFilter=function(){window.JetSmartFilters.filtersList.JetEngineLocationDistance='jet-smart-filters-location-distance';window.JetSmartFilters.filters.JetEngineLocationDistance=class JetEngineLocationDistance extends window.JetSmartFilters.filters.Search{name='location-distance';currentLocationVerbose='Your current location';defaultLocation=null;$locationParent=null;$locationInput=null;$locationDropdown=null;$distanceInput=null;constructor($container){const $filter=$container.find('.jsf-location-distance');super($container,$filter);this.locationData={};this.$locationParent=$filter.find('.jsf-location-distance__location');this.$locationInput=$filter.find('.jsf-location-distance__location-input');this.$locationDropdown=$filter.find('.jsf-location-distance__location-dropdown');this.$distanceInput=$filter.find('.jsf-location-distance__distance');if($filter.data('geolocation-placeholder')){this.currentLocationVerbose=$filter.data('geolocation-placeholder')}
2this.$distanceInput.on('change',(event)=>{this.updateLocationData({distance:event.target.value})});this.defaultLocation=$filter.data('current-location');if(this.defaultLocation.distance){this.selectDistance(this.defaultLocation.distance)}
3this.$locationInput.on('keyup',(event)=>{var keyCode=(event.keyCode?event.keyCode:event.which);if(event.target.value.length){this.switchClear(!0);this.switchLocate()}else{this.switchClear();this.switchLocate(!0)}
4if(3>event.target.value.length){this.clearDropdown();return}
5this.updateLocationData({address:event.target.value,},!0);if(13===keyCode){this.maybeApplyFilter();this.clearDropdown();return}
6$.ajax({url:window.JetMapListingLocationDistanceFilterData.apiAutocomplete,type:'GET',dataType:'json',data:{query:event.target.value},}).done((response)=>{this.clearDropdown();if(!response||!response.success){return}
7this.$locationDropdown.addClass('is-active');for(var i=0;i<response.data.length;i++){this.$locationDropdown.append('<div class="jsf-location-distance__location-dropdown-item" data-address="'+response.data[i].address+'">'+response.data[i].address+'</div>')}})});this.$locationDropdown.on('click','.jsf-location-distance__location-dropdown-item',(event)=>{const $dropdownItem=$(event.target);this.$locationInput.val($dropdownItem.data('address'));this.clearDropdown();this.updateLocationData({address:$dropdownItem.data('address'),latitude:0,longitude:0,})});this.$locationParent.on('click','.jsf-location-distance__location-clear',(event)=>{this.clearLocation()});this.$locationParent.on('click','.jsf-location-distance__location-locate',(event)=>{this.switchLocate();this.switchLoading(!0);navigator.geolocation.getCurrentPosition((position)=>{this.switchLoading();this.$locationInput.val(this.currentLocationVerbose);this.switchClear(!0);this.updateLocationData({address:0,latitude:position.coords.latitude,longitude:position.coords.longitude,})})});$(document).on('click',(event)=>{const $parent=$(event.target).closest('.jsf-location-distance__location');if(!$parent.length){this.clearDropdown()}})}
8maybeApplyFilter(){const applyOn=['ajax','mixed'];if(!applyOn.includes(this.applyType)){return}
9this.emitFiterApply()}
10reset(){this.updateLocationData({},!0,['distance']);this.$distanceInput.find('option:selected').removeAttr('selected');this.clearLocation()}
11setData(newData){if(newData){this.updateLocationData({...newData},!0)}
12if(newData&&newData.address){if(0==newData.address&&newData.latitude&&newData.longitude){this.$locationInput.val(this.currentLocationVerbose)}else{this.$locationInput.val(newData.address)}
13this.switchClear(!0);this.switchLocate()}
14if(newData&&newData.distance){this.selectDistance(newData.distance)}}
15selectDistance(distance){this.$distanceInput.find('option[value="'+distance+'"]').attr('selected',!0)}
16get activeValue(){if(!this.hasLocation()&&this.defaultLocation.distance==this.locationData.distance){return!1}
17const activeValue=[];if(this.locationData.address&&0!=this.locationData.address){activeValue.push(this.locationData.address)}else if(this.locationData.latitude&&this.locationData.longitude){activeValue.push(this.currentLocationVerbose)}
18activeValue.push(this.locationData.distance+this.locationData.units);return activeValue.join(', ')}
19locationDataIsEmpty(){if(!this.locationData||0===Object.keys(this.locationData).length){return!0}
20if(!this.hasLocation()&&!this.locationData.distance){return!0}
21return!1}
22get data(){if(this.dataValue&&!this.disabled){return{...this.dataValue}}else if(!this.locationDataIsEmpty()&&!this.disabled){return{...this.locationData}}else{console.log('Empty');return!1}}
23processData(){if(this.hasLocation()){this.dataValue={...this.locationData}}else{this.dataValue=!1}}
24clearLocation(){this.$locationInput.val('');this.clearDropdown();this.switchClear();this.switchLocate(!0);this.updateLocationData({},!1,['address','longitude','latitude'])}
25hasLocation(){if(!this.locationData||(!this.locationData.address&&!this.locationData.latitude&&!this.locationData.longitude)){return!1}else{return!0}}
26clearDropdown(){this.$locationDropdown.html('').removeClass('is-active')}
27switchClear(show){if(show&&!this.$locationParent.hasClass('jsf-show-clear')){this.$locationParent.addClass('jsf-show-clear')}else if(!show){this.$locationParent.removeClass('jsf-show-clear')}}
28switchLoading(show){if(show&&!this.$locationParent.hasClass('jsf-show-loading')){this.$locationParent.addClass('jsf-show-loading')}else if(!show){this.$locationParent.removeClass('jsf-show-loading')}}
29switchLocate(show){if(!navigator.geolocation){this.$locationParent.removeClass('jsf-show-locate');return}
30if(show&&!this.$locationParent.hasClass('jsf-show-locate')){this.$locationParent.addClass('jsf-show-locate')}else if(!show){this.$locationParent.removeClass('jsf-show-locate')}}
31updateLocationData(newData,silent,deleteData){if(0!==Object.keys(newData).length){if(0!==Object.keys(this.defaultLocation).length){newData={...this.defaultLocation,...newData}}
32for(const prop in newData){this.locationData[prop]=newData[prop]}
33if(!this.locationData.distance){this.locationData.distance=this.$distanceInput.data('default')}
34if(!this.locationData.units){this.locationData.units=this.$distanceInput.data('units')}}
35if(deleteData){for(var i=0;i<deleteData.length;i++){delete this.locationData[deleteData[i]]}}
36if(!silent){this.maybeApplyFilter()}}}}
37if(window.JetMapListingGeolocationFilterData&&'jet-smart-filters/before-init'===window.JetMapListingGeolocationFilterData.initEvent){document.addEventListener('jet-smart-filters/before-init',(e)=>{initLocationDistanceFilter()})}else{window.addEventListener('DOMContentLoaded',(e)=>{initLocationDistanceFilter()})}}(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.