From 030ce95deaeda367d67f64b49fc7a6834de1fc2b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 5 Dec 2013 17:35:44 -0500 Subject: [PATCH] closed #615 - added "active chats" dropdown to header - some minor tweaks also, to make taskbar work a little better with chats --- public/language/en/global.json | 5 +++-- public/src/forum/footer.js | 28 ++++++++++++++++++++++++++++ public/src/modules/chat.js | 1 + public/src/modules/taskbar.js | 8 +++++++- public/templates/header.tpl | 11 ++++++++++- src/messaging.js | 20 ++++++++++++++++++++ src/websockets.js | 15 +++++++++++++-- 7 files changed, 82 insertions(+), 6 deletions(-) diff --git a/public/language/en/global.json b/public/language/en/global.json index 00576a18be..32ea294957 100644 --- a/public/language/en/global.json +++ b/public/language/en/global.json @@ -5,7 +5,7 @@ "403.title": "Access Denied", "403.message": "You seem to have stumbled upon a page that you do not have access to. Perhaps you should try logging in?", "404.title": "Not Found", - "404.message": "You seem to have stumbled upon a page that does not exist. Return to the home page.", + "404.message": "You seem to have stumbled upon a page that does not exist. Return to the home page.", "500.title": "Internal error.", "500.message": "Ooops! Looks like something went wrong!", "logout": "Logout", @@ -16,5 +16,6 @@ "header.unread": "Unread", "header.users": "Users", "header.search": "Search", - "notifications.loading": "Loading Notifications" + "notifications.loading": "Loading Notifications", + "chats.loading": "Loading Chats" } \ No newline at end of file diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 9de817550c..a496ee7c95 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -175,6 +175,34 @@ Tinycon.setBubble(savedCount+1); }); + // Chats Dropdown + var chatsToggleEl = $('#chat_dropdown'), + chatsListEl = $('#chat-list'), + chatDropdownEl = chatsToggleEl.parent(); + chatsToggleEl.on('click', function() { + if (chatDropdownEl.hasClass('open')) { + return; + } + + socket.emit('api:chats.list', function(chats) { + var chatsFrag = document.createDocumentFragment(), + chatEl = document.createElement('li'), + numChats = chats.length, + x, userObj; + + for(x=0;x' + userObj.username + ''; + + chatsFrag.appendChild(chatEl.cloneNode(true)); + } + + chatsListEl.empty(); + chatsListEl.html(chatsFrag); + // console.log('received chats: ', chats); + }); + }); socket.on('chatMessage', function(data) { diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 8afcd129ad..2aeb2f02bf 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -102,6 +102,7 @@ define(['taskbar'], function(taskbar) { chatModal.show(); module.bringModalToTop(chatModal); checkOnlineStatus(chatModal); + taskbar.updateActive(uuid); } module.minimize = function(uuid) { diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index 131e52ada1..df7e8c460d 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -87,6 +87,11 @@ define(function() { toggleNew: function(uuid, state) { var btnEl = $(taskbar.tasklist.querySelector('[data-uuid="' + uuid + '"]')); btnEl.toggleClass('new', state); + }, + updateActive: function(uuid) { + var tasks = $(taskbar.tasklist).find('li'); + tasks.removeClass('active'); + tasks.filter('[data-uuid="' + uuid + '"]').addClass('active'); } } @@ -98,6 +103,7 @@ define(function() { push: taskbar.push, discard: taskbar.discard, minimize: taskbar.minimize, - toggleNew: taskbar.toggleNew + toggleNew: taskbar.toggleNew, + updateActive: taskbar.updateActive } }); \ No newline at end of file diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 3493ecd75c..b1a2b48479 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -89,7 +89,7 @@ - + +