mirror of
https://github.com/zotero/zotero.git
synced 2026-08-28 05:25:31 +00:00
feat: added optional icon to alert call
This commit is contained in:
parent
9ed00c843d
commit
9d99d3474a
2 changed files with 32 additions and 3 deletions
|
|
@ -879,7 +879,8 @@ Zotero_Preferences.Sync = {
|
|||
Zotero.alert(
|
||||
window,
|
||||
Zotero.getString('sync.storage.serverConfigurationVerified'),
|
||||
Zotero.getString('sync.storage.fileSyncSetUp')
|
||||
Zotero.getString('sync.storage.fileSyncSetUp'),
|
||||
{ icon: 'success' }
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -1417,10 +1417,38 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte
|
|||
* @param {Window}
|
||||
* @param {String} title
|
||||
* @param {String} msg
|
||||
* @param {Object} [options]
|
||||
* @param {String} [options.icon] - Name of a Zotero icon to display instead of the
|
||||
* default alert icon
|
||||
*/
|
||||
this.alert = function (window, title, msg) {
|
||||
this.alert = function (window, title, msg, options = {}) {
|
||||
this.debug(`Alert:\n\n${msg}`);
|
||||
Services.prompt.alert(window, title, msg);
|
||||
|
||||
if (!options.icon) {
|
||||
Services.prompt.alert(window, title, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
let dialogObserverChangeIcon = subject => {
|
||||
let doc = subject.document;
|
||||
if (doc.title != title
|
||||
|| doc.getElementById('infoBody')?.textContent != msg) {
|
||||
return;
|
||||
}
|
||||
let icon = doc.getElementById('infoIcon');
|
||||
icon?.classList.remove('alert-icon');
|
||||
icon?.setAttribute(
|
||||
'src',
|
||||
`chrome://zotero/skin/20/universal/${options.icon}.svg`
|
||||
);
|
||||
};
|
||||
Services.obs.addObserver(dialogObserverChangeIcon, 'common-dialog-loaded');
|
||||
try {
|
||||
Services.prompt.alert(window, title, msg);
|
||||
}
|
||||
finally {
|
||||
Services.obs.removeObserver(dialogObserverChangeIcon, 'common-dialog-loaded');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue