www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 474420620ef3fc44b76f48b0f5bedd099fc37728
parent 0828d4d5e971e0b1425ad52e9587f535f5e2a0b1
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  6 Sep 2016 17:59:55 -0400

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.)

Diffstat:
Mchrome/content/zotero/bibliography.js | 18++++++++++++++++++
Mchrome/content/zotero/bibliography.xul | 4++++
Mchrome/content/zotero/integration/integrationDocPrefs.xul | 4++++
Mchrome/content/zotero/preferences/preferences.js | 1+
Mchrome/content/zotero/preferences/preferences_cite.xul | 4++--
Mchrome/locale/en-US/zotero/zotero.dtd | 1+
Atest/tests/bibliographyTest.js | 45+++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js @@ -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); + } + }; } diff --git a/chrome/content/zotero/bibliography.xul b/chrome/content/zotero/bibliography.xul @@ -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"> diff --git a/chrome/content/zotero/integration/integrationDocPrefs.xul b/chrome/content/zotero/integration/integrationDocPrefs.xul @@ -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> diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js @@ -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; diff --git a/chrome/content/zotero/preferences/preferences_cite.xul b/chrome/content/zotero/preferences/preferences_cite.xul @@ -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"> diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd @@ -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"> diff --git a/test/tests/bibliographyTest.js b/test/tests/bibliographyTest.js @@ -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); + }); +});