ditch ZoteroPane.getActiveZoteroPane() and just make window.ZoteroPane refer to either tab or pane, depending on which is active
This commit is contained in:
parent
ddcdfb6961
commit
c722bbff56
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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) });
|
||||
|
|
|
@ -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) });
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -3393,22 +3393,6 @@ var ZoteroPane = new function()
|
|||
if(browserWindow.ZoteroOverlay) browserWindow.ZoteroOverlay.toggleTab();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user