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 $("header").children(":visible").each(function (i,e) {
83 headerWidth = headerWidth + $(e).outerWidth();
86 $("body").addClass("compact");
88 $("header").children(":visible").each(function (i,e) {
89 compactWidth = compactWidth + $(e).outerWidth();
92 $("body").removeClass("compact");
94 function updateHeader() {
95 var windowWidth = $(window).width();
97 if (windowWidth < compactWidth) {
98 $("body").removeClass("compact").addClass("small");
99 } else if (windowWidth < headerWidth) {
100 $("body").addClass("compact").removeClass("small");
102 $("body").removeClass("compact").removeClass("small");
108 $(window).resize(updateHeader);
110 $("#menu-icon").on("click", function(e) {
112 $("header").toggleClass("closed");
115 $("nav.primary li a").on("click", function() {
116 $("header").toggleClass("closed");
119 var application_data = $("head").data();
121 I18n.default_locale = OSM.DEFAULT_LOCALE;
122 I18n.locale = application_data.locale;
123 I18n.fallbacks = true;
125 OSM.preferred_editor = application_data.preferredEditor;
127 if (application_data.user) {
128 OSM.user = application_data.user;
130 if (application_data.userHome) {
131 OSM.home = application_data.userHome;
135 if (application_data.location) {
136 OSM.location = application_data.location;