Skip to content

Node.js based forum software built for the modern web

moved event alert to serverside, now node controls the registration alert. added some transition animation to page changes

psychobunnya06b3519a16a
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index 0b588571f4..437c4e5792 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -18,13 +18,19 @@ var ajaxify = {};
current_state = url;
window.history.pushState({}, url, "/" + url);
- content.innerHTML = templates[tpl_url];
- exec_body_scripts(content);
-
- ajaxify.enable();
- if (callback) {
- callback();
- }
+
+ jQuery('#content').fadeOut(100, function() {
+ content.innerHTML = templates[tpl_url];
+ exec_body_scripts(content);
+
+ ajaxify.enable();
+ if (callback) {
+ callback();
+ }
+
+ jQuery('#content').fadeIn(200);
+ });
+
}
return true;
@@ -42,6 +48,7 @@ var ajaxify = {};
if (ajaxify.go(url)) {
ev.preventDefault();
+ return false;
}
}
diff --git a/public/src/app.js b/public/src/app.js
index 7418b2d5a6..5cd1063bc1 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -13,6 +13,10 @@ var socket,
socket.on('event:connect', function(data) {
});
+
+ socket.on('event:alert', function(data) {
+ app.alert(data);
+ });
},
async: false
diff --git a/public/templates/register.tpl b/public/templates/register.tpl
index db2dda181e..f748ef8dae 100644
--- a/public/templates/register.tpl
+++ b/public/templates/register.tpl
@@ -54,14 +54,7 @@
socket.on('user.create', function(data) {
//console.log('user create: ' + data.status);
- ajaxify.go('/', function() {
- app.alert({
- title: 'Thank you for registering',
- message: 'You have successfully registered - welcome to nodebb!',
- type: 'notify',
- timeout: 2000
- });
- });
+ ajaxify.go('/');
});
socket.on('user.exists', function(data) {
diff --git a/src/user.js b/src/user.js
index bb399ddff2..2d1a8b8cc5 100644
--- a/src/user.js
+++ b/src/user.js
@@ -65,6 +65,13 @@ var RDB = require('./redis.js');
io.sockets.emit('user.latest', {username: username});
global.socket.emit('user.create', {'status': 1});
+
+ global.socket.emit('event:alert', {
+ title: 'Thank you for registering',
+ message: 'You have successfully registered - welcome to nodebb!',
+ type: 'notify',
+ timeout: 2000
+ });
});
});
};