fx115: nsIPromptService → Services.prompt

This commit is contained in:
Dan Stillman 2023-12-04 05:19:57 -05:00
parent ef75f59037
commit b6a597a7f9
25 changed files with 53 additions and 110 deletions

View file

@ -145,8 +145,7 @@ var ZoteroAdvancedSearch = new function() {
this.save = Zotero.Promise.coroutine(function* () {
_searchBox.updateSearch();
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var libraryID = _searchBox.search.libraryID;

View file

@ -688,8 +688,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
var tagColors = this.state.tagColors;
if (tagColors.size >= Zotero.Tags.MAX_COLORED_TAGS && !tagColors.has(io.name)) {
var ps = Cc['@mozilla.org/embedcomp/prompt-service;1']
.getService(Ci.nsIPromptService);
var ps = Services.prompt;
ps.alert(null, '', Zotero.getString('pane.tagSelector.maxColoredTags', Zotero.Tags.MAX_COLORED_TAGS));
return;
}
@ -751,8 +750,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
}
async openRenamePrompt() {
var promptService = Cc['@mozilla.org/embedcomp/prompt-service;1']
.getService(Ci.nsIPromptService);
var promptService = Services.prompt;
var newName = { value: this.contextTag.name };
var result = promptService.prompt(window,
@ -786,8 +784,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
}
async openDeletePrompt() {
var promptService = Cc['@mozilla.org/embedcomp/prompt-service;1']
.getService(Ci.nsIPromptService);
var promptService = Services.prompt;
var confirmed = promptService.confirm(window,
Zotero.getString('pane.tagSelector.delete.title'),
@ -834,8 +831,7 @@ Zotero.TagSelector = class TagSelectorContainer extends React.PureComponent {
return;
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var confirmed = ps.confirm(
window,
Zotero.getString('pane.tagSelector.deleteAutomatic.title'),

View file

@ -1406,8 +1406,7 @@
+ Zotero.ItemFields.getLocalizedString(fieldsToDelete[i]);
}
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
}
if (!fieldsToDelete || fieldsToDelete.length == 0

View file

@ -108,8 +108,7 @@
return;
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
if (!xmlhttp.responseXML){
try {

View file

@ -504,8 +504,7 @@ var Zotero_File_Interface = new function() {
this.importFromClipboard = Zotero.Promise.coroutine(function* () {
var str = Zotero.Utilities.Internal.getClipboard("text/unicode");
if(!str) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
ps.alert(
null,
Zotero.getString('general.error'),
@ -563,8 +562,7 @@ var Zotero_File_Interface = new function() {
yield onBeforeImport(false);
}
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
let index = ps.confirmEx(

View file

@ -540,8 +540,7 @@ var Zotero_Citation_Dialog = new function () {
if(_autoRegeneratePref == -1) {
if(focusShifted) { // only ask after onchange event; oninput is too
// frequent for this to be worthwhile
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var saveBehavior = { value: false };
var regenerate = promptService.confirmEx(
@ -613,8 +612,7 @@ var Zotero_Citation_Dialog = new function () {
if(isCustom) {
var citation = _editor.getContent(true);
if(Zotero.Utilities.trim(citation) == "") {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var insert = promptService.confirm(window,
Zotero.getString("integration.emptyCitationWarning.title"),
Zotero.getString("integration.emptyCitationWarning.body"));

View file

@ -157,8 +157,7 @@ var Zotero_Bibliography_Dialog = new function () {
* Clears all customizations
*/
this.revertAll = function() {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var out = {};
var regenerate = promptService.confirmEx(
@ -181,8 +180,7 @@ var Zotero_Bibliography_Dialog = new function () {
* Clears customizations to selected entry
*/
this.revert = function() {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var out = {};
var regenerate = promptService.confirmEx(
@ -214,8 +212,7 @@ var Zotero_Bibliography_Dialog = new function () {
isCited |= bibEditInterface.isCited(itemID);
}
if(isCited) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var out = {};
var regenerate = promptService.confirmEx(

View file

@ -106,8 +106,7 @@ Zotero_Preferences.Advanced = {
}
Components.utils.import("resource://zotero/config.js")
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
// If there's a migration marker, point data directory back to the current location and remove
// it to trigger the migration again
@ -269,8 +268,7 @@ Zotero_Preferences.Advanced = {
resetTranslatorsAndStyles: function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
@ -294,8 +292,7 @@ Zotero_Preferences.Advanced = {
resetTranslators: async function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
@ -324,8 +321,7 @@ Zotero_Preferences.Advanced = {
resetStyles: async function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
@ -665,8 +661,7 @@ Zotero_Preferences.Attachment_Base_Directory = {
}
//Confirm change of the base path
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var chooseStrPrefix = 'attachmentBasePath.chooseNewPath.';
var clearStrPrefix = 'attachmentBasePath.clearBasePath.';
@ -756,8 +751,7 @@ Zotero_Preferences.Attachment_Base_Directory = {
var relativeAttachmentIDs = yield Zotero.DB.columnQueryAsync(sql, params);
// Prompt for confirmation
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var strPrefix = 'attachmentBasePath.clearBasePath.';
var title = Zotero.getString(strPrefix + 'title');

View file

@ -210,8 +210,7 @@ Zotero_Preferences.Cite = {
var text = Zotero.getString('styles.deleteStyles');
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
if(ps.confirm(null, '', text)) {
// delete if requested
if(cslIDs.length == 1) {

View file

@ -489,8 +489,7 @@ Zotero_Preferences.Sync = {
var sql = "SELECT COUNT(*) FROM settings "
+ "WHERE setting='storage' AND key='zfsPurge' AND value='user'";
if (!Zotero.DB.valueQueryAsync(sql)) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;

View file

@ -361,8 +361,7 @@ Zotero.DataDirectory = {
|| ('winLastError' in e && e.winLastError == OS.Constants.Win.ERROR_ACCESS_DENIED))) {
Zotero.restarting = true;
let isDefaultDir = dataDir == Zotero.DataDirectory.defaultDir;
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
if (!isDefaultDir) {

View file

@ -210,8 +210,7 @@ Zotero.FileDragDataProvider.prototype = {
}
if (notFoundNames.length || existingItems.length) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
}
// Display alert if files were not found

View file

@ -147,8 +147,7 @@ Zotero.Integration = new function() {
// can attempt to delete on OS X
try {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let promptService = Services.prompt;
var deletePipe = promptService.confirm(null, Zotero.getString("integration.error.title"), Zotero.getString("integration.error.deletePipe"));
if(!deletePipe) return false;
let escapedFifoFile = pipe.path.replace("'", "'\\''");

View file

@ -710,8 +710,7 @@ Zotero.Schema = new function(){
// This is mostly temporary
// TEMP - NSF
this.importSchema = Zotero.Promise.coroutine(function* (str, uri) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
if (!uri.match(/https?:\/\/([^\.]+\.)?zotero.org\//)) {
Zotero.debug("Ignoring schema file from non-zotero.org domain");
@ -2188,8 +2187,7 @@ Zotero.Schema = new function(){
catch (e) {
Zotero.debug(e, 1);
Components.utils.reportError(e);
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
ps.alert(
null,
Zotero.getString('general.error'),

View file

@ -115,8 +115,7 @@ Zotero.Sync.Storage = new function () {
setTimeout(function () {
var group = Zotero.Groups.get(e.data.groupID);
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ ps.BUTTON_DELAY_ENABLE;

View file

@ -91,8 +91,7 @@ Zotero.Sync.Storage.Utilities = {
throw new Error("Unsupported library type " + libraryType);
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;

View file

@ -769,9 +769,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
* @return bool True if the verification eventually succeeded, false otherwise
*/
handleVerificationError: Zotero.Promise.coroutine(function* (err, window, skipSuccessMessage) {
var promptService =
Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
createInstance(Components.interfaces.nsIPromptService);
var promptService = Services.prompt;
var errorTitle, errorMsg;

View file

@ -260,8 +260,7 @@ Zotero.Sync.Server = new function () {
}
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ ps.BUTTON_DELAY_ENABLE;

View file

@ -544,8 +544,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
let removedGroups = [];
let keptGroups = [];
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
@ -1158,8 +1157,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
if (e.error == Zotero.Error.ERROR_API_KEY_NOT_SET) {

View file

@ -72,8 +72,7 @@ Zotero.Sync.Data.Utilities = {
throw new Error("Unsupported library type " + libraryType);
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ ps.BUTTON_DELAY_ENABLE;

View file

@ -399,8 +399,7 @@ Zotero.Utilities.Internal = {
* Display a prompt from an error with custom buttons and a callback
*/
errorPrompt: function (title, e) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var message, buttonText, buttonCallback;
if (e.dialogButtonText !== undefined) {

View file

@ -305,8 +305,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
)
: Zotero.getString('dataDir.notFound', Zotero.clientName);
_startupErrorHandler = async function() {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
createInstance(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
@ -552,8 +551,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
// Require >=2.1b3 database to ensure proper locking
let dbSystemVersion = yield Zotero.Schema.getDBVersion('system');
if (dbSystemVersion > 0 && dbSystemVersion < 31) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPromptService);
let ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
@ -629,8 +627,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
ZOTERO_CONFIG.DOMAIN_NAME);
Zotero.startupError = msg;
_startupErrorHandler = function() {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
@ -1249,9 +1246,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
*/
this.alert = function (window, title, msg) {
this.debug(`Alert:\n\n${msg}`);
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(window, title, msg);
Services.prompt.alert(window, title, msg);
}

View file

@ -545,8 +545,7 @@ var ZoteroPane = new function()
Zotero.restoreFromServer = false;
setTimeout(function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = ps.confirmEx(
@ -2425,9 +2424,7 @@ var ZoteroPane = new function()
var prompt = toDelete;
}
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
if (!prompt || promptService.confirm(window, prompt.title, prompt.text)) {
if (!prompt || Services.prompt.confirm(window, prompt.title, prompt.text)) {
this.itemsView.deleteSelection(force);
}
}
@ -2484,8 +2481,7 @@ var ZoteroPane = new function()
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var ps = Services.prompt;
buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
if (this.getCollectionTreeRow()) {
@ -2619,10 +2615,7 @@ var ZoteroPane = new function()
this.emptyTrash = Zotero.Promise.coroutine(function* () {
var libraryID = this.getSelectedLibraryID();
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var result = ps.confirm(
var result = Services.prompt.confirm(
null,
"",
Zotero.getString('pane.collections.emptyTrash') + "\n\n"
@ -2799,9 +2792,7 @@ var ZoteroPane = new function()
// This isn't currently shown, because the commands are disabled when not relevant, so this
// function isn't called
if (!items.length) {
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, "", Zotero.getString("fileInterface.noReferencesError"));
Services.prompt.alert(null, "", Zotero.getString("fileInterface.noReferencesError"));
return;
}
@ -5241,23 +5232,17 @@ var ZoteroPane = new function()
this.displayCannotEditLibraryMessage = function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, "", Zotero.getString('save.error.cannotMakeChangesToCollection'));
Services.prompt.alert(null, "", Zotero.getString('save.error.cannotMakeChangesToCollection'));
}
this.displayCannotEditLibraryFilesMessage = function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, "", Zotero.getString('save.error.cannotAddFilesToCollection'));
Services.prompt.alert(null, "", Zotero.getString('save.error.cannotAddFilesToCollection'));
}
this.displayCannotAddToMyPublicationsMessage = function () {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, "", Zotero.getString('save.error.cannotAddToMyPublications'));
Services.prompt.alert(null, "", Zotero.getString('save.error.cannotAddToMyPublications'));
}

View file

@ -108,9 +108,7 @@ ZoteroCommandLineHandler.prototype = {
var checkState = {
value: Zotero.Prefs.get('import.createNewCollection.fromFileOpenHandler')
};
if (Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
.confirmCheck(null, Zotero.getString('ingester.importFile.title'),
if (Services.prompt.confirmCheck(null, Zotero.getString('ingester.importFile.title'),
Zotero.getString('ingester.importFile.text', [file.leafName]),
Zotero.getString('ingester.importFile.intoNewCollection'),
checkState)) {

View file

@ -124,10 +124,11 @@ ZoteroPluginInstaller.prototype = {
if(this.force && !this._addon.DISABLE_PROGRESS_WINDOW) {
var addon = this._addon;
setTimeout(function() {
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
.alert(null, addon.EXTENSION_STRING,
Zotero.getString("zotero.preferences.wordProcessors.installationSuccess"));
Services.prompt.alert(
null,
addon.EXTENSION_STRING,
Zotero.getString("zotero.preferences.wordProcessors.installationSuccess")
);
}, 0);
}
},