diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index dd97426bb..3ee559dc1 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -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") + ); } } }); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 221765c0a..46014c27a 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -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 = [];