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 zoomPrecision(zoom) {
24 return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
27 function remoteEditHandler(bbox, select) {
30 left: bbox.getWest() - 0.0001,
31 top: bbox.getNorth() + 0.0001,
32 right: bbox.getEast() + 0.0001,
33 bottom: bbox.getSouth() - 0.0001
36 if (select) query.select = select;
38 var iframe = $('<iframe>')
41 .attr("src", "http://127.0.0.1:8111/load_and_zoom?" + querystring.stringify(query))
42 .on('load', function() {
47 setTimeout(function () {
49 alert(I18n.t('site.index.remote_failed'));
58 * Called as the user scrolls/zooms around to maniplate hrefs of the
59 * view tab and various other links
61 function updatelinks(loc, zoom, layers, object) {
62 $(".geolink").each(function(index, link) {
63 var href = link.href.split(/[?#]/)[0],
64 args = querystring.parse(link.search.substring(1)),
65 editlink = $(link).hasClass("editlink");
67 if (object && editlink) {
70 delete args['relation'];
71 delete args['changeset'];
73 args[object.type] = object.id;
76 var query = querystring.stringify(args);
77 if (query) href += '?' + query;
81 lon: loc.lon || loc.lng,
85 if (layers && !editlink) {
89 href += OSM.formatHash(args);
94 var editDisabled = zoom < 13;
96 .tooltip({placement: 'bottom'})
98 .on('click.minzoom', function() { return !editDisabled; })
99 .toggleClass('disabled', editDisabled)
100 .attr('data-original-title', editDisabled ?
101 I18n.t('javascripts.site.edit_disabled_tooltip') : '');
104 // generate a cookie-safe string of map state
105 function cookieContent(map) {
106 var center = map.getCenter().wrap();
107 return [center.lng, center.lat, map.getZoom(), map.getLayersCode()].join('|');
110 function escapeHTML(string) {
118 return string == null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
119 return htmlEscapes[match];
123 function maximiseMap() {
124 $("#content").addClass("maximised");
127 function minimiseMap() {
128 $("#content").removeClass("maximised");
131 $(document).ready(function () {
132 $("#menu-icon").on("click", function(e) {
134 $("header").toggleClass("closed");
137 $("nav.primary li a").on("click", function() {
138 $("header").toggleClass("closed");