feat: client-side taskbar.update method, deprecates .updateTitle()

v1.18.x
Julian Lam 5 years ago
parent 12ba589d69
commit 9b09ee0e93

@ -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,
}));

@ -155,9 +155,8 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator
var 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);
};

Loading…
Cancel
Save