Select first result from geolocation dropdown with enter #42
@@ -1,12 +1,10 @@
|
|||||||
const PRICE_SLIDER_OPTIONS = {
|
const PRICE_SLIDER_OPTIONS = {
|
||||||
start: [50000, 85000],
|
start: [50000, 85000],
|
||||||
range: {
|
range: {
|
||||||
min: [0, 1000],
|
min: [0],
|
||||||
"10%": [20000, 1000],
|
max: [300000]
|
||||||
"35%": [100000, 1000],
|
|
||||||
"70%": [200000, 10000],
|
|
||||||
max: [1000000]
|
|
||||||
},
|
},
|
||||||
|
step: 1000,
|
||||||
connect: true,
|
connect: true,
|
||||||
tooltips: true
|
tooltips: true
|
||||||
};
|
};
|
||||||
@@ -15,10 +13,10 @@ const PRICE_SLIDER_OPTIONS = {
|
|||||||
const HOME_SIZE_SLIDER_OPTIONS = {
|
const HOME_SIZE_SLIDER_OPTIONS = {
|
||||||
start: [30, 75],
|
start: [30, 75],
|
||||||
range: {
|
range: {
|
||||||
min: [0, 5],
|
min: [0],
|
||||||
"50%": [100, 10],
|
|
||||||
max: [400]
|
max: [400]
|
||||||
},
|
},
|
||||||
|
step: 5,
|
||||||
connect: true,
|
connect: true,
|
||||||
tooltips: true
|
tooltips: true
|
||||||
};
|
};
|
||||||
@@ -26,11 +24,10 @@ const HOME_SIZE_SLIDER_OPTIONS = {
|
|||||||
const GARDEN_SIZE_SLIDER_OPTIONS = {
|
const GARDEN_SIZE_SLIDER_OPTIONS = {
|
||||||
start: [100, 1000],
|
start: [100, 1000],
|
||||||
range: {
|
range: {
|
||||||
min: [0, 10],
|
min: [0],
|
||||||
"40%": [1000, 100],
|
max: [10000]
|
||||||
"80%": [10000, 100],
|
|
||||||
max: [100000]
|
|
||||||
},
|
},
|
||||||
|
step: 100,
|
||||||
connect: true,
|
connect: true,
|
||||||
tooltips: true
|
tooltips: true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -99,6 +99,7 @@
|
|||||||
autocomplete = new google.maps.places.Autocomplete(inputElement, initialAutocompleteParams);
|
autocomplete = new google.maps.places.Autocomplete(inputElement, initialAutocompleteParams);
|
||||||
autocomplete.bindTo('bounds', map);
|
autocomplete.bindTo('bounds', map);
|
||||||
autocomplete.addListener('place_changed', onPlaceChanged);
|
autocomplete.addListener('place_changed', onPlaceChanged);
|
||||||
|
pacSelectFirst(inputElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPlaceChanged() {
|
function onPlaceChanged() {
|
||||||
@@ -110,6 +111,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pacSelectFirst(input) {
|
||||||
|
// store the original event binding function
|
||||||
|
const _addEventListener = input.addEventListener
|
||||||
|
? input.addEventListener
|
||||||
|
: input.attachEvent
|
||||||
|
|
||||||
|
function addEventListenerWrapper (type, listener) {
|
||||||
|
// Simulate a 'down arrow' keypress on hitting 'return' when no pac suggestion is selected,
|
||||||
|
// and then trigger the original listener.
|
||||||
|
if (type == 'keydown') {
|
||||||
|
const originalListener = listener
|
||||||
|
listener = function (event) {
|
||||||
|
const suggestionSelected = $('.pac-item-selected').length > 0
|
||||||
|
if (event.key == 'Enter' && !suggestionSelected) {
|
||||||
|
const simulatedDownArrow = $.Event('keydown', {
|
||||||
|
keyCode: 40,
|
||||||
|
which: 40
|
||||||
|
})
|
||||||
|
originalListener.apply(input, [simulatedDownArrow])
|
||||||
|
}
|
||||||
|
|
||||||
|
originalListener.apply(input, [event])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_addEventListener.apply(input, [type, listener])
|
||||||
|
}
|
||||||
|
|
||||||
|
input.addEventListener = addEventListenerWrapper
|
||||||
|
input.attachEvent = addEventListenerWrapper
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$("#submit").click(() => {
|
$("#submit").click(() => {
|
||||||
const mapBounds = map.getBounds();
|
const mapBounds = map.getBounds();
|
||||||
|
|||||||
Reference in New Issue
Block a user