Update title on pushState, closes #33

This commit is contained in:
Aaron Lidman 2013-11-08 16:10:08 -08:00
parent 1107787f08
commit 1ae7872ed8
19 changed files with 60 additions and 20 deletions

View file

@ -235,7 +235,11 @@ $(document).ready(function () {
page.pushstate = page.popstate = function(path) {
$("#content").addClass("overlay-sidebar");
map.invalidateSize();
$('#sidebar_content').load(path);
$('#sidebar_content').load(path, function(a, b, xhr) {
if (xhr.getResponseHeader('X-Page-Title')) {
document.title = xhr.getResponseHeader('X-Page-Title');
}
});
};
page.unload = function() {
@ -250,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, function(a, b, xhr) {
if (xhr.getResponseHeader('X-Page-Title')) {
document.title = xhr.getResponseHeader('X-Page-Title');
}
page.load(path, type, id);
});
};

View file

@ -51,7 +51,12 @@ OSM.Export = function(map) {
page.pushstate = page.popstate = function(path) {
$("#export_tab").addClass("current");
$("#sidebar_content").load(path, page.load);
$("#sidebar_content").load(path, function(a, b, xhr) {
if (xhr.getResponseHeader('X-Page-Title')) {
document.title = xhr.getResponseHeader('X-Page-Title');
}
page.load();
});
};
page.load = function() {

View file

@ -47,7 +47,7 @@ OSM.History = function(map) {
url: window.location.pathname,
method: "GET",
data: {bbox: map.getBounds().toBBoxString()},
success: function(html) {
success: function(html, status, xhr) {
$('#sidebar_content .changesets').html(html);
updateMap();
}
@ -99,7 +99,12 @@ OSM.History = function(map) {
page.pushstate = page.popstate = function(path) {
$("#history_tab").addClass("current");
$("#sidebar_content").load(path, page.load);
$("#sidebar_content").load(path, function(a, b, xhr) {
if (xhr.getResponseHeader('X-Page-Title')) {
document.title = xhr.getResponseHeader('X-Page-Title');
}
page.load();
});
};
page.load = function() {

View file

@ -49,7 +49,12 @@ OSM.Search = function(map) {
page.pushstate = page.popstate = function(path) {
var params = querystring.parse(path.substring(path.indexOf('?') + 1));
$("#query").val(params.query);
$("#sidebar_content").load(path, page.load);
$("#sidebar_content").load(path, function() {
if (xhr.getResponseHeader('X-Page-Title')) {
document.title = xhr.getResponseHeader('X-Page-Title');
}
page.load();
});
};
page.load = function() {