commit c722bbff56b76927a0ebac19abb87c48e6cd0388
parent ddcdfb6961ce12f78f44da3eac547e826a8e48b8
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 3 Feb 2011 05:00:08 +0000
ditch ZoteroPane.getActiveZoteroPane() and just make window.ZoteroPane refer to either tab or pane, depending on which is active
Diffstat:
13 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/chrome/content/zotero/advancedSearch.js b/chrome/content/zotero/advancedSearch.js
@@ -152,8 +152,11 @@ var ZoteroAdvancedSearch = new function() {
return;
}
- lastWin.ZoteroPane.show();
- lastWin.ZoteroPane.getActiveZoteroPane().selectItem(item.getID(), false, true);
+ if (lastWin.document.getElementById('zotero-pane').getAttribute('hidden') == 'true') {
+ lastWin.ZoteroPane.toggleDisplay();
+ }
+
+ lastWin.ZoteroPane.selectItem(item.getID(), false, true);
lastWin.focus();
}
}
diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml
@@ -317,8 +317,11 @@
return;
}
- lastWin.ZoteroPane.show();
- var zp = lastWin.ZoteroPane.getActiveZoteroPane();
+ if (lastWin.ZoteroOverlay) {
+ lastWin.ZoteroOverlay.toggleDisplay();
+ }
+
+ var zp = lastWin.ZoteroPane;
}
var parentID = this.item.getSource();
diff --git a/chrome/content/zotero/bindings/relatedbox.xml b/chrome/content/zotero/bindings/relatedbox.xml
@@ -223,7 +223,7 @@
var p;
if(window.ZoteroPane)
{
- p = window.ZoteroPane.getActiveZoteroPane();
+ p = window.ZoteroPane;
}
else
{
@@ -242,10 +242,10 @@
return;
}
- p = win.ZoteroPane.getActiveZoteroPane();
+ p = win.ZoteroPane;
}
-
- if(p) p.selectItem(id);
+
+ p.selectItem(id);
}
]]>
</body>
diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js
@@ -151,10 +151,9 @@ var Zotero_Browser = new function() {
// get libraryID and collectionID
var libraryID, collectionID;
- var pane = ZoteroPane.getActiveZoteroPane();
- if(pane) {
- libraryID = pane.getSelectedLibraryID();
- collectionID = pane.getSelectedCollection(true);
+ if(ZoteroPane) {
+ libraryID = ZoteroPane.getSelectedLibraryID();
+ collectionID = ZoteroPane.getSelectedCollection(true);
} else {
libraryID = collectionID = null;
}
diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js
@@ -68,9 +68,8 @@ const Zotero_Lookup = new function () {
var libraryID = null;
var collection = false;
try {
- var zp = window.opener.ZoteroPane.getActiveZoteroPane();
- libraryID = zp.getSelectedLibraryID();
- collection = zp.getSelectedCollection();
+ libraryID = window.opener.ZoteroPane.getSelectedLibraryID();
+ collection = window.opener.ZoteroPane.getSelectedCollection();
} catch(e) {}
translate.setHandler("itemDone", function(obj, item) {
if(collection) collection.addItem(item.id);
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -138,6 +138,7 @@ var ZoteroOverlay = new function()
setTimeout("gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL); Zotero.initialURL = null;", 1);
}
+ ZoteroPane_Overlay = ZoteroPane;
ZoteroPane.init();
// Hide browser chrome on Zotero tab
@@ -159,9 +160,9 @@ var ZoteroOverlay = new function()
/**
* Hides/displays the Zotero interface
*/
- this.toggleDisplay = function()
+ this.toggleDisplay = function(makeVisible)
{
- if(this.isTab) {
+ if(this.isTab && (makeVisible || makeVisible === undefined)) {
// If in separate tab mode, just open the tab
this.loadZoteroTab();
return;
@@ -172,7 +173,7 @@ var ZoteroOverlay = new function()
var isHidden = zoteroPane.getAttribute('hidden') == 'true';
var isCollapsed = zoteroPane.getAttribute('collapsed') == 'true';
- var makeVisible = isHidden || isCollapsed;
+ if(makeVisible === undefined) makeVisible = isHidden || isCollapsed;
zoteroSplitter.setAttribute('hidden', !makeVisible);
zoteroPane.setAttribute('hidden', false);
@@ -307,6 +308,9 @@ var ZoteroOverlay = new function()
// don't do anything if Zotero tab is the only tab
if(tab && gBrowser.tabs.length === 1) return;
+ // swap ZoteroPane object
+ ZoteroPane = ZoteroPane_Overlay;
+
// otherwise, close Zotero tab and open Zotero pane
gBrowser.removeTab(tab);
this.isTab = false;
diff --git a/chrome/content/zotero/reportInterface.js b/chrome/content/zotero/reportInterface.js
@@ -44,7 +44,7 @@ var Zotero_Report_Interface = new function() {
}
if (col) {
- window.loadURI('zotero://report/collection/'
+ ZoteroPane.loadURI('zotero://report/collection/'
+ Zotero.Collections.getLibraryKeyHash(col)
+ '/html/report.html' + queryString);
return;
@@ -52,7 +52,7 @@ var Zotero_Report_Interface = new function() {
var s = ZoteroPane.getSelectedSavedSearch();
if (s) {
- window.loadURI('zotero://report/search/'
+ ZoteroPane.loadURI('zotero://report/search/'
+ Zotero.Searches.getLibraryKeyHash(s)
+ '/html/report.html' + queryString);
return;
@@ -77,7 +77,7 @@ var Zotero_Report_Interface = new function() {
keyHashes.push(Zotero.Items.getLibraryKeyHash(item));
}
- window.loadURI('zotero://report/items/' + keyHashes.join('-') + '/html/report.html');
+ ZoteroPane.loadURI('zotero://report/items/' + keyHashes.join('-') + '/html/report.html');
}
@@ -89,6 +89,6 @@ var Zotero_Report_Interface = new function() {
throw ('No itemIDs provided to loadItemReportByIds()');
}
- window.loadURI('zotero://report/items/' + ids.join('-') + '/html/report.html');
+ ZoteroPane.loadURI('zotero://report/items/' + ids.join('-') + '/html/report.html');
}
}
diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js
@@ -40,18 +40,24 @@ var ZoteroTab = new function()
}
if(browserIndex === -1) return;
+ // initialize ZoteroPane and swap out old window ZoteroPane object
+ ZoteroPane.init();
+
+ // swap window ZoteroPane with ZoteroPane from tab
+ window.ZoteroPane_Overlay = window.ZoteroPane;
+ window.ZoteroPane_Tab = ZoteroPane;
+ window.ZoteroPane = ZoteroPane;
+
// get tab for browser
var tab = window.gBrowser.tabs[browserIndex];
if(window.gBrowser.selectedTab === tab) {
// if tab is already selected, init now
- ZoteroPane.init();
ZoteroPane.makeVisible();
} else {
// otherwise, add a handler to wait until this tab is selected
var listener = function(event) {
if(event.target !== tab) return;
window.gBrowser.tabContainer.removeEventListener("TabSelect", listener, false);
- ZoteroPane.init();
ZoteroPane.makeVisible();
}
window.gBrowser.tabContainer.addEventListener("TabSelect", listener, false);
@@ -59,6 +65,10 @@ var ZoteroTab = new function()
}
this.onUnload = function() {
+ if(window.ZoteroPane === window.ZoteroPane_Tab) {
+ window.ZoteroPane = window.ZoteroPane_Overlay;
+ }
+ delete window.ZoteroPane_Tab;
ZoteroPane.destroy();
}
}
diff --git a/chrome/content/zotero/tab.xul b/chrome/content/zotero/tab.xul
@@ -56,6 +56,7 @@
accesskey="&selectAllCmd.accesskey;"
command="cmd_selectAll"/>
</popup>
+ <commandset id="mainCommandSet"/>
<hbox flex="1" id="browser">
<vbox id="appcontent" flex="1">
<stack id="zotero-pane-stack" fullscreenmode="true" flex="1"/>
diff --git a/chrome/content/zotero/xpcom/connector.js b/chrome/content/zotero/xpcom/connector.js
@@ -703,9 +703,8 @@ Zotero.Connector.Translate.Save.prototype = {
this._libraryID = null;
var collection = null;
try {
- var zp = win.ZoteroPane.getActiveZoteroPane();
- this._libraryID = zp.getSelectedLibraryID();
- collection = zp.getSelectedCollection();
+ this._libraryID = win.ZoteroPane.getSelectedLibraryID();
+ collection = win.ZoteroPane.getSelectedCollection();
} catch(e) {}
var me = this;
translate.setHandler("select", function(obj, item) { return me._selectItems(obj, item) });
diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js
@@ -118,9 +118,8 @@ Zotero.MIMETypeHandler = new function () {
var libraryID = null;
var collection = null;
try {
- var zp = frontWindow.ZoteroPane.getActiveZoteroPane();
- libraryID = zp.getSelectedLibraryID();
- collection = zp.getSelectedCollection();
+ libraryID = frontWindow.ZoteroPane.getSelectedLibraryID();
+ collection = frontWindow.ZoteroPane.getSelectedCollection();
} catch(e) {}
translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Browser.itemDone(obj, item, collection) });
translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Browser.finishScraping(obj, item, collection) });
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -126,7 +126,7 @@ var Zotero = new function(){
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
- return win.getActiveZoteroPane();
+ return win.ZoteroPane;
};
this.getLocalUserKey = function (generate) {
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -3394,22 +3394,6 @@ var ZoteroPane = new function()
}
/**
- * Gets the ZoteroPane object that is currently active in this window. Should be used for
- * determining the active collection for scraping, etc.
- */
- this.getActiveZoteroPane = function() {
- if(ZoteroOverlay && ZoteroOverlay.isTab) {
- // If a Zotero tab is open, return the pane for the tab
- var tab = ZoteroOverlay.findZoteroTab();
- if(!tab) return null;
- return gBrowser.getBrowserForTab(tab).contentWindow.ZoteroPane;
- } else {
- // Otherwise, return the pane for this tab
- return ZoteroPane;
- }
- }
-
- /**
* Shows the Zotero pane, making it visible if it is not and switching to the appropriate tab
* if necessary.
*/