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');
 
  24  * Called as the user scrolls/zooms around to maniplate hrefs of the
 
  25  * view tab and various other links
 
  27 window.updateLinks = function (loc, zoom, layers, object) {
 
  28   $(".geolink").each(function(index, link) {
 
  29     var 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").addClass("small");
 
  87     } else if (windowWidth < headerWidth) {
 
  88       $("body").addClass("compact").removeClass("small");
 
  90       $("body").removeClass("compact").removeClass("small");
 
  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");
 
 107     $("header").children(":visible").each(function (i,e) {
 
 108       compactWidth = compactWidth + $(e).outerWidth();
 
 111     $("body").removeClass("compact");
 
 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;