agenda-libre-ruby/public/assets/pages-9095e3d3785d23f61fcfb57e1cb9f4c10cf262409efe6d656b9710c721249e6c.js
echarp fb01a0f8da City filter added in most pages.
This filter is based on the geocoding filter, when no distance has been set...

Refs #170
2020-04-06 16:47:55 +02:00

33 lines
999 B
JavaScript

(function() {
var showPosition;
$(document).on('turbolinks:load', function() {
if (!navigator.geolocation) {
return;
}
$('a.near-me').click(function(event) {
event.preventDefault();
window.goto = event.target.href;
return navigator.geolocation.getCurrentPosition(showPosition, function(error) {
switch (error.code) {
case error.PERMISSION_DENIED:
return $('ul.regions li#near-me').remove();
}
});
});
return $('body.pages.show form').submit(function() {
if ($('#near_location').val() && $('#near_distance').val()) {
return $('#city').val('');
} else {
$('#city').val($('#near_location').val());
return $('#near_location').val('');
}
});
});
showPosition = function(position) {
return location.replace(window.goto.replace('[me]', "[" + (position.coords.latitude.toFixed(2)) + ", " + (position.coords.longitude.toFixed(2)) + "]"));
};
}).call(this);