mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
added popstate functionality
This commit is contained in:
@@ -21,11 +21,13 @@ var ajaxify = {};
|
||||
|
||||
|
||||
window.onpopstate = function(event) {
|
||||
// this breaks reloading and results in ajaxify.go calling twice, believe it messes around with sockets. ill come back for you later bitchez
|
||||
// ajaxify.go(document.location.href.replace(rootUrl +'/', ''));
|
||||
console.log('popstate called:', event);
|
||||
if (event !== null && event.state && event.state.url) ajaxify.go(event.state.url, null, null, true);
|
||||
};
|
||||
|
||||
ajaxify.go = function(url, callback, custom_tpl) {
|
||||
ajaxify.go = function(url, callback, template, quiet) {
|
||||
console.log('go', url, quiet);
|
||||
// "quiet": If set to true, will not call pushState
|
||||
|
||||
// leave room and join global
|
||||
app.enter_room('global');
|
||||
@@ -41,7 +43,12 @@ var ajaxify = {};
|
||||
}
|
||||
|
||||
if (templates[tpl_url]) {
|
||||
window.history.pushState({}, url, "/" + url);
|
||||
if (quiet !== true) {
|
||||
console.log('pushing state');
|
||||
window.history.pushState({
|
||||
"url": url
|
||||
}, url, "/" + url);
|
||||
}
|
||||
|
||||
jQuery('#footer').fadeOut(100);
|
||||
jQuery('#content').fadeOut(100);
|
||||
@@ -55,7 +62,7 @@ var ajaxify = {};
|
||||
}
|
||||
|
||||
jQuery('#content, #footer').fadeIn(200);
|
||||
}, custom_tpl);
|
||||
}, url, template);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user