3 //= require jquery.timers
4 //= require jquery.cookie/jquery.cookie
5 //= require jquery.throttle-debounce
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 querystring
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 querystring = require("querystring-component"),
29 href = link.href.split(/[?#]/)[0],
30 args = querystring.parse(link.search.substring(1)),
31 editlink = $(link).hasClass("editlink");
36 delete args.changeset;
38 if (object && editlink) {
39 args[object.type] = object.id;
42 var query = querystring.stringify(args);
43 if (query) href += "?" + query;
47 lon: "lon" in loc ? loc.lon : loc.lng,
51 if (layers && !editlink) {
55 href += OSM.formatHash(args);
60 var editDisabled = zoom < 13;
62 .tooltip({ placement: "bottom" })
64 .on("click.minzoom", function () { return !editDisabled; })
65 .toggleClass("disabled", editDisabled)
66 .attr("data-original-title", editDisabled ?
67 I18n.t("javascripts.site.edit_disabled_tooltip") : "");
70 window.maximiseMap = function () {
71 $("#content").addClass("maximised");
74 window.minimiseMap = function () {
75 $("#content").removeClass("maximised");
78 $(document).ready(function () {
82 function updateHeader() {
83 var windowWidth = $(window).width();
85 if (windowWidth < compactWidth) {
86 $("body").removeClass("compact-nav").addClass("small-nav");
87 } else if (windowWidth < headerWidth) {
88 $("body").addClass("compact-nav").removeClass("small-nav");
90 $("body").removeClass("compact-nav").removeClass("small-nav");
95 * Chrome 60 and later seem to fire the "ready" callback
96 * before the DOM is fully ready causing us to measure the
97 * wrong sizes for the header elements - use a 0ms timeout
98 * to defer the measurement slightly as a workaround.
100 setTimeout(function () {
101 $("header").children(":visible").each(function (i, e) {
102 headerWidth = headerWidth + $(e).outerWidth();
105 $("body").addClass("compact-nav");
107 $("header").children(":visible").each(function (i, e) {
108 compactWidth = compactWidth + $(e).outerWidth();
111 $("body").removeClass("compact-nav");
115 $(window).resize(updateHeader);
118 $("#menu-icon").on("click", function (e) {
120 $("header").toggleClass("closed");
123 $("nav.primary li a").on("click", function () {
124 $("header").toggleClass("closed");
127 var application_data = $("head").data();
129 I18n.default_locale = OSM.DEFAULT_LOCALE;
130 I18n.locale = application_data.locale;
131 I18n.fallbacks = true;
133 OSM.preferred_editor = application_data.preferredEditor;
135 if (application_data.user) {
136 OSM.user = application_data.user;
138 if (application_data.userHome) {
139 OSM.home = application_data.userHome;
143 if (application_data.location) {
144 OSM.location = application_data.location;