Move handleUnappliedChangesClose

This commit is contained in:
Oliver Hamlet
2016-01-06 18:27:01 +00:00
parent 3e51af2cc5
commit ca22743726
2 changed files with 21 additions and 21 deletions
+21
View File
@@ -623,6 +623,27 @@ function onSidebarClick(evt) {
}
}
}
function handleUnappliedChangesClose(change) {
loot.Dialog.askQuestion('', loot.l10n.translate('You have not yet applied or cancelled your %s. Are you sure you want to quit?', change), loot.l10n.translate('Quit'), (result) => {
if (!result) {
return;
}
/* Cancel any sorting and close any editors. Cheat by sending a
cancelSort query for as many times as necessary. */
const queries = [];
let numQueries = 0;
if (!document.getElementById('applySortButton').classList.contains('hidden')) {
numQueries += 1;
}
numQueries += document.body.getAttribute('data-editors');
for (let i = 0; i < numQueries; ++i) {
queries.push(loot.query('cancelSort'));
}
Promise.all(queries).then(() => {
window.close();
}).catch(handlePromiseError);
});
}
function onQuit(evt) {
if (!document.getElementById('applySortButton').classList.contains('hidden')) {
handleUnappliedChangesClose(loot.l10n.translate('sorted load order'));
-21
View File
@@ -16,27 +16,6 @@ function hideElement(element) {
element.classList.toggle('hidden', true);
}
}
function handleUnappliedChangesClose(change) {
loot.Dialog.askQuestion('', loot.l10n.translate('You have not yet applied or cancelled your %s. Are you sure you want to quit?', change), loot.l10n.translate('Quit'), (result) => {
if (!result) {
return;
}
/* Cancel any sorting and close any editors. Cheat by sending a
cancelSort query for as many times as necessary. */
const queries = [];
let numQueries = 0;
if (!document.getElementById('applySortButton').classList.contains('hidden')) {
numQueries += 1;
}
numQueries += document.body.getAttribute('data-editors');
for (let i = 0; i < numQueries; ++i) {
queries.push(loot.query('cancelSort'));
}
Promise.all(queries).then(() => {
window.close();
}).catch(handlePromiseError);
});
}
function getConflictingPlugins(pluginName) {
if (!pluginName) {
return Promise.resolve([]);