mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
refactor: removed parsing for taskbar
harmony doesnt have a taskbar
This commit is contained in:
@@ -1,18 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, translator, hooks) {
|
define('taskbar', ['translator', 'hooks'], function (translator, hooks) {
|
||||||
const taskbar = {};
|
const taskbar = {};
|
||||||
|
let noTaskbar = false;
|
||||||
taskbar.init = function () {
|
taskbar.init = function () {
|
||||||
const self = this;
|
taskbar.taskbar = $('[component="taskbar"]');
|
||||||
|
taskbar.tasklist = taskbar.taskbar.find('ul');
|
||||||
Benchpress.render('modules/taskbar', {}).then(function (html) {
|
if (!taskbar.taskbar.length || !taskbar.tasklist.length) {
|
||||||
self.taskbar = $(html);
|
noTaskbar = true;
|
||||||
self.tasklist = self.taskbar.find('ul');
|
return;
|
||||||
$(document.body).append(self.taskbar);
|
}
|
||||||
|
taskbar.taskbar.on('click', 'li', async function () {
|
||||||
self.taskbar.on('click', 'li', async function () {
|
|
||||||
const $btn = $(this);
|
const $btn = $(this);
|
||||||
const moduleName = $btn.attr('data-module');
|
const moduleName = $btn.attr('data-module');
|
||||||
const uuid = $btn.attr('data-uuid');
|
const uuid = $btn.attr('data-uuid');
|
||||||
@@ -30,7 +29,6 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$(window).on('action:app.loggedOut', function () {
|
$(window).on('action:app.loggedOut', function () {
|
||||||
taskbar.closeAll();
|
taskbar.closeAll();
|
||||||
@@ -38,6 +36,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.close = async function (moduleName, uuid) {
|
taskbar.close = async function (moduleName, uuid) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Sends signal to the appropriate module's .close() fn (if present)
|
// Sends signal to the appropriate module's .close() fn (if present)
|
||||||
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
||||||
|
|
||||||
@@ -50,6 +51,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.closeAll = function (module) {
|
taskbar.closeAll = function (module) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// module is optional
|
// module is optional
|
||||||
let selector = '[data-uuid]';
|
let selector = '[data-uuid]';
|
||||||
|
|
||||||
@@ -63,6 +67,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.discard = function (module, uuid) {
|
taskbar.discard = function (module, uuid) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
||||||
btnEl.remove();
|
btnEl.remove();
|
||||||
|
|
||||||
@@ -71,6 +78,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
|
|
||||||
taskbar.push = function (module, uuid, options, callback) {
|
taskbar.push = function (module, uuid, options, callback) {
|
||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
|
if (noTaskbar) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
const element = taskbar.tasklist.find('li[data-uuid="' + uuid + '"]');
|
const element = taskbar.tasklist.find('li[data-uuid="' + uuid + '"]');
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
@@ -90,6 +100,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.get = function (module) {
|
taskbar.get = function (module) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const items = $('[data-module="' + module + '"]').map(function (idx, el) {
|
const items = $('[data-module="' + module + '"]').map(function (idx, el) {
|
||||||
return $(el).data();
|
return $(el).data();
|
||||||
});
|
});
|
||||||
@@ -98,11 +111,17 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.minimize = function (module, uuid) {
|
taskbar.minimize = function (module, uuid) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
const btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
||||||
btnEl.toggleClass('active', false);
|
btnEl.toggleClass('active', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
taskbar.toggleNew = function (uuid, state, silent) {
|
taskbar.toggleNew = function (uuid, state, silent) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const btnEl = taskbar.tasklist.find('[data-uuid="' + uuid + '"]');
|
const btnEl = taskbar.tasklist.find('[data-uuid="' + uuid + '"]');
|
||||||
btnEl.toggleClass('new', state);
|
btnEl.toggleClass('new', state);
|
||||||
|
|
||||||
@@ -112,7 +131,7 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.updateActive = function (uuid) {
|
taskbar.updateActive = function (uuid) {
|
||||||
if (!taskbar.tasklist) {
|
if (noTaskbar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +144,17 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.isActive = function (uuid) {
|
taskbar.isActive = function (uuid) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const taskBtn = taskbar.tasklist.find('li[data-uuid="' + uuid + '"]');
|
const taskBtn = taskbar.tasklist.find('li[data-uuid="' + uuid + '"]');
|
||||||
return taskBtn.hasClass('active');
|
return taskBtn.hasClass('active');
|
||||||
};
|
};
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const tasks = taskbar.tasklist.find('li');
|
const tasks = taskbar.tasklist.find('li');
|
||||||
|
|
||||||
if (tasks.length > 0) {
|
if (tasks.length > 0) {
|
||||||
@@ -140,10 +165,16 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
}
|
}
|
||||||
|
|
||||||
function minimizeAll() {
|
function minimizeAll() {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
taskbar.tasklist.find('.active').removeClass('active');
|
taskbar.tasklist.find('.active').removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTaskbarItem(data, callback) {
|
function createTaskbarItem(data, callback) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
translator.translate(data.options.title, function (taskTitle) {
|
translator.translate(data.options.title, function (taskTitle) {
|
||||||
const title = $('<div></div>').text(taskTitle || 'NodeBB Task').html();
|
const title = $('<div></div>').text(taskTitle || 'NodeBB Task').html();
|
||||||
|
|
||||||
@@ -196,6 +227,9 @@ define('taskbar', ['benchpress', 'translator', 'hooks'], function (Benchpress, t
|
|||||||
};
|
};
|
||||||
|
|
||||||
taskbar.update = function (module, uuid, options) {
|
taskbar.update = function (module, uuid, options) {
|
||||||
|
if (noTaskbar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const element = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
const element = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
|
||||||
if (!element.length) {
|
if (!element.length) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user