Julien Roncaglia 1a8d15d1c5 Add 2 new hooks: geoSearch and nicknameClicked
For both of them returning false will interupt the default action

'geoSearch' is called when something is entered in the search box.
The argument is the string entered in the search box

'nicknameClicked' is called when a nickname is cliked.
The argument is an object with 2 properties:
 - 'event' contain the standard event object
 - 'nickname' contain the nick of the user
2013-04-09 22:40:34 +02:00

27 lines
781 B
JavaScript

// GEOSEARCH /////////////////////////////////////////////////////////
window.setupGeosearch = function() {
$('#geosearch').keypress(function(e) {
if((e.keyCode ? e.keyCode : e.which) != 13) return;
var search = $(this).val();
if (!runHooks('geoSearch', search)) {
return;
}
$.getJSON(NOMINATIM + encodeURIComponent(search), function(data) {
if(!data || !data[0]) return;
var b = data[0].boundingbox;
if(!b) return;
var southWest = new L.LatLng(b[0], b[2]),
northEast = new L.LatLng(b[1], b[3]),
bounds = new L.LatLngBounds(southWest, northEast);
window.map.fitBounds(bounds);
if(window.isSmartphone()) window.smartphone.mapButton.click();
});
e.preventDefault();
});
}