Add Zotero.alert() method
This is just a wrapper around nsIPromptService.alert() that takes Zotero.noUserInput into consideration, which avoids long timeouts during testing (e.g., for lookup failures).
This commit is contained in:
parent
9511c43432
commit
4f9366749c
|
@ -87,10 +87,11 @@ const Zotero_Lookup = new function () {
|
|||
}
|
||||
|
||||
if(!items.length) {
|
||||
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
prompts.alert(window, Zotero.getString("lookup.failure.title"),
|
||||
Zotero.getString("lookup.failureToID.description"));
|
||||
Zotero.alert(
|
||||
window,
|
||||
Zotero.getString("lookup.failure.title"),
|
||||
Zotero.getString("lookup.failureToID.description")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -127,10 +128,11 @@ const Zotero_Lookup = new function () {
|
|||
if(successful) {
|
||||
document.getElementById("zotero-lookup-panel").hidePopup();
|
||||
} else {
|
||||
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
prompts.alert(window, Zotero.getString("lookup.failure.title"),
|
||||
Zotero.getString("lookup.failure.description"));
|
||||
Zotero.alert(
|
||||
window,
|
||||
Zotero.getString("lookup.failure.title"),
|
||||
Zotero.getString("lookup.failure.description")
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1308,6 +1308,29 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
err.lineNumber ? err.lineNumber : null, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display an alert in a given window
|
||||
*
|
||||
* This is just a wrapper around nsIPromptService.alert() that takes the Zotero.noUserInput
|
||||
* flag into consideration
|
||||
*
|
||||
* @param {Window}
|
||||
* @param {String} title
|
||||
* @param {String} msg
|
||||
*/
|
||||
this.alert = function (window, title, msg) {
|
||||
if (this.noUserInput) {
|
||||
Zotero.debug("Not displaying alert: " + title + ": " + msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
ps.alert(window, title, msg);
|
||||
}
|
||||
|
||||
|
||||
function getErrors(asStrings) {
|
||||
var errors = [];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user