From 80f504768763924f467aa76e79853e88f7d565de Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 29 Aug 2010 04:14:05 +0000 Subject: [PATCH] Commons: - Reload bucket on bucket click if not loaded in the last 60 seconds - Add "Show Original" button to Commons metadata pane to switch back to original linked item, if it exists - Hide metadata pane tabs in Commons view - Add support for setting credentials via zotero.org (untested, and not yet stored in Fx login manager) Also: - Add ZoteroPane.getItemGroup() function --- chrome/content/zotero/overlay.js | 49 ++++++++++++++++--- chrome/content/zotero/overlay.xul | 3 ++ chrome/content/zotero/xpcom/commons.js | 26 ++++++++-- .../content/zotero/xpcom/mimeTypeHandler.js | 1 + chrome/content/zotero/xpcom/zotero.js | 40 +++++++++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index f09a2b567..0b560b325 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -1075,7 +1075,11 @@ var ZoteroPane = new function() } } } - + + this.getItemGroup = function () { + return this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); + } + function itemSelected() { @@ -1096,6 +1100,7 @@ var ZoteroPane = new function() var tabs = document.getElementById('zotero-view-tabbox'); + // Single item selected if (this.itemsView && this.itemsView.selection.count == 1 && this.itemsView.selection.currentIndex != -1) { var item = this.itemsView._getItemAtRow(this.itemsView.selection.currentIndex); @@ -1142,10 +1147,23 @@ var ZoteroPane = new function() } // Regular item - else - { + else { + var isCommons = this.getItemGroup().isBucket(); + document.getElementById('zotero-item-pane-content').selectedIndex = 1; - var pane = document.getElementById('zotero-view-tabbox').selectedIndex; + var tabBox = document.getElementById('zotero-view-tabbox'); + var pane = tabBox.selectedIndex; + tabBox.firstChild.hidden = isCommons; + + var button = document.getElementById('zotero-item-show-original'); + if (isCommons) { + button.hidden = false; + button.disabled = !this.getOriginalItem(); + } + else { + button.hidden = true; + } + if (this.collectionsView.editable) { ZoteroItemPane.viewItem(item.ref, null, pane); tabs.selectedIndex = document.getElementById('zotero-view-item').selectedIndex; @@ -1156,8 +1174,8 @@ var ZoteroPane = new function() } } } - else - { + // Zero or multiple items selected + else { document.getElementById('zotero-item-pane-content').selectedIndex = 0; var label = document.getElementById('zotero-view-selected-label'); @@ -1439,6 +1457,25 @@ var ZoteroPane = new function() } + // Currently used only for Commons to find original linked item + this.getOriginalItem = function () { + var item = this.getSelectedItems()[0]; + var itemGroup = this.getItemGroup(); + // TEMP: Commons buckets only + return itemGroup.ref.getLocalItem(item); + } + + + this.showOriginalItem = function () { + var item = this.getOriginalItem(); + if (!item) { + Zotero.debug("Original item not found"); + return; + } + this.selectItem(item.id); + } + + this.restoreSelectedItems = function () { var items = this.getSelectedItems(); if (!items) { diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 6c894b2c4..0260f09d9 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -401,6 +401,9 @@