agenda-libre-ruby/public/assets/pages-9dcc8cb3626a9f198ab95f9e64bb4d269167a7405dd07f94140f5ec6d32b6084.js

25 lines
694 B
JavaScript
Raw Normal View History

2019-11-05 22:42:37 +01:00
(function() {
var showPosition;
$(document).on('turbolinks:load', function() {
if (!navigator.geolocation) {
return;
}
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();
}
});
});
});
showPosition = function(position) {
return location.replace(window.goto.replace('[me]', "[" + position.coords.latitude + ", " + position.coords.longitude + "]"));
};
}).call(this);