]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Replace Vary header with explicit xhr=1 param
[rails.git] / app / assets / javascripts / index.js
index 2ed869905995753fecea8b6515c4f72ed63414cc..5e96c35174a6f66fb106b58c7ffe6fb234689e48 100644 (file)
@@ -102,16 +102,6 @@ $(document).ready(function () {
   map.dataLayer = new L.OSM.DataLayer(null);
   map.dataLayer.options.code = 'D';
 
-  if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
-    if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
-      map.addLayer(map.noteLayer);
-    }
-
-    if (params.layers.indexOf(map.dataLayer.options.code) >= 0) {
-      map.addLayer(map.dataLayer);
-    }
-  }
-
   var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
 
   L.OSM.zoom({position: position})
@@ -153,6 +143,18 @@ $(document).ready(function () {
   L.control.scale()
     .addTo(map);
 
+  if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
+    initializeNotes(map);
+    if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
+      map.addLayer(map.noteLayer);
+    }
+
+    initializeBrowse(map);
+    if (params.layers.indexOf(map.dataLayer.options.code) >= 0) {
+      map.addLayer(map.dataLayer);
+    }
+  }
+
   $('.leaflet-control .control-button').tooltip({placement: 'left', container: 'body'});
 
   map.on('moveend layeradd layerremove', function() {
@@ -227,16 +229,17 @@ $(document).ready(function () {
     });
   }
 
-  initializeBrowse(map);
-  initializeNotes(map);
-
   OSM.Index = function(map) {
     var page = {};
 
     page.pushstate = page.popstate = function(path) {
       $("#content").addClass("overlay-sidebar");
       map.invalidateSize();
-      $('#sidebar_content').load(path);
+      $('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) {
+        if (xhr.getResponseHeader('X-Page-Title')) {
+          document.title = xhr.getResponseHeader('X-Page-Title');
+        }
+      });
     };
 
     page.unload = function() {
@@ -251,7 +254,10 @@ $(document).ready(function () {
     var page = {};
 
     page.pushstate = page.popstate = function(path, type, id) {
-      $('#sidebar_content').load(path, function() {
+      $('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) {
+        if (xhr.getResponseHeader('X-Page-Title')) {
+          document.title = xhr.getResponseHeader('X-Page-Title');
+        }
         page.load(path, type, id);
       });
     };