From fe4aee177d86614ec4315c401883155ca1cc8cd9 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 4 Dec 2013 21:44:36 -0500 Subject: [PATCH] lots of tweaks to chat and taskbar --- public/src/forum/footer.js | 9 +++++++-- public/src/modules/chat.js | 15 ++++++++++++--- public/src/modules/taskbar.js | 14 +++++++++++--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 8ce1831a54..1fe343d929 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -183,11 +183,16 @@ if (chat.modalExists(data.fromuid)) { modal = chat.getModal(data.fromuid); chat.appendChatMessage(modal, data.message, data.timestamp); + + if (modal.is(":visible")) { + chat.load(modal.attr('UUID')); + } else { + chat.toggleNew(modal.attr('UUID'), true); + } } else { modal = chat.createModal(data.username, data.fromuid); + chat.toggleNew(modal.attr('UUID'), true); } - - chat.load(modal.attr('UUID')); }); }); diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index fefe6110e2..8afcd129ad 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -67,7 +67,8 @@ define(['taskbar'], function(taskbar) { chatModal.find('.close').on('click', function(e) { clearInterval(chatModal.intervalId); chatModal.intervalId = 0; - chatModal.hide(); + chatModal.remove(); + chatModal.data('modal', null); taskbar.discard('chat', uuid); }); @@ -81,7 +82,11 @@ define(['taskbar'], function(taskbar) { checkOnlineStatus(chatModal); }); - taskbar.push('chat', chatModal.attr('UUID'), {title:' ' + username}); + taskbar.push('chat', chatModal.attr('UUID'), { + title:' ' + username, + state: '' + }); + return chatModal; } @@ -149,7 +154,11 @@ define(['taskbar'], function(taskbar) { chatContent.scrollTop( chatContent[0].scrollHeight - chatContent.height() ); - } + }; + + module.toggleNew = function(uuid, state) { + taskbar.toggleNew(uuid, state); + }; return module; }); \ No newline at end of file diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index 0fbdd76da9..131e52ada1 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -25,6 +25,7 @@ define(function() { if (_btn.className.indexOf('active') === -1) { taskbar.minimizeAll(); module.load(uuid); + taskbar.toggleNew(uuid, false); // Highlight the button $(taskbar.tasklist).removeClass('active'); @@ -69,7 +70,7 @@ define(function() { ''; btnEl.setAttribute('data-module', module); btnEl.setAttribute('data-uuid', uuid); - btnEl.className = options.state || 'active'; + btnEl.className = options.state !== undefined ? options.state : 'active'; if (!options.state || options.state === 'active') taskbar.minimizeAll(); taskbar.tasklist.appendChild(btnEl); @@ -82,14 +83,21 @@ define(function() { }, minimizeAll: function() { $(taskbar.tasklist.querySelectorAll('.active')).removeClass('active'); + }, + toggleNew: function(uuid, state) { + var btnEl = $(taskbar.tasklist.querySelector('[data-uuid="' + uuid + '"]')); + btnEl.toggleClass('new', state); } } - if (!taskbar.initialized) taskbar.init(); + if (!taskbar.initialized) { + taskbar.init(); + } return { push: taskbar.push, discard: taskbar.discard, - minimize: taskbar.minimize + minimize: taskbar.minimize, + toggleNew: taskbar.toggleNew } }); \ No newline at end of file