diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index ba3ccd04c2..9cedb24bd3 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -44,43 +44,20 @@ define('taskbar', function() { }; taskbar.push = function(module, uuid, options) { + var element = taskbar.tasklist.find('li[data-uuid="' + uuid + '"]'); + var data = { module: module, uuid: uuid, - options: options + options: options, + element: element }; $(window).trigger('filter:taskbar.push', data); - var element = taskbar.tasklist.find('li[data-uuid="' + data.uuid + '"]'); - - if (element.length) { - return; - } - - var title = $('
').text(data.options.title || 'NodeBB Task').html(); - - var btnEl = $('
  • ') - .addClass(data.options.className) - .html('' + - (data.options.icon ? ' ' : '') + - (data.options.image ? ' ': '') + - '' + title + '' + - '') - .attr({ - 'data-module': data.module, - 'data-uuid': data.uuid - }) - .addClass(data.options.state !== undefined ? data.options.state : 'active'); - - if (!data.options.state || data.options.state === 'active') { - minimizeAll(); + if (!element.length) { + createTaskbar(data); } - - taskbar.tasklist.append(btnEl); - update(); - - $(window).trigger('action:taskbar.pushed'); }; taskbar.minimize = function(module, uuid) { @@ -118,5 +95,31 @@ define('taskbar', function() { taskbar.tasklist.find('.active').removeClass('active'); } + function createTaskbar(data) { + var title = $('
    ').text(data.options.title || 'NodeBB Task').html(); + + var btnEl = $('
  • ') + .addClass(data.options.className) + .html('' + + (data.options.icon ? ' ' : '') + + (data.options.image ? ' ': '') + + '' + title + '' + + '') + .attr({ + 'data-module': data.module, + 'data-uuid': data.uuid + }) + .addClass(data.options.state !== undefined ? data.options.state : 'active'); + + if (!data.options.state || data.options.state === 'active') { + minimizeAll(); + } + + taskbar.tasklist.append(btnEl); + update(); + + $(window).trigger('action:taskbar.pushed'); + } + return taskbar; });