Add "Manage Styles…" link to Create Bib and Doc Prefs windows

Clicking it cancels the current window, opens the Cite pane of the
prefs, and selects the Styles tab. (This will be more useful once we
have inline style installation from that pane.)
This commit is contained in:
Dan Stillman 2016-09-06 17:59:55 -04:00
parent 0828d4d5e9
commit 474420620e
7 changed files with 75 additions and 2 deletions

View File

@ -39,6 +39,8 @@ var Zotero_File_Interface_Bibliography = new function() {
var lastSelectedStyle,
lastSelectedLocale;
var isDocPrefs = false;
/*
* Initialize some variables and prepare event listeners for when chrome is done
* loading
@ -104,6 +106,11 @@ var Zotero_File_Interface_Bibliography = new function() {
window.setTimeout(function () {
listbox.ensureIndexIsVisible(selectIndex);
listbox.selectedIndex = selectIndex;
if (listbox.selectedIndex == -1) {
// This can happen in tests if styles aren't loaded
Zotero.debug("No styles to select", 2);
return;
}
Zotero_File_Interface_Bibliography.styleChanged();
}, 0);
@ -131,6 +138,7 @@ var Zotero_File_Interface_Bibliography = new function() {
// ONLY FOR integrationDocPrefs.xul: update status of displayAs, set
// bookmarks text
isDocPrefs = !!document.getElementById("displayAs");
if(document.getElementById("displayAs")) {
if(_io.useEndnotes && _io.useEndnotes == 1) document.getElementById("displayAs").selectedIndex = 1;
}
@ -271,4 +279,14 @@ var Zotero_File_Interface_Bibliography = new function() {
Zotero.Prefs.set("export.lastLocale", lastSelectedLocale);
}
};
this.manageStyles = function () {
document.documentElement.getButton('cancel').click();
var win = Zotero.Utilities.Internal.openPreferences('zotero-prefpane-cite', { tab: 'styles-tab' });
if (isDocPrefs) {
// TODO: Move activate() code elsewhere
Zotero.Integration.activate(win);
}
};
}

View File

@ -15,6 +15,10 @@
<groupbox>
<caption label="&zotero.bibliography.style.label;"/>
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
<hbox align="right">
<label id="manage-styles" class="text-link"
onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label>
</hbox>
</groupbox>
<groupbox>
<hbox align="center">

View File

@ -46,6 +46,10 @@
<groupbox>
<caption label="&zotero.bibliography.style.label;"/>
<listbox id="style-listbox" onselect="Zotero_File_Interface_Bibliography.styleChanged()"/>
<hbox align="right">
<label id="manage-styles" class="text-link"
onclick="Zotero_File_Interface_Bibliography.manageStyles()">&zotero.bibliography.manageStyles;</label>
</hbox>
</groupbox>
<groupbox>

View File

@ -39,6 +39,7 @@ var Zotero_Preferences = {
if(window.arguments) {
var io = window.arguments[0];
io = io.wrappedJSObject || io;
if(io.pane) {
let tabID = io.tab;

View File

@ -39,8 +39,8 @@
<tabbox>
<tabs>
<tab label="&zotero.preferences.cite.wordProcessors;"/>
<tab label="&zotero.preferences.cite.styles;"/>
<tab id="wordProcessors-tab" label="&zotero.preferences.cite.wordProcessors;"/>
<tab id="styles-tab" label="&zotero.preferences.cite.styles;"/>
</tabs>
<tabpanels>
<tabpanel orient="vertical" id="wordProcessors">

View File

@ -176,6 +176,7 @@
<!ENTITY zotero.bibliography.title "Create Citation/Bibliography">
<!ENTITY zotero.bibliography.style.label "Citation Style:">
<!ENTITY zotero.bibliography.manageStyles "Manage Styles…">
<!ENTITY zotero.bibliography.locale.label "Language:">
<!ENTITY zotero.bibliography.outputMode "Output Mode:">
<!ENTITY zotero.bibliography.bibliography "Bibliography">

View File

@ -0,0 +1,45 @@
"use strict";
describe("Create Bibliography Dialog", function () {
var win, zp;
before(function* () {
win = yield loadZoteroPane();
zp = win.ZoteroPane;
});
after(function () {
win.close();
});
it("should perform a search", function* () {
yield Zotero.Styles.init();
var item = yield createDataObject('item');
var deferred = Zotero.Promise.defer();
var called = false;
waitForWindow("chrome://zotero/content/bibliography.xul", function (dialog) {
waitForWindow("chrome://zotero/content/preferences/preferences.xul", function (window) {
// Wait for pane switch
Zotero.Promise.coroutine(function* () {
do {
Zotero.debug("Checking for pane");
yield Zotero.Promise.delay(5);
}
while (window.document.documentElement.currentPane.id != 'zotero-prefpane-cite');
let pane = window.document.documentElement.currentPane;
assert.equal(pane.getElementsByTagName('tabbox')[0].selectedTab.id, 'styles-tab');
assert.equal(pane.getElementsByTagName('tabbox')[0].selectedPanel.id, 'styles');
called = true;
window.close();
deferred.resolve();
})();
});
dialog.document.getElementById('manage-styles').click();
});
win.Zotero_File_Interface.bibliographyFromItems();
yield deferred.promise;
assert.ok(called);
});
});