diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 90f13142fa..97907a8b86 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -26,30 +26,28 @@ var ajaxify = {}; ajaxify.go = function(url, callback) { // leave room and join global - if (current_room != 'global') { - socket.emit('event:enter_room', 'global'); - current_room = 'global'; - } + app.enter_room('global'); var url = url.replace(/\/$/, ""); var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0]; if (templates[tpl_url]) { window.history.pushState({}, url, "/" + url); - - jQuery('#content, #footer').fadeOut(100); - - load_template(function() { - exec_body_scripts(content); - - ajaxify.enable(); - if (callback) { - callback(); - } - - jQuery('#content, #footer').fadeIn(200); + jQuery('#content, #footer').fadeOut(100, function() { + load_template(function() { + + exec_body_scripts(content); + + ajaxify.enable(); + if (callback) { + callback(); + } + + jQuery('#content, #footer').fadeIn(250); + }); }); + return true; } @@ -62,7 +60,6 @@ var ajaxify = {}; ajaxify.onclick = function(ev) { if (this.href == window.location.href + "#") return; - console.log(this.href); var url = this.href.replace(rootUrl +'/', ''); if (ajaxify.go(url)) { diff --git a/public/src/app.js b/public/src/app.js index 68f4894a43..90d8c8fbc2 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -1,7 +1,6 @@ var socket, config, app = {}, - current_room, API_URL = null; // todo: cleanup,etc @@ -172,11 +171,21 @@ var socket, jQuery(post_window).slideToggle(250); }; + + app.current_room = null; + app.enter_room = function(room) { + if (app.current_room === room) return; + + socket.emit('event:enter_room', { + 'enter': room, + 'leave': app.current_room + }); + + app.current_room = room; + }; + jQuery('document').ready(function() { - if (current_room != 'global') { - socket.emit('event:enter_room', 'global'); - current_room = 'global'; - } + app.enter_room('global'); // On menu click, change "active" state diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 5bd8dc23f8..1359100584 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -4,7 +4,7 @@
  • {topic_name}
  • - psychobunny, null, and 2 guests are browsing this thread
    +