pad_editbar: Always call the callback

pull/5152/head
Richard Hansen 2021-07-15 18:57:59 -04:00
parent 07e05a92eb
commit 148e10821b
1 changed files with 39 additions and 33 deletions

View File

@ -201,46 +201,52 @@ exports.padeditbar = {
if (padeditor.ace) padeditor.ace.focus(); if (padeditor.ace) padeditor.ace.focus();
}, },
toggleDropDown(moduleName, cb) { toggleDropDown(moduleName, cb) {
// do nothing if users are sticked let cbErr = null;
if (moduleName === 'users' && $('#users').hasClass('stickyUsers')) { try {
return; // do nothing if users are sticked
} if (moduleName === 'users' && $('#users').hasClass('stickyUsers')) {
return;
}
$('.nice-select').removeClass('open'); $('.nice-select').removeClass('open');
$('.toolbar-popup').removeClass('popup-show'); $('.toolbar-popup').removeClass('popup-show');
// hide all modules and remove highlighting of all buttons // hide all modules and remove highlighting of all buttons
if (moduleName === 'none') { if (moduleName === 'none') {
for (const thisModuleName of this.dropdowns) { for (const thisModuleName of this.dropdowns) {
// skip the userlist // skip the userlist
if (thisModuleName === 'users') continue; if (thisModuleName === 'users') continue;
const module = $(`#${thisModuleName}`); const module = $(`#${thisModuleName}`);
// skip any "force reconnect" message // skip any "force reconnect" message
const isAForceReconnectMessage = module.find('button#forcereconnect:visible').length > 0; const isAForceReconnectMessage = module.find('button#forcereconnect:visible').length > 0;
if (isAForceReconnectMessage) continue; if (isAForceReconnectMessage) continue;
if (module.hasClass('popup-show')) { if (module.hasClass('popup-show')) {
$(`li[data-key=${thisModuleName}] > a`).removeClass('selected'); $(`li[data-key=${thisModuleName}] > a`).removeClass('selected');
module.removeClass('popup-show'); module.removeClass('popup-show');
} }
} }
} else { } else {
// hide all modules that are not selected and remove highlighting // hide all modules that are not selected and remove highlighting
// respectively add highlighting to the corresponding button // respectively add highlighting to the corresponding button
for (const thisModuleName of this.dropdowns) { for (const thisModuleName of this.dropdowns) {
const module = $(`#${thisModuleName}`); const module = $(`#${thisModuleName}`);
if (module.hasClass('popup-show')) { if (module.hasClass('popup-show')) {
$(`li[data-key=${thisModuleName}] > a`).removeClass('selected'); $(`li[data-key=${thisModuleName}] > a`).removeClass('selected');
module.removeClass('popup-show'); module.removeClass('popup-show');
} else if (thisModuleName === moduleName) { } else if (thisModuleName === moduleName) {
$(`li[data-key=${thisModuleName}] > a`).addClass('selected'); $(`li[data-key=${thisModuleName}] > a`).addClass('selected');
module.addClass('popup-show'); module.addClass('popup-show');
}
} }
} }
} catch (err) {
cbErr = err || new Error(err);
} finally {
if (cb) cb(cbErr);
} }
if (cb) cb();
}, },
setSyncStatus: (status) => { setSyncStatus: (status) => {
if (status === 'syncing') { if (status === 'syncing') {