Update title on pushState, closes #33
This commit is contained in:
parent
1107787f08
commit
1ae7872ed8
19 changed files with 60 additions and 20 deletions
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -62,7 +62,6 @@ class BrowseController < ApplicationController
|
|||
@way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'way_page')
|
||||
@relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'relation_page')
|
||||
|
||||
@title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
|
||||
@next = Changeset.where("id > ?", @changeset.id).order(:id => :asc).first
|
||||
@prev = Changeset.where("id < ?", @changeset.id).order(:id => :desc).first
|
||||
|
||||
|
@ -77,7 +76,6 @@ class BrowseController < ApplicationController
|
|||
def note
|
||||
@type = "note"
|
||||
@note = Note.find(params[:id])
|
||||
@title = "#{I18n.t('browse.note.title')} | #{@note.id}"
|
||||
@next = Note.visible.where("id > ?", @note.id).order(:id => :asc).first
|
||||
@prev = Note.visible.where("id < ?", @note.id).order(:id => :desc).first
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
11
app/helpers/title_helper.rb
Normal file
11
app/helpers/title_helper.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module TitleHelper
|
||||
def set_title(title = false)
|
||||
if title
|
||||
title = t('layouts.project_name.title') + ' | ' + title
|
||||
else
|
||||
title = t('layouts.project_name.title')
|
||||
end
|
||||
response.headers["X-Page-Title"] = title
|
||||
@title = title
|
||||
end
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
<% set_title("#{t('browse.changeset.title')} | #{@changeset.id}") %>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t 'browse.changeset.changeset', :id => @changeset.id %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @node
|
||||
@title = t('browse.node.node') + ' | ' + @name
|
||||
set_title(t('browse.node.node') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @node
|
||||
@title = t('browse.node_history.node_history') + ' | ' + @name
|
||||
set_title(t('browse.node_history.node_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<% set_title("#{t('browse.note.title')} | #{@note.id}") %>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t "browse.note.#{@note.status}_title", :note_name => @note.id %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @relation
|
||||
@title = t('browse.relation.relation') + ' | ' + @name
|
||||
set_title(t('browse.relation.relation') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @relation
|
||||
@title = t('browse.relation_history.relation_history') + ' | ' + @name
|
||||
set_title(t('browse.relation_history.relation_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @way
|
||||
@title = t('browse.way.way') + ' | ' + @name
|
||||
set_title(t('browse.way.way') + ' | ' + @name)
|
||||
%>
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
@name = printable_name @way
|
||||
@title = t('browse.way_history.way_history') + ' | ' + @name
|
||||
set_title(t('browse.way_history.way_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
<%
|
||||
if params[:friends] and @user
|
||||
@title = t 'changeset.list.title_friend'
|
||||
set_title(t 'changeset.list.title_friend')
|
||||
@heading = t 'changeset.list.title_friend'
|
||||
elsif params[:nearby] and @user
|
||||
@title = t 'changeset.list.title_nearby'
|
||||
set_title(t 'changeset.list.title_nearby')
|
||||
@heading = t 'changeset.list.title_nearby'
|
||||
elsif params[:display_name]
|
||||
@title = t 'changeset.list.title_user', :user => params[:display_name]
|
||||
set_title(t 'changeset.list.title_user', :user => params[:display_name])
|
||||
@heading = t('changeset.list.title_user', :user => link_to(params[:display_name], :controller => "user", :action => "view", :display_name => params[:display_name])).html_safe
|
||||
else
|
||||
@title = t 'changeset.list.title'
|
||||
set_title(t 'changeset.list.title')
|
||||
@heading = t 'changeset.list.title'
|
||||
end
|
||||
%>
|
||||
|
|
|
@ -45,5 +45,5 @@
|
|||
OSM.oauth_consumer_secret = "<%= @oauth.client_application.secret %>";
|
||||
<% end -%>
|
||||
</script>
|
||||
<title><%= t 'layouts.project_name.title' %><%= ' | '+ @title if @title %></title>
|
||||
<title><%= @title %></title>
|
||||
</head>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<% set_title(t('export.title')) %>
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t 'export.start_rjs.export' %>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<% content_for(:content_class) { "overlay-sidebar" } %>
|
||||
<%
|
||||
set_title()
|
||||
content_for(:content_class) { "overlay-sidebar" }
|
||||
%>
|
||||
|
||||
<% unless @user %>
|
||||
<div class="welcome">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue