lots of tweaks to chat and taskbar

v1.18.x
Julian Lam 11 years ago
parent 16e07d475f
commit fe4aee177d

@ -183,11 +183,16 @@
if (chat.modalExists(data.fromuid)) { if (chat.modalExists(data.fromuid)) {
modal = chat.getModal(data.fromuid); modal = chat.getModal(data.fromuid);
chat.appendChatMessage(modal, data.message, data.timestamp); chat.appendChatMessage(modal, data.message, data.timestamp);
if (modal.is(":visible")) {
chat.load(modal.attr('UUID'));
} else {
chat.toggleNew(modal.attr('UUID'), true);
}
} else { } else {
modal = chat.createModal(data.username, data.fromuid); modal = chat.createModal(data.username, data.fromuid);
chat.toggleNew(modal.attr('UUID'), true);
} }
chat.load(modal.attr('UUID'));
}); });
}); });

@ -67,7 +67,8 @@ define(['taskbar'], function(taskbar) {
chatModal.find('.close').on('click', function(e) { chatModal.find('.close').on('click', function(e) {
clearInterval(chatModal.intervalId); clearInterval(chatModal.intervalId);
chatModal.intervalId = 0; chatModal.intervalId = 0;
chatModal.hide(); chatModal.remove();
chatModal.data('modal', null);
taskbar.discard('chat', uuid); taskbar.discard('chat', uuid);
}); });
@ -81,7 +82,11 @@ define(['taskbar'], function(taskbar) {
checkOnlineStatus(chatModal); checkOnlineStatus(chatModal);
}); });
taskbar.push('chat', chatModal.attr('UUID'), {title:'<i class="fa fa-comment"></i> ' + username}); taskbar.push('chat', chatModal.attr('UUID'), {
title:'<i class="fa fa-comment"></i> ' + username,
state: ''
});
return chatModal; return chatModal;
} }
@ -149,7 +154,11 @@ define(['taskbar'], function(taskbar) {
chatContent.scrollTop( chatContent.scrollTop(
chatContent[0].scrollHeight - chatContent.height() chatContent[0].scrollHeight - chatContent.height()
); );
} };
module.toggleNew = function(uuid, state) {
taskbar.toggleNew(uuid, state);
};
return module; return module;
}); });

@ -25,6 +25,7 @@ define(function() {
if (_btn.className.indexOf('active') === -1) { if (_btn.className.indexOf('active') === -1) {
taskbar.minimizeAll(); taskbar.minimizeAll();
module.load(uuid); module.load(uuid);
taskbar.toggleNew(uuid, false);
// Highlight the button // Highlight the button
$(taskbar.tasklist).removeClass('active'); $(taskbar.tasklist).removeClass('active');
@ -69,7 +70,7 @@ define(function() {
'</a>'; '</a>';
btnEl.setAttribute('data-module', module); btnEl.setAttribute('data-module', module);
btnEl.setAttribute('data-uuid', uuid); 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(); if (!options.state || options.state === 'active') taskbar.minimizeAll();
taskbar.tasklist.appendChild(btnEl); taskbar.tasklist.appendChild(btnEl);
@ -82,14 +83,21 @@ define(function() {
}, },
minimizeAll: function() { minimizeAll: function() {
$(taskbar.tasklist.querySelectorAll('.active')).removeClass('active'); $(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 { return {
push: taskbar.push, push: taskbar.push,
discard: taskbar.discard, discard: taskbar.discard,
minimize: taskbar.minimize minimize: taskbar.minimize,
toggleNew: taskbar.toggleNew
} }
}); });
Loading…
Cancel
Save