Add loadPrefPane(paneName) support function

E.g., loadPrefPane('sync') to open the prefs and select the
'zotero-pane-sync' pane
This commit is contained in:
Dan Stillman 2017-03-13 15:59:50 -07:00
parent b732a82d55
commit 640aaa1557

View File

@ -58,6 +58,22 @@ var loadZoteroPane = Zotero.Promise.coroutine(function* (win) {
return win;
});
var loadPrefPane = Zotero.Promise.coroutine(function* (paneName) {
var id = 'zotero-prefpane-' + paneName;
var win = yield loadWindow("chrome://zotero/content/preferences/preferences.xul", {
pane: id
});
var doc = win.document;
var defer = Zotero.Promise.defer();
var pane = doc.getElementById(id);
if (!pane.loaded) {
pane.addEventListener('paneload', () => defer.resolve());
yield defer.promise;
}
return win;
});
/**
* Waits for a window with a specific URL to open. Returns a promise for the window, and
* optionally passes the window to a callback immediately for use with modal dialogs,