Node.js based forum software built for the modern web
feat: client-side taskbar.update method, deprecates .updateTitle()
Julian Lam9b09ee0e932d
diff --git a/public/src/modules/chat.js b/public/src/modules/chat.jsindex 6381e523eb..4b1515f998 100644--- a/public/src/modules/chat.js+++ b/public/src/modules/chat.js@@ -124,7 +124,9 @@ define('chat', [var newTitle = $('<div/>').html(data.newName).text();var modal = module.getModal(data.roomId);modal.find('[component="chat/room/name"]').text(newTitle);- taskbar.updateTitle('chat', modal.attr('data-uuid'), newTitle);+ taskbar.update('chat', modal.attr('data-uuid'), {+ title: newTitle,+ });$(window).trigger('action:chat.renamed', Object.assign(data, {modal: modal,}));diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.jsindex 954c491580..701b14665d 100644--- a/public/src/modules/taskbar.js+++ b/public/src/modules/taskbar.js@@ -155,9 +155,8 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translatorvar taskbarEl = $('<li />').addClass(data.options.className)- .html('<a href="#">' ++ .html('<a href="#"' + (data.options.image ? ' style="background-image: url(\'' + data.options.image + '\');"' : '') + '>' +(data.options.icon ? '<i class="fa ' + data.options.icon + '"></i> ' : '') +- (data.options.image ? '<img src="' + data.options.image + '"/> ' : '') +'<span component="taskbar/title">' + title + '</span>' +'</a>').attr({@@ -182,7 +181,37 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator});}+ var processUpdate = function (element, key, value) {+ switch (key) {+ case 'title':+ element.find('[component="taskbar/title"]').text(value);+ break;+ case 'icon':+ element.find('i').attr('class', 'fa fa-' + value);+ break;+ case 'image':+ element.find('a').css('background-image', 'url("' + value + '")');+ break;+ case 'background-color':+ element.find('a').css('background-color', value);+ break;+ }+ };++ taskbar.update = function (module, uuid, options) {+ var element = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');+ var data = element.data();++ Object.keys(options).forEach(function (key) {+ data[key] = options[key];+ processUpdate(element, key, options[key]);+ });++ element.data(data);+ };+taskbar.updateTitle = function (module, uuid, newTitle) {+ console.warn('[taskbar] .updateTitle() is deprecated, use .update() instead');taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"] [component="taskbar/title"]').text(newTitle);};