mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: client-side taskbar.update method, deprecates .updateTitle()
This commit is contained in:
@@ -124,7 +124,9 @@ define('chat', [
|
|||||||
var newTitle = $('<div/>').html(data.newName).text();
|
var newTitle = $('<div/>').html(data.newName).text();
|
||||||
var modal = module.getModal(data.roomId);
|
var modal = module.getModal(data.roomId);
|
||||||
modal.find('[component="chat/room/name"]').text(newTitle);
|
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, {
|
$(window).trigger('action:chat.renamed', Object.assign(data, {
|
||||||
modal: modal,
|
modal: modal,
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -155,9 +155,8 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator
|
|||||||
|
|
||||||
var taskbarEl = $('<li />')
|
var taskbarEl = $('<li />')
|
||||||
.addClass(data.options.className)
|
.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.icon ? '<i class="fa ' + data.options.icon + '"></i> ' : '') +
|
||||||
(data.options.image ? '<img src="' + data.options.image + '"/> ' : '') +
|
|
||||||
'<span component="taskbar/title">' + title + '</span>' +
|
'<span component="taskbar/title">' + title + '</span>' +
|
||||||
'</a>')
|
'</a>')
|
||||||
.attr({
|
.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) {
|
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);
|
taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"] [component="taskbar/title"]').text(newTitle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user