fixes #392 - needs testing on try to see if google updates title correctly

order of events: 1. title changes, 2. content fades in, 3. history
pushState
v1.18.x
psychobunny 12 years ago
parent 0613b530e8
commit 754aef8a84

@ -61,14 +61,6 @@ var ajaxify = {};
} }
if (templates.is_available(tpl_url) && !templates.force_refresh(tpl_url)) { if (templates.is_available(tpl_url) && !templates.force_refresh(tpl_url)) {
if (quiet !== true) {
if (window.history && window.history.pushState) {
window.history.pushState({
"url": url
}, url, RELATIVE_PATH + "/" + url);
}
}
translator.load(tpl_url); translator.load(tpl_url);
jQuery('#footer, #content').fadeOut(100); jQuery('#footer, #content').fadeOut(100);
@ -84,7 +76,15 @@ var ajaxify = {};
callback(); callback();
} }
utils.refreshTitle(url, function() {
jQuery('#content, #footer').stop(true, true).fadeIn(200, function () { jQuery('#content, #footer').stop(true, true).fadeIn(200, function () {
if (quiet !== true) {
if (window.history && window.history.pushState) {
window.history.pushState({
"url": url
}, url, RELATIVE_PATH + "/" + url);
}
}
app.process_page(); app.process_page();
if (window.location.hash) if (window.location.hash)
@ -92,8 +92,7 @@ var ajaxify = {};
if (hash) if (hash)
app.scrollToPost(hash.substr(1)); app.scrollToPost(hash.substr(1));
}); });
});
utils.refreshTitle(url);
}, url, template); }, url, template);

@ -129,7 +129,7 @@
return tags; return tags;
}, },
refreshTitle: function(url) { refreshTitle: function(url, callback) {
if (!url) { if (!url) {
var a = document.createElement('a'); var a = document.createElement('a');
a.href = document.location; a.href = document.location;
@ -139,6 +139,10 @@
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) { socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title; document.title = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
if (callback) {
callback();
}
notificationIcon = notificationIcon || document.querySelector('.notifications a i'); notificationIcon = notificationIcon || document.querySelector('.notifications a i');
if (numNotifications > 0 && notificationIcon) notificationIcon.className = 'icon-circle active'; if (numNotifications > 0 && notificationIcon) notificationIcon.className = 'icon-circle active';
}); });

Loading…
Cancel
Save