From d711a4e334d79e940075461fac9073d607b05445 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 24 Apr 2013 20:40:34 +0000 Subject: [PATCH] added post button, post window, added click handler to toaster alert, started on posts and topics schema and code --- app.js | 4 ++ public/src/app.js | 48 ++++++++++++- public/templates/footer.tpl | 2 +- public/templates/header.tpl | 77 ++++++++++++++++++++- public/templates/home.tpl | 9 ++- public/vendor/ajaxify/ajaxify.js | 70 ------------------- src/posts.js | 40 +++++++++++ src/topics.js | 111 +++++++++++++++++++++++++++++++ src/webserver.js | 12 ---- src/websockets.js | 4 ++ 10 files changed, 289 insertions(+), 88 deletions(-) delete mode 100644 public/vendor/ajaxify/ajaxify.js create mode 100644 src/posts.js create mode 100644 src/topics.js diff --git a/app.js b/app.js index 447b0ff314..1a5e97b762 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,7 @@ var modules = { user: require('./src/user.js'), + topics: require('./src/topics.js'), + posts: require('./src/posts.js'), templates: require('./src/templates.js'), webserver: require('./src/webserver.js'), websockets: require('./src/websockets.js') @@ -11,6 +13,8 @@ var modules = { global.configuration = {}; global.modules = modules; +// change this to = null when auth module is complete +global.uid = 1; diff --git a/public/src/app.js b/public/src/app.js index e6363b710b..07fe1ad0e4 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -2,6 +2,7 @@ var socket, config, app = {}; +// todo: cleanup,etc (function() { $.ajax({ @@ -42,7 +43,7 @@ var socket, p.innerHTML = params.message; strong.innerHTML = params.title; - div.className = "alert " + ((params.type=='warning') ? '' : "alert-" + params.type); + div.className = "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type); div.setAttribute('id', alert_id); div.appendChild(button); @@ -61,9 +62,52 @@ var socket, if (params.timeout) { setTimeout(function() { - jQuery(div).fadeOut('1000'); + jQuery(div).fadeOut(1000); }, params.timeout) } + + if (params.clickfn) { + div.onclick = function() { + params.clickfn(); + jQuery(div).fadeOut(500); + } + } } + var post_window = null; + app.open_post_window = function() { + post_window = post_window || document.getElementById('post_window'); + + jQuery(post_window).slideToggle(250); + + }; + + app.post_topic = function() { + var title = document.getElementById('post_title').innerHTML, + content = document.getElementById('post_content').innerHTML; + + if (title.length < 5 || content.length < 5) { + app.alert({ + title: 'Topic Post Failure', + message: 'You need to write more dude.', + type: 'error', + timeout: 2000, + clickfn: function() { + ajaxify.go('register'); + } + }); + + return; + } + + socket.emit('topics.post', { + 'title' : title, + 'content' : content + }); + jQuery(post_window).slideToggle(250); + }; + + jQuery('document').ready(function() { + jQuery('#post_window').slideToggle(0); + }) }()); diff --git a/public/templates/footer.tpl b/public/templates/footer.tpl index 279d1389c1..0b37f9001e 100644 --- a/public/templates/footer.tpl +++ b/public/templates/footer.tpl @@ -2,7 +2,7 @@ -
+

diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 43d9eb967b..93187a3f2b 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -10,6 +10,7 @@ + @@ -47,6 +94,32 @@
-
-
+
+
+
+ +
+
+
+
+ +
+
+ + + + +
+ +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/public/templates/home.tpl b/public/templates/home.tpl index 9e208b7747..0689a42334 100644 --- a/public/templates/home.tpl +++ b/public/templates/home.tpl @@ -1,6 +1,13 @@ -dis is home nibs +