This commit is contained in:
Vinícius Dutra 2026-09-25 13:49:58 +08:00 • committed by GitHub
commit b6ce9734b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 3 deletions

View file

@ -897,7 +897,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 {

View file

@ -1443,10 +1443,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');
}
}