diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index ff45ac177..1d7d4e9c5 100644 --- 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 index 08e025e92..239ee89f7 100644 --- a/chrome/content/zotero/bibliography.xul +++ b/chrome/content/zotero/bibliography.xul @@ -15,6 +15,10 @@ + + + diff --git a/chrome/content/zotero/integration/integrationDocPrefs.xul b/chrome/content/zotero/integration/integrationDocPrefs.xul index e2a3a8ab3..a67dad658 100644 --- a/chrome/content/zotero/integration/integrationDocPrefs.xul +++ b/chrome/content/zotero/integration/integrationDocPrefs.xul @@ -46,6 +46,10 @@ + + + diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index cd10717d5..d66793ab0 100644 --- 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 index 0ee500f6c..f138166ce 100644 --- a/chrome/content/zotero/preferences/preferences_cite.xul +++ b/chrome/content/zotero/preferences/preferences_cite.xul @@ -39,8 +39,8 @@ - - + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index f383415c1..ebe403009 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -176,6 +176,7 @@ + diff --git a/test/tests/bibliographyTest.js b/test/tests/bibliographyTest.js new file mode 100644 index 000000000..8e7b805ee --- /dev/null +++ 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); + }); +});