mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
modified ajaxify slightly to make transitions between pages a bit more fluid (although first load doesn't look that awesome); fixed up rooms - resolved DRY failure and properly leave rooms
This commit is contained in:
@@ -26,20 +26,16 @@ 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);
|
||||
|
||||
jQuery('#content, #footer').fadeOut(100, function() {
|
||||
load_template(function() {
|
||||
|
||||
exec_body_scripts(content);
|
||||
|
||||
ajaxify.enable();
|
||||
@@ -47,8 +43,10 @@ var ajaxify = {};
|
||||
callback();
|
||||
}
|
||||
|
||||
jQuery('#content, #footer').fadeIn(200);
|
||||
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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,9 +39,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery('document').ready(function() {
|
||||
// join room for this thread - DRY failure, see ajaxify and app.js
|
||||
socket.emit('event:enter_room', 'topic_' + '{topic_id}');
|
||||
current_room = 'topic_' + '{topic_id}';
|
||||
app.enter_room('global', 'topic_' + '{topic_id}');
|
||||
set_up_posts();
|
||||
});
|
||||
|
||||
|
||||
@@ -69,8 +69,9 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}),
|
||||
|
||||
// BEGIN: API calls (todo: organize)
|
||||
// julian: :^)
|
||||
socket.on('event:enter_room', function(room) {
|
||||
socket.join(room);
|
||||
socket.on('event:enter_room', function(data) {
|
||||
if (data.leave !== null) socket.leave (data.leave);
|
||||
socket.join(data.enter);
|
||||
});
|
||||
|
||||
socket.on('api:user.get', function(data) {
|
||||
|
||||
Reference in New Issue
Block a user