3 //= require jquery.timers
4 //= require jquery.cookie
5 //= require jquery.throttle-debounce
6 //= require bootstrap.tooltip
7 //= require bootstrap.dropdown
11 //= require leaflet.osm
12 //= require leaflet.map
13 //= require leaflet.zoom
14 //= require leaflet.locationfilter
15 //= require i18n/translations
19 //= require querystring
21 var querystring = require('querystring-component');
23 function remoteEditHandler(bbox, object) {
25 url = document.location.protocol === "https:" ?
26 "https://127.0.0.1:8112/load_and_zoom?" :
27 "http://127.0.0.1:8111/load_and_zoom?",
29 left: bbox.getWest() - 0.0001,
30 top: bbox.getNorth() + 0.0001,
31 right: bbox.getEast() + 0.0001,
32 bottom: bbox.getSouth() - 0.0001
35 if (object) query.select = object.type + object.id;
37 var iframe = $('<iframe>')
40 .attr("src", url + querystring.stringify(query))
41 .on('load', function() {
46 setTimeout(function () {
48 alert(I18n.t('site.index.remote_failed'));
57 * Called as the user scrolls/zooms around to maniplate hrefs of the
58 * view tab and various other links
60 function updateLinks(loc, zoom, layers, object) {
61 $(".geolink").each(function(index, link) {
62 var href = link.href.split(/[?#]/)[0],
63 args = querystring.parse(link.search.substring(1)),
64 editlink = $(link).hasClass("editlink");
68 delete args['relation'];
69 delete args['changeset'];
71 if (object && editlink) {
72 args[object.type] = object.id;
75 var query = querystring.stringify(args);
76 if (query) href += '?' + query;
80 lon: 'lon' in loc ? loc.lon : loc.lng,
84 if (layers && !editlink) {
88 href += OSM.formatHash(args);
93 var editDisabled = zoom < 13;
95 .tooltip({placement: 'bottom'})
97 .on('click.minzoom', function() { return !editDisabled; })
98 .toggleClass('disabled', editDisabled)
99 .attr('data-original-title', editDisabled ?
100 I18n.t('javascripts.site.edit_disabled_tooltip') : '');
103 function escapeHTML(string) {
111 return string == null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
112 return htmlEscapes[match];
116 function maximiseMap() {
117 $("#content").addClass("maximised");
120 function minimiseMap() {
121 $("#content").removeClass("maximised");
124 $(document).ready(function () {
125 $("#menu-icon").on("click", function(e) {
127 $("header").toggleClass("closed");
130 $("nav.primary li a").on("click", function() {
131 $("header").toggleClass("closed");