From a06b3519a16af751ae9fc907960b56719ac505a0 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 23 Apr 2013 20:17:12 +0000 Subject: [PATCH] moved event alert to serverside, now node controls the registration alert. added some transition animation to page changes --- public/src/ajaxify.js | 21 ++++++++++++++------- public/src/app.js | 4 ++++ public/templates/register.tpl | 9 +-------- src/user.js | 7 +++++++ 4 files changed, 26 insertions(+), 15 deletions(-) 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 + }); }); }); };