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) {
26 left: bbox.getWest() - 0.0001,
27 top: bbox.getNorth() + 0.0001,
28 right: bbox.getEast() + 0.0001,
29 bottom: bbox.getSouth() - 0.0001
32 if (object) query.select = object.type + object.id;
34 var iframe = $('<iframe>')
37 .attr("src", "http://127.0.0.1:8111/load_and_zoom?" + querystring.stringify(query))
38 .on('load', function() {
43 setTimeout(function () {
45 alert(I18n.t('site.index.remote_failed'));
54 * Called as the user scrolls/zooms around to maniplate hrefs of the
55 * view tab and various other links
57 function updateLinks(loc, zoom, layers, object) {
58 $(".geolink").each(function(index, link) {
59 var href = link.href.split(/[?#]/)[0],
60 args = querystring.parse(link.search.substring(1)),
61 editlink = $(link).hasClass("editlink");
65 delete args['relation'];
66 delete args['changeset'];
68 if (object && editlink) {
69 args[object.type] = object.id;
72 var query = querystring.stringify(args);
73 if (query) href += '?' + query;
77 lon: 'lon' in loc ? loc.lon : loc.lng,
81 if (layers && !editlink) {
85 href += OSM.formatHash(args);
90 var editDisabled = zoom < 13;
92 .tooltip({placement: 'bottom'})
94 .on('click.minzoom', function() { return !editDisabled; })
95 .toggleClass('disabled', editDisabled)
96 .attr('data-original-title', editDisabled ?
97 I18n.t('javascripts.site.edit_disabled_tooltip') : '');
100 function escapeHTML(string) {
108 return string == null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
109 return htmlEscapes[match];
113 function maximiseMap() {
114 $("#content").addClass("maximised");
117 function minimiseMap() {
118 $("#content").removeClass("maximised");
121 $(document).ready(function () {
122 $("#menu-icon").on("click", function(e) {
124 $("header").toggleClass("closed");
127 $("nav.primary li a").on("click", function() {
128 $("header").toggleClass("closed");