3 //= require jquery.timers
4 //= require jquery.cookie
5 //= require jquery.throttle-debounce
7 //= require bootstrap-sprockets
10 //= require leaflet.osm
11 //= require leaflet.map
12 //= require leaflet.zoom
13 //= require leaflet.locationfilter
18 //= require querystring
21 * Called as the user scrolls/zooms around to manipulate hrefs of the
22 * view tab and various other links
24 window.updateLinks = function (loc, zoom, layers, object) {
25 $(".geolink").each(function (index, link) {
26 var querystring = require("querystring-component"),
27 href = link.href.split(/[?#]/)[0],
28 args = querystring.parse(link.search.substring(1)),
29 editlink = $(link).hasClass("editlink");
34 delete args.changeset;
36 if (object && editlink) {
37 args[object.type] = object.id;
40 var query = querystring.stringify(args);
41 if (query) href += "?" + query;
45 lon: "lon" in loc ? loc.lon : loc.lng,
49 if (layers && !editlink) {
53 href += OSM.formatHash(args);
58 var editDisabled = zoom < 13;
60 .tooltip({ placement: "bottom" })
62 .on("click.minzoom", function () { return !editDisabled; })
63 .toggleClass("disabled", editDisabled)
64 .attr("data-original-title", editDisabled ?
65 I18n.t("javascripts.site.edit_disabled_tooltip") : "");
68 window.maximiseMap = function () {
69 $("#content").addClass("maximised");
72 window.minimiseMap = function () {
73 $("#content").removeClass("maximised");
76 $(document).ready(function () {
80 function updateHeader() {
81 var windowWidth = $(window).width();
83 if (windowWidth < compactWidth) {
84 $("body").removeClass("compact").addClass("small");
85 } else if (windowWidth < headerWidth) {
86 $("body").addClass("compact").removeClass("small");
88 $("body").removeClass("compact").removeClass("small");
93 * Chrome 60 and later seem to fire the "ready" callback
94 * before the DOM is fully ready causing us to measure the
95 * wrong sizes for the header elements - use a 0ms timeout
96 * to defer the measurement slightly as a workaround.
98 setTimeout(function () {
99 $("header").children(":visible").each(function (i, e) {
100 headerWidth = headerWidth + $(e).outerWidth();
103 $("body").addClass("compact");
105 $("header").children(":visible").each(function (i, e) {
106 compactWidth = compactWidth + $(e).outerWidth();
109 $("body").removeClass("compact");
113 $(window).resize(updateHeader);
116 $("#menu-icon").on("click", function (e) {
118 $("header").toggleClass("closed");
121 $("nav.primary li a").on("click", function () {
122 $("header").toggleClass("closed");
125 var application_data = $("head").data();
127 I18n.default_locale = OSM.DEFAULT_LOCALE;
128 I18n.locale = application_data.locale;
129 I18n.fallbacks = true;
131 OSM.preferred_editor = application_data.preferredEditor;
133 if (application_data.user) {
134 OSM.user = application_data.user;
136 if (application_data.userHome) {
137 OSM.home = application_data.userHome;
141 if (application_data.location) {
142 OSM.location = application_data.location;