From 345bbcf50cfe579edc06abc68a40d100ad9ff21e Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 31 Jul 2023 09:44:20 -0400 Subject: [PATCH] Scaffold: Prompt to save before resetting Now that Scaffold remembers and automatically loads the last edited translator (65048fd6241444a495be98a74ba678bd5e32521c), it needs to be easier to create a new translator without saving (and bumping the lastModified date on) the translator you had open. --- chrome/content/scaffold/scaffold.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/chrome/content/scaffold/scaffold.js b/chrome/content/scaffold/scaffold.js index c4e50cc84b..059ead3199 100644 --- a/chrome/content/scaffold/scaffold.js +++ b/chrome/content/scaffold/scaffold.js @@ -602,10 +602,23 @@ var Scaffold = new function () { this.setFontSize(currentSize - 2); }; - this.newTranslator = async function (skipSave) { - if (!skipSave) { - _logOutput('Saving translator and resetting...'); - await this.save(); + this.newTranslator = async function (skipSavePrompt) { + if (!skipSavePrompt && _editors.code.getValue()) { + let ps = Services.prompt; + let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING + + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING; + let label = document.getElementById('textbox-label').value; + let index = ps.confirmEx(null, + "Scaffold", + `Do you want to save the changes you made to ${label}?`, + buttonFlags, + Zotero.getString('general.no'), + Zotero.getString('general.yes'), + null, null, {} + ); + if (index == 1 && !await this.save()) { + return; + } } this.generateTranslatorID();