3 //= require jquery.timers
 
   4 //= require jquery.cookie
 
   5 //= require jquery.throttle-debounce
 
   6 //= require bootstrap.tooltip
 
   7 //= require bootstrap.dropdown
 
  10 //= require leaflet.osm
 
  11 //= require leaflet.map
 
  12 //= require leaflet.zoom
 
  13 //= require leaflet.locationfilter
 
  18 //= require querystring
 
  20 var querystring = require("querystring-component");
 
  23  * Called as the user scrolls/zooms around to maniplate 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 = querystring.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 = querystring.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   var editDisabled = zoom < 13;
 
  61     .tooltip({placement: "bottom"})
 
  63     .on("click.minzoom", function() { return !editDisabled; })
 
  64     .toggleClass("disabled", editDisabled)
 
  65     .attr("data-original-title", editDisabled ?
 
  66       I18n.t("javascripts.site.edit_disabled_tooltip") : "");
 
  69 window.maximiseMap = function () {
 
  70   $("#content").addClass("maximised");
 
  73 window.minimiseMap = function () {
 
  74   $("#content").removeClass("maximised");
 
  77 $(document).ready(function () {
 
  81   function updateHeader() {
 
  82     var windowWidth = $(window).width();
 
  84     if (windowWidth < compactWidth) {
 
  85       $("body").removeClass("compact").addClass("small");
 
  86     } else if (windowWidth < headerWidth) {
 
  87       $("body").addClass("compact").removeClass("small");
 
  89       $("body").removeClass("compact").removeClass("small");
 
  94    * Chrome 60 and later seem to fire the "ready" callback
 
  95    * before the DOM is fully ready causing us to measure the
 
  96    * wrong sizes for the header elements - use a 0ms timeout
 
  97    * to defer the measurement slightly as a workaround.
 
  99   setTimeout(function () {
 
 100     $("header").children(":visible").each(function (i,e) {
 
 101       headerWidth = headerWidth + $(e).outerWidth();
 
 104     $("body").addClass("compact");
 
 106     $("header").children(":visible").each(function (i,e) {
 
 107       compactWidth = compactWidth + $(e).outerWidth();
 
 110     $("body").removeClass("compact");
 
 114     $(window).resize(updateHeader);
 
 117   $("#menu-icon").on("click", function(e) {
 
 119     $("header").toggleClass("closed");
 
 122   $("nav.primary li a").on("click", function() {
 
 123     $("header").toggleClass("closed");
 
 126   var application_data = $("head").data();
 
 128   I18n.default_locale = OSM.DEFAULT_LOCALE;
 
 129   I18n.locale = application_data.locale;
 
 130   I18n.fallbacks = true;
 
 132   OSM.preferred_editor = application_data.preferredEditor;
 
 134   if (application_data.user) {
 
 135     OSM.user = application_data.user;
 
 137     if (application_data.userHome) {
 
 138       OSM.home = application_data.userHome;
 
 142   if (application_data.location) {
 
 143     OSM.location = application_data.location;