Replace nsIPrompt with nsIPromptService for Fx4 compatibility

This commit is contained in:
Dan Stillman 2010-09-20 06:10:06 +00:00
parent 50934eef0c
commit 749b13bc02
11 changed files with 193 additions and 157 deletions

View File

@ -183,9 +183,9 @@
var relItem = Zotero.Items.get(io.dataOut[0]); var relItem = Zotero.Items.get(io.dataOut[0]);
if (relItem.libraryID != this.item.libraryID) { if (relItem.libraryID != this.item.libraryID) {
// FIXME // FIXME
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
prompt.alert("", "You cannot relate items in different libraries in this Zotero release."); ps.alert(null, "", "You cannot relate items in different libraries in this Zotero release.");
return; return;
} }
} }

View File

@ -224,9 +224,9 @@ var Zotero_File_Interface = new function() {
var clip = Components.classes["@mozilla.org/widget/clipboard;1"] var clip = Components.classes["@mozilla.org/widget/clipboard;1"]
.getService(Components.interfaces.nsIClipboard); .getService(Components.interfaces.nsIClipboard);
if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard)) { if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard)) {
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
prompt.alert("", Zotero.getString('fileInterface.importClipboardNoDataError')); ps.alert(null, "", Zotero.getString('fileInterface.importClipboardNoDataError'));
return; return;
} }
var trans = Components.classes["@mozilla.org/widget/transferable;1"] var trans = Components.classes["@mozilla.org/widget/transferable;1"]
@ -279,11 +279,12 @@ var Zotero_File_Interface = new function() {
var unsupportedFormat = "The selected file is not in a supported format."; var unsupportedFormat = "The selected file is not in a supported format.";
var viewSupportedFormats = "View Supported Formats..."; var viewSupportedFormats = "View Supported Formats...";
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_OK) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_OK)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_IS_STRING); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
"", "",
unsupportedFormat, unsupportedFormat,
buttonFlags, buttonFlags,

View File

@ -152,9 +152,9 @@ var ZoteroItemPane = new function() {
this.removeNote = function (id) { this.removeNote = function (id) {
var note = Zotero.Items.get(id); var note = Zotero.Items.get(id);
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
if (note && pr.confirm('', Zotero.getString('pane.item.notes.delete.confirm'))) { if (note && ps.confirm(null, '', Zotero.getString('pane.item.notes.delete.confirm'))) {
note.erase(); note.erase();
} }
} }

View File

@ -142,11 +142,12 @@ var ZoteroPane = new function()
Zotero.restoreFromServer = false; Zotero.restoreFromServer = false;
setTimeout(function () { setTimeout(function () {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
"Zotero Restore", "Zotero Restore",
"The local Zotero database has been cleared." "The local Zotero database has been cleared."
+ " " + " "
@ -161,14 +162,16 @@ var ZoteroPane = new function()
onSuccess: function () { onSuccess: function () {
Zotero.Sync.Runner.setSyncIcon(); Zotero.Sync.Runner.setSyncIcon();
pr.alert( ps.alert(
null,
"Restore Completed", "Restore Completed",
"The local Zotero database has been successfully restored." "The local Zotero database has been successfully restored."
); );
}, },
onError: function (msg) { onError: function (msg) {
pr.alert( ps.alert(
null,
"Restore Failed", "Restore Failed",
"An error occurred while restoring from the server:\n\n" "An error occurred while restoring from the server:\n\n"
+ msg + msg
@ -314,10 +317,10 @@ var ZoteroPane = new function()
{ {
if (!ZoteroPane.loaded) { if (!ZoteroPane.loaded) {
if (Zotero.locked) { if (Zotero.locked) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var msg = Zotero.getString('general.operationInProgress') + '\n\n' + Zotero.getString('general.operationInProgress.waitUntilFinished'); var msg = Zotero.getString('general.operationInProgress') + '\n\n' + Zotero.getString('general.operationInProgress.waitUntilFinished');
pr.alert("", msg); ps.alert(null, "", msg);
return; return;
} }
ZoteroPane.onLoad(); ZoteroPane.onLoad();
@ -365,9 +368,9 @@ var ZoteroPane = new function()
// TODO: Add a better error page/window here with reporting // TODO: Add a better error page/window here with reporting
// instructions // instructions
// window.loadURI('chrome://zotero/content/error.xul'); // window.loadURI('chrome://zotero/content/error.xul');
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
pr.alert("", errMsg); ps.alert(null, "", errMsg);
} }
return; return;
@ -1497,12 +1500,15 @@ var ZoteroPane = new function()
this.emptyTrash = function () { this.emptyTrash = function () {
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var result = prompt.confirm("", var result = ps.confirm(
Zotero.getString('pane.collections.emptyTrash') + "\n\n" + null,
Zotero.getString('general.actionCannotBeUndone')); "",
Zotero.getString('pane.collections.emptyTrash') + "\n\n"
+ Zotero.getString('general.actionCannotBeUndone')
);
if (result) { if (result) {
Zotero.Items.emptyTrash(); Zotero.Items.emptyTrash();
Zotero.purgeDataObjects(true); Zotero.purgeDataObjects(true);
@ -1513,20 +1519,21 @@ var ZoteroPane = new function()
var self = this; var self = this;
Zotero.Commons.getBuckets(function () { Zotero.Commons.getBuckets(function () {
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var invalid = false; var invalid = false;
while (true) { while (true) {
if (invalid) { if (invalid) {
// TODO: localize // TODO: localize
prompt.alert("", "Invalid title. Please try again."); ps.alert(null, "", "Invalid title. Please try again.");
invalid = false; invalid = false;
} }
var newTitle = {}; var newTitle = {};
var result = prompt.prompt( var result = prompt.prompt(
null,
"", "",
// TODO: localize // TODO: localize
"Enter a title for this Zotero Commons collection:", "Enter a title for this Zotero Commons collection:",
@ -1566,12 +1573,13 @@ var ZoteroPane = new function()
+ "Collection identifiers can contain basic Latin letters, numbers, " + "Collection identifiers can contain basic Latin letters, numbers, "
+ "hyphens, and underscores and must be no longer than 32 characters. " + "hyphens, and underscores and must be no longer than 32 characters. "
+ "Spaces and other characters are not allowed."; + "Spaces and other characters are not allowed.";
prompt.alert("", msg); ps.alert(null, "", msg);
invalid = false; invalid = false;
} }
var newName = { value: origName }; var newName = { value: origName };
var result = prompt.prompt( var result = ps.prompt(
null,
"", "",
// TODO: localize // TODO: localize
"Enter an identifier for the collection '" + title + "'.\n\n" "Enter an identifier for the collection '" + title + "'.\n\n"
@ -1697,9 +1705,9 @@ var ZoteroPane = new function()
} }
} }
if (!canCopy) { if (!canCopy) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
pr.alert("", Zotero.getString("fileInterface.noReferencesError")); ps.alert(null, "", Zotero.getString("fileInterface.noReferencesError"));
return; return;
} }
@ -2811,9 +2819,9 @@ var ZoteroPane = new function()
var itemGroup = ZoteroPane.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); var itemGroup = ZoteroPane.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
if (link && itemGroup.isWithinGroup()) { if (link && itemGroup.isWithinGroup()) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
pr.alert("", "Linked files cannot be added to group libraries."); ps.alert(null, "", "Linked files cannot be added to group libraries.");
return; return;
} }
@ -3285,16 +3293,16 @@ var ZoteroPane = new function()
this.displayCannotEditLibraryMessage = function () { this.displayCannotEditLibraryMessage = function () {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
pr.alert("", "You cannot make changes to the currently selected library."); ps.alert(null, "", "You cannot make changes to the currently selected library.");
} }
this.displayCannotEditLibraryFilesMessage = function () { this.displayCannotEditLibraryFilesMessage = function () {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
pr.alert("", "You cannot add files to the currently selected library."); ps.alert(null, "", "You cannot add files to the currently selected library.");
} }

View File

@ -211,13 +211,14 @@ function updateStorageSettings(enabled, protocol, skipWarnings) {
if (oldProtocol == 'zotero' && protocol == 'webdav') { if (oldProtocol == 'zotero' && protocol == 'webdav') {
var sql = "SELECT COUNT(*) FROM version WHERE schema='storage_zfs'"; var sql = "SELECT COUNT(*) FROM version WHERE schema='storage_zfs'";
if (Zotero.DB.valueQuery(sql)) { if (Zotero.DB.valueQuery(sql)) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_IS_STRING) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ pr.BUTTON_DELAY_ENABLE; + ps.BUTTON_DELAY_ENABLE;
var account = Zotero.Sync.Server.username; var account = Zotero.Sync.Server.username;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
// TODO: localize // TODO: localize
"Purge Attachment Files on Zotero Servers?", "Purge Attachment Files on Zotero Servers?",
@ -236,13 +237,15 @@ function updateStorageSettings(enabled, protocol, skipWarnings) {
Zotero.Sync.Storage.purgeDeletedStorageFiles('zfs', function (success) { Zotero.Sync.Storage.purgeDeletedStorageFiles('zfs', function (success) {
if (success) { if (success) {
pr.alert( ps.alert(
null,
Zotero.getString("general.success"), Zotero.getString("general.success"),
"Attachment files from your personal library have been removed from the Zotero servers." "Attachment files from your personal library have been removed from the Zotero servers."
); );
} }
else { else {
pr.alert( ps.alert(
null,
Zotero.getString("general.error"), Zotero.getString("general.error"),
"An error occurred. Please try again later." "An error occurred. Please try again later."
); );
@ -343,11 +346,12 @@ function handleSyncResetSelect(obj) {
} }
function handleSyncReset(action) { function handleSyncReset(action) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
if (!Zotero.Sync.Server.enabled) { if (!Zotero.Sync.Server.enabled) {
pr.alert( ps.alert(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
// TODO: localize // TODO: localize
"You must enter a username and password in the " "You must enter a username and password in the "
@ -362,10 +366,11 @@ function handleSyncReset(action) {
switch (action) { switch (action) {
case 'restore-from-server': case 'restore-from-server':
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_POS_1_DEFAULT; + ps.BUTTON_POS_1_DEFAULT;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
// TODO: localize // TODO: localize
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
"All data in this copy of Zotero will be erased and replaced with " "All data in this copy of Zotero will be erased and replaced with "
@ -390,8 +395,9 @@ function handleSyncReset(action) {
file.append('restore-from-server'); file.append('restore-from-server');
Zotero.File.putContents(file, ''); Zotero.File.putContents(file, '');
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING); var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.restartRequired'), Zotero.getString('general.restartRequired'),
// TODO: localize // TODO: localize
"Firefox must be restarted to complete the restore process.", "Firefox must be restarted to complete the restore process.",
@ -421,10 +427,11 @@ function handleSyncReset(action) {
break; break;
case 'restore-to-server': case 'restore-to-server':
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_POS_1_DEFAULT; + ps.BUTTON_POS_1_DEFAULT;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
// TODO: localize // TODO: localize
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
"All data belonging to user '" + account + "' on the Zotero server " "All data belonging to user '" + account + "' on the Zotero server "
@ -448,14 +455,16 @@ function handleSyncReset(action) {
onSuccess: function () { onSuccess: function () {
Zotero.Sync.Runner.setSyncIcon(); Zotero.Sync.Runner.setSyncIcon();
pr.alert( ps.alert(
null,
"Restore Completed", "Restore Completed",
"Data on the Zotero server has been successfully restored." "Data on the Zotero server has been successfully restored."
); );
}, },
onError: function (msg) { onError: function (msg) {
// TODO: combine with error dialog for regular syncs // TODO: combine with error dialog for regular syncs
pr.alert( ps.alert(
null,
"Restore Failed", "Restore Failed",
"An error occurred uploading your data to the server.\n\n" "An error occurred uploading your data to the server.\n\n"
+ "Click the sync error icon in the Zotero toolbar " + "Click the sync error icon in the Zotero toolbar "
@ -475,10 +484,11 @@ function handleSyncReset(action) {
break; break;
case 'full-sync': case 'full-sync':
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_POS_1_DEFAULT; + ps.BUTTON_POS_1_DEFAULT;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
// TODO: localize // TODO: localize
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
"The local Zotero library will be completely merged with data belonging to user '" + account + "' on the Zotero server. " "The local Zotero library will be completely merged with data belonging to user '" + account + "' on the Zotero server. "
@ -496,14 +506,16 @@ function handleSyncReset(action) {
Zotero.Sync.Server.sync(/*{ Zotero.Sync.Server.sync(/*{
onSuccess: function () { onSuccess: function () {
Zotero.Sync.Runner.setSyncIcon(); Zotero.Sync.Runner.setSyncIcon();
pr.alert( ps.alert(
null,
"Full Sync Completed", "Full Sync Completed",
"The local Zotero library has been merged with data from the Zotero server." "The local Zotero library has been merged with data from the Zotero server."
); );
}, },
onError: function (msg) { onError: function (msg) {
// TODO: combine with error dialog for regular syncs // TODO: combine with error dialog for regular syncs
pr.alert( ps.alert(
null,
"Full Sync Failed", "Full Sync Failed",
"An error occurred while performing the full sync.\n\n" "An error occurred while performing the full sync.\n\n"
+ "Click the sync error icon in the Zotero toolbar " + "Click the sync error icon in the Zotero toolbar "
@ -522,10 +534,11 @@ function handleSyncReset(action) {
break; break;
case 'reset-storage-history': case 'reset-storage-history':
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_POS_1_DEFAULT; + ps.BUTTON_POS_1_DEFAULT;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
// TODO: localize // TODO: localize
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
"All file sync history will be cleared.\n\n" "All file sync history will be cleared.\n\n"
@ -538,7 +551,8 @@ function handleSyncReset(action) {
switch (index) { switch (index) {
case 0: case 0:
Zotero.Sync.Storage.resetAllSyncStates(); Zotero.Sync.Storage.resetAllSyncStates();
pr.alert( ps.alert(
null,
"File Sync History Cleared", "File Sync History Cleared",
"The file sync history has been cleared." "The file sync history has been cleared."
); );
@ -1375,11 +1389,12 @@ Zotero_Preferences.Debug_Output = {
Zotero.debug(xmlhttp.responseText); Zotero.debug(xmlhttp.responseText);
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
if (!xmlhttp.responseXML) { if (!xmlhttp.responseXML) {
pr.alert( ps.alert(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
'Invalid response from server' 'Invalid response from server'
); );
@ -1387,7 +1402,8 @@ Zotero_Preferences.Debug_Output = {
} }
var reported = xmlhttp.responseXML.getElementsByTagName('reported'); var reported = xmlhttp.responseXML.getElementsByTagName('reported');
if (reported.length != 1) { if (reported.length != 1) {
pr.alert( ps.alert(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
'The server returned an error. Please try again.' 'The server returned an error. Please try again.'
); );
@ -1395,7 +1411,8 @@ Zotero_Preferences.Debug_Output = {
} }
var reportID = reported[0].getAttribute('reportID'); var reportID = reported[0].getAttribute('reportID');
pr.alert( ps.alert(
null,
"Submitted", "Submitted",
"Debug output has been sent to the Zotero server.\n\n" "Debug output has been sent to the Zotero server.\n\n"
+ "The Debug ID is D" + reportID + "." + "The Debug ID is D" + reportID + "."
@ -1403,8 +1420,8 @@ Zotero_Preferences.Debug_Output = {
} }
var bufferUploader = function (data) { var bufferUploader = function (data) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var oldLen = output.length; var oldLen = output.length;
var newLen = data.length; var newLen = data.length;
@ -1414,7 +1431,8 @@ Zotero_Preferences.Debug_Output = {
+ savings + "% savings)"); + savings + "% savings)");
if (Zotero.Utilities.HTTP.browserIsOffline()) { if (Zotero.Utilities.HTTP.browserIsOffline()) {
pr.alert( ps.alert(
null,
Zotero.getString( Zotero.getString(
'general.error', 'general.error',
Zotero.appName + " is in offline mode." Zotero.appName + " is in offline mode."
@ -1467,7 +1485,8 @@ Zotero_Preferences.Debug_Output = {
req.sendAsBinary(data); req.sendAsBinary(data);
} }
catch (e) { catch (e) {
pr.alert( ps.alert(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
"An error occurred sending debug output." "An error occurred sending debug output."
); );

View File

@ -56,11 +56,12 @@
try { try {
if (data.integrityCheck) { if (data.integrityCheck) {
if (!Zotero.DB.integrityCheck()) { if (!Zotero.DB.integrityCheck()) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
Zotero.getString('upgrade.integrityCheckFailed'), Zotero.getString('upgrade.integrityCheckFailed'),
buttonFlags, Zotero.getString('upgrade.loadDBRepairTool'), buttonFlags, Zotero.getString('upgrade.loadDBRepairTool'),

View File

@ -390,9 +390,9 @@ Zotero.Commons = new function() {
this.error = function (message) { this.error = function (message) {
Components.utils.reportError(message); Components.utils.reportError(message);
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
prompt.alert("Zotero Commons Error", message); ps.alert(null, "Zotero Commons Error", message);
} }
@ -789,21 +789,22 @@ Zotero.Commons.Bucket.prototype.uploadItems = function (ids) {
} }
} }
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var validItemsMessage = "Only titled items with bibliographic metadata and at least one attached file can be added to the Zotero Commons."; var validItemsMessage = "Only titled items with bibliographic metadata and at least one attached file can be added to the Zotero Commons.";
if (itemsToUpload.length == 0) { if (itemsToUpload.length == 0) {
Zotero.debug("No regular items to upload"); Zotero.debug("No regular items to upload");
pr.alert("", validItemsMessage); ps.alert(null, "", validItemsMessage);
return; return;
} }
if (itemsToUpload.length != items.length) { if (itemsToUpload.length != items.length) {
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
"", "",
"Some of the dragged items will not be uploaded." "Some of the dragged items will not be uploaded."
+ "\n\n" + "\n\n"
@ -819,9 +820,10 @@ Zotero.Commons.Bucket.prototype.uploadItems = function (ids) {
} }
} }
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = pr.confirmEx( var index = ps.confirmEx(
null,
"Zotero Commons Upload", "Zotero Commons Upload",
"By uploading items to Zotero Commons you agree to the terms of use at zotero.org and archive.org. " "By uploading items to Zotero Commons you agree to the terms of use at zotero.org and archive.org. "
+ "Please make sure metadata for your items is set properly." + "Please make sure metadata for your items is set properly."

View File

@ -219,8 +219,8 @@ Zotero.Schema = new function(){
// This is mostly temporary // This is mostly temporary
// TEMP - NSF // TEMP - NSF
this.importSchema = function (str, uri) { this.importSchema = function (str, uri) {
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
if (!uri.match(/https?:\/\/([^\.]+\.)?zotero.org\//)) { if (!uri.match(/https?:\/\/([^\.]+\.)?zotero.org\//)) {
Zotero.debug("Ignoring schema file from non-zotero.org domain"); Zotero.debug("Ignoring schema file from non-zotero.org domain");
@ -234,7 +234,7 @@ Zotero.Schema = new function(){
if (str == "%%%ZOTERO_NSF_TEMP_INSTALL%%%") { if (str == "%%%ZOTERO_NSF_TEMP_INSTALL%%%") {
Zotero.debug(Zotero.ItemTypes.getID("nsfReviewer")); Zotero.debug(Zotero.ItemTypes.getID("nsfReviewer"));
if (Zotero.ItemTypes.getID("nsfReviewer")) { if (Zotero.ItemTypes.getID("nsfReviewer")) {
prompt.alert("Zotero Item Type Already Exists", "The 'NSF Reviewer' item type already exists in Zotero."); ps.alert(null, "Zotero Item Type Already Exists", "The 'NSF Reviewer' item type already exists in Zotero.");
Zotero.debug("nsfReviewer item type already exists"); Zotero.debug("nsfReviewer item type already exists");
return; return;
} }
@ -305,12 +305,12 @@ Zotero.Schema = new function(){
s.addCondition('tag', 'isNot', 'Completed'); s.addCondition('tag', 'isNot', 'Completed');
s.save(); s.save();
prompt.alert("Zotero Item Type Added", "The 'NSF Reviewer' item type and 'Overdue NSF Reviewers' saved search have been installed."); ps.alert(null, "Zotero Item Type Added", "The 'NSF Reviewer' item type and 'Overdue NSF Reviewers' saved search have been installed.");
} }
else if (str == "%%%ZOTERO_NSF_TEMP_UNINSTALL%%%") { else if (str == "%%%ZOTERO_NSF_TEMP_UNINSTALL%%%") {
var itemTypeID = Zotero.ItemTypes.getID('nsfReviewer'); var itemTypeID = Zotero.ItemTypes.getID('nsfReviewer');
if (!itemTypeID) { if (!itemTypeID) {
prompt.alert("Zotero Item Type Does Not Exist", "The 'NSF Reviewer' item type does not exist in Zotero."); ps.alert(null, "Zotero Item Type Does Not Exist", "The 'NSF Reviewer' item type does not exist in Zotero.");
Zotero.debug("nsfReviewer item types doesn't exist", 2); Zotero.debug("nsfReviewer item types doesn't exist", 2);
return; return;
} }
@ -321,7 +321,7 @@ Zotero.Schema = new function(){
s2.addCondition('itemType', 'is', 'nsfReviewer'); s2.addCondition('itemType', 'is', 'nsfReviewer');
s2.addCondition('deleted', 'true'); s2.addCondition('deleted', 'true');
if (s.search() || s2.search()) { if (s.search() || s2.search()) {
prompt.alert("Error", "All 'NSF Reviewer' items must be deleted before the item type can be removed from Zotero."); ps.alert(null, "Error", "All 'NSF Reviewer' items must be deleted before the item type can be removed from Zotero.");
return; return;
} }
@ -346,7 +346,7 @@ Zotero.Schema = new function(){
_reloadSchema(); _reloadSchema();
prompt.alert("Zotero Item Type Removed", "The 'NSF Reviewer' item type has been uninstalled."); ps.alert(null, "Zotero Item Type Removed", "The 'NSF Reviewer' item type has been uninstalled.");
} }
} }
@ -2941,10 +2941,10 @@ Zotero.Schema = new function(){
// //
// Conditional should be same as in showUpgradeWizard() // Conditional should be same as in showUpgradeWizard()
if (e.name && e.name == "NS_ERROR_FAILURE" && e.message.match(/nsIFile\.moveTo/)) { if (e.name && e.name == "NS_ERROR_FAILURE" && e.message.match(/nsIFile\.moveTo/)) {
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var title = Zotero.getString('upgrade.failed.title'); var title = Zotero.getString('upgrade.failed.title');
pr.alert(title, Zotero.getString('upgrade.couldNotMigrate') + "\n\n" + Zotero.getString('upgrade.couldNotMigrate.restart')); ps.alert(null, title, Zotero.getString('upgrade.couldNotMigrate') + "\n\n" + Zotero.getString('upgrade.couldNotMigrate.restart'));
} }
throw(e); throw(e);

View File

@ -1582,12 +1582,13 @@ Zotero.Sync.Storage = new function () {
setTimeout(function () { setTimeout(function () {
var group = Zotero.Groups.get(e.data.groupID); var group = Zotero.Groups.get(e.data.groupID);
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_DELAY_ENABLE; + ps.BUTTON_DELAY_ENABLE;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
Zotero.getString('sync.storage.error.fileEditingAccessLost', group.name) + "\n\n" Zotero.getString('sync.storage.error.fileEditingAccessLost', group.name) + "\n\n"
+ Zotero.getString('sync.error.groupWillBeReset') + "\n\n" + Zotero.getString('sync.error.groupWillBeReset') + "\n\n"

View File

@ -836,22 +836,22 @@ Zotero.Sync.Runner = new function () {
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
// Warning // Warning
if (status == 'warning') { if (status == 'warning') {
var title = Zotero.getString('general.warning'); var title = Zotero.getString('general.warning');
// If secondary button not specified, just use an alert // If secondary button not specified, just use an alert
if (!buttonText) { if (!buttonText) {
pr.alert(title, message); ps.alert(null, title, message);
return; return;
} }
var buttonFlags = pr.BUTTON_POS_0 * pr.BUTTON_TITLE_OK var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ pr.BUTTON_POS_1 * pr.BUTTON_TITLE_IS_STRING; + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
Zotero.debug(buttonFlags); var index = ps.confirmEx(
var index = pr.confirmEx( null,
title, title,
message, message,
buttonFlags, buttonFlags,
@ -880,13 +880,14 @@ Zotero.Sync.Runner = new function () {
} }
// If secondary button is explicitly null, just use an alert // If secondary button is explicitly null, just use an alert
else if (buttonText === null) { else if (buttonText === null) {
pr.alert(title, message); ps.alert(null, title, message);
return; return;
} }
var buttonFlags = pr.BUTTON_POS_0 * pr.BUTTON_TITLE_OK var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_OK
+ pr.BUTTON_POS_1 * pr.BUTTON_TITLE_IS_STRING; + ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.error'), Zotero.getString('general.error'),
message, message,
buttonFlags, buttonFlags,
@ -1844,12 +1845,13 @@ Zotero.Sync.Server = new function () {
var libraryID = parseInt(firstChild.getAttribute('libraryID')); var libraryID = parseInt(firstChild.getAttribute('libraryID'));
var group = Zotero.Groups.getByLibraryID(libraryID); var group = Zotero.Groups.getByLibraryID(libraryID);
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ pr.BUTTON_DELAY_ENABLE; + ps.BUTTON_DELAY_ENABLE;
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
Zotero.getString('sync.error.writeAccessLost', group.name) + "\n\n" Zotero.getString('sync.error.writeAccessLost', group.name) + "\n\n"
+ Zotero.getString('sync.error.groupWillBeReset') + "\n\n" + Zotero.getString('sync.error.groupWillBeReset') + "\n\n"
@ -2015,13 +2017,13 @@ Zotero.Sync.Server = new function () {
if (lastUserID && lastUserID != userID) { if (lastUserID && lastUserID != userID) {
var groups = Zotero.Groups.getAll(); var groups = Zotero.Groups.getAll();
var pr = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ (pr.BUTTON_POS_2) * (pr.BUTTON_TITLE_IS_STRING) + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING)
+ pr.BUTTON_POS_1_DEFAULT + ps.BUTTON_POS_1_DEFAULT
+ pr.BUTTON_DELAY_ENABLE; + ps.BUTTON_DELAY_ENABLE;
var msg = "This Zotero database was last synced with a different " var msg = "This Zotero database was last synced with a different "
+ "zotero.org account ('" + lastUsername + "') from the " + "zotero.org account ('" + lastUsername + "') from the "
@ -2063,7 +2065,8 @@ Zotero.Sync.Server = new function () {
} }
if (!noPrompt) { if (!noPrompt) {
var index = pr.confirmEx( var index = ps.confirmEx(
null,
Zotero.getString('general.warning'), Zotero.getString('general.warning'),
msg, msg,
buttonFlags, buttonFlags,
@ -2183,10 +2186,10 @@ Zotero.Sync.Server = new function () {
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var pr = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService); .getService(Components.interfaces.nsIPromptService);
var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
// TODO: localize // TODO: localize
if (e.error == Zotero.Error.ERROR_SYNC_USERNAME_NOT_SET) { if (e.error == Zotero.Error.ERROR_SYNC_USERNAME_NOT_SET) {
var title = Zotero.getString('sync.error.usernameNotSet'); var title = Zotero.getString('sync.error.usernameNotSet');
@ -2197,7 +2200,7 @@ Zotero.Sync.Server = new function () {
var msg = "The Zotero sync server did not accept your username and password.\n\n" var msg = "The Zotero sync server did not accept your username and password.\n\n"
+ "Please check that you have entered your zotero.org login information correctly in the Zotero sync preferences."; + "Please check that you have entered your zotero.org login information correctly in the Zotero sync preferences.";
} }
var index = pr.confirmEx( var index = ps.confirmEx(
win, win,
title, title,
msg, msg,

View File

@ -1519,8 +1519,8 @@ Zotero.Prefs = new function(){
// Import settings bundles // Import settings bundles
this.importSettings = function (str, uri) { this.importSettings = function (str, uri) {
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.createInstance(Components.interfaces.nsIPrompt); .getService(Components.interfaces.nsIPromptService);
if (!uri.match(/https:\/\/([^\.]+\.)?zotero.org\//)) { if (!uri.match(/https:\/\/([^\.]+\.)?zotero.org\//)) {
Zotero.debug("Ignoring settings file not from https://zotero.org"); Zotero.debug("Ignoring settings file not from https://zotero.org");
@ -1530,7 +1530,8 @@ Zotero.Prefs = new function(){
str = Zotero.Utilities.prototype.trim(str.replace(/<\?xml.*\?>\s*/, '')); str = Zotero.Utilities.prototype.trim(str.replace(/<\?xml.*\?>\s*/, ''));
Zotero.debug(str); Zotero.debug(str);
var confirm = prompt.confirm( var confirm = ps.confirm(
null,
"", "",
"Apply settings from zotero.org?" "Apply settings from zotero.org?"
); );