3 //= require jquery.timers
4 //= require jquery.throttle-debounce
5 //= require js-cookie/dist/js.cookie
7 //= require bootstrap-sprockets
9 //= require leaflet/dist/leaflet-src
10 //= require leaflet.osm
11 //= require leaflet.map
12 //= require leaflet.zoom
13 //= require leaflet.locationfilter
18 //= require qs/dist/qs
19 //= require bs-custom-file-input
20 //= require bs-custom-file-input-init
23 * Called as the user scrolls/zooms around to manipulate hrefs of the
24 * view tab and various other links
26 window.updateLinks = function (loc, zoom, layers, object) {
27 $(".geolink").each(function (index, link) {
28 var href = link.href.split(/[?#]/)[0],
29 args = Qs.parse(link.search.substring(1)),
30 editlink = $(link).hasClass("editlink");
35 delete args.changeset;
37 if (object && editlink) {
38 args[object.type] = object.id;
41 var query = Qs.stringify(args);
42 if (query) href += "?" + query;
46 lon: "lon" in loc ? loc.lon : loc.lng,
50 if (layers && !editlink) {
54 href += OSM.formatHash(args);
59 // Disable the button group and also the buttons to avoid
60 // inconsistent behaviour when zooming
61 var editDisabled = zoom < 13;
63 .tooltip({ placement: "bottom" })
64 .tooltip(editDisabled ? "enable" : "disable")
65 .toggleClass("disabled", editDisabled)
67 .toggleClass("disabled", editDisabled);
70 window.maximiseMap = function () {
71 $("#content").addClass("maximised");
74 window.minimiseMap = function () {
75 $("#content").removeClass("maximised");
78 $(document).ready(function () {
80 .attr("title", I18n.t("javascripts.site.edit_disabled_tooltip"));
85 function updateHeader() {
86 var windowWidth = $(window).width();
88 if (windowWidth < compactWidth) {
89 $("body").removeClass("compact-nav").addClass("small-nav");
90 } else if (windowWidth < headerWidth) {
91 $("body").addClass("compact-nav").removeClass("small-nav");
93 $("body").removeClass("compact-nav").removeClass("small-nav");
98 * Chrome 60 and later seem to fire the "ready" callback
99 * before the DOM is fully ready causing us to measure the
100 * wrong sizes for the header elements - use a 0ms timeout
101 * to defer the measurement slightly as a workaround.
103 setTimeout(function () {
104 $("header").children(":visible").each(function (i, e) {
105 headerWidth = headerWidth + $(e).outerWidth();
108 $("body").addClass("compact-nav");
110 $("header").children(":visible").each(function (i, e) {
111 compactWidth = compactWidth + $(e).outerWidth();
114 $("body").removeClass("compact-nav");
118 $(window).resize(updateHeader);
121 $("#menu-icon").on("click", function (e) {
123 $("header").toggleClass("closed");
126 $("nav.primary li a").on("click", function () {
127 $("header").toggleClass("closed");
130 var application_data = $("head").data();
132 I18n.default_locale = OSM.DEFAULT_LOCALE;
133 I18n.locale = application_data.locale;
134 I18n.fallbacks = true;
136 OSM.preferred_editor = application_data.preferredEditor;
138 if (application_data.user) {
139 OSM.user = application_data.user;
141 if (application_data.userHome) {
142 OSM.home = application_data.userHome;
146 if (application_data.location) {
147 OSM.location = application_data.location;