Merge branch 'popstate'

v1.18.x
Julian Lam 12 years ago
commit 315cf9a88d

@ -21,11 +21,13 @@ var ajaxify = {};
window.onpopstate = function(event) { 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 console.log('popstate called:', event);
// ajaxify.go(document.location.href.replace(rootUrl +'/', '')); 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 // leave room and join global
app.enter_room('global'); app.enter_room('global');
@ -41,7 +43,12 @@ var ajaxify = {};
} }
if (templates[tpl_url]) { 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('#footer').fadeOut(100);
jQuery('#content').fadeOut(100); jQuery('#content').fadeOut(100);
@ -55,7 +62,7 @@ var ajaxify = {};
} }
jQuery('#content, #footer').fadeIn(200); jQuery('#content, #footer').fadeIn(200);
}, custom_tpl); }, url, template);
return true; return true;

@ -160,14 +160,12 @@ var templates = {};
}()); }());
function load_template(callback, custom_tpl) { function load_template(callback, url, template) {
var location = document.location || window.location, var location = document.location || window.location,
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''); rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
var url = location.href.replace(rootUrl +'/', '');
url = (url === '' || url === '/') ? 'home' : url; url = (url === '' || url === '/') ? 'home' : url;
jQuery.get(API_URL + url, function(data) { jQuery.get(API_URL + url, function(data) {
var tpl = templates.get_custom_map(url); var tpl = templates.get_custom_map(url);

Loading…
Cancel
Save