From 263439c6ab927d71486b7d740cde8785129ee2c6 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 6 Sep 2011 06:13:26 +0000 Subject: [PATCH] Closes #1464, Limit number of creators in metadata pane Displays "[x] more..." label that can be clicked to show all creators. Switching away from the item resets. This might need some further tweaking. Untruncated display of large creator lists is probably faster now as well, though definitely not enough for the ATLAS Experiment. --- .../content/zotero-platform/mac/itembox.css | 2 +- chrome/content/zotero/bindings/itembox.xml | 95 +++++++++++++++---- .../skin/default/zotero/bindings/itembox.css | 5 + 3 files changed, 85 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero-platform/mac/itembox.css b/chrome/content/zotero-platform/mac/itembox.css index cd73a6b30c..8ff82d5a86 100644 --- a/chrome/content/zotero-platform/mac/itembox.css +++ b/chrome/content/zotero-platform/mac/itembox.css @@ -3,7 +3,7 @@ scrollbox padding-top: 3px; } -row > label:first-child, .creator-type-label +row > label:first-child, .creator-type-label, #more-creators-label { color: #7f7f7f; } diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index cdf4c80601..a48b4ae0e7 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -52,6 +52,9 @@ + 10 + + "view" @@ -113,6 +116,12 @@ if (!(val instanceof Zotero.Item)) { throw (".item must be a Zotero.Item"); } + + // When changing items, reset truncation of creator list + if (!this._item || val.id != this._item.id) { + this._displayAllCreators = false; + } + this._item = val; this.refresh(); ]]> @@ -509,20 +518,46 @@ } this._creatorCount = 0; - if (this.item.numCreators() > 0) { - for (var i = 0, len=this.item.numCreators(); i 0) { + var max = Math.min(num, this._initialVisibleCreators); + // If fewer than five more, just display + if (num < max + 5 || this._displayAllCreators) { + max = num; + } + for (var i = 0; i < max; i++) { this.addCreatorRow(this.item.getCreator(i).ref, this.item.getCreator(i).creatorTypeID); + + if (i == max - 2) { + this.disableCreatorAddButtons(); + } } - if (this._addCreatorRow) { - this.addCreatorRow(false, false, true); - this._addCreatorRow = false; + // Additional creators not displayed + if (num > max) { + this.addMoreCreatorsRow(num - max); + + this.disableCreatorAddButtons(); + } + else { + // If we didn't start with creators truncated, + // don't truncate for as long as we're viewing + // this item, so that added creators aren't + // immediately hidden + this._displayAllCreators = true; + + if (this._addCreatorRow) { + this.addCreatorRow(false, false, true); + this._addCreatorRow = false; + this.disableCreatorAddButtons(); + } } } else if (this.editable && Zotero.CreatorTypes.itemTypeHasCreators(this.item.itemTypeID)) { // Add default row this.addCreatorRow(false, false, true, true); + this.disableCreatorAddButtons(); } // Move to next or previous field if (shift-)tab was pressed @@ -636,12 +671,6 @@ }; } - // Disable the "+" button on previous rows - var elems = this._dynamicFields.getElementsByAttribute('value', '+'); - if (elems.length) { - this.disableButton(elems[elems.length-1]); - } - if (creator.fieldMode == 1) { var firstName = ''; var lastName = creator.lastName ? creator.lastName : this._defaultFullName; @@ -774,6 +803,27 @@ + + + + + + + @@ -1117,18 +1167,31 @@ - - + + + + + diff --git a/chrome/skin/default/zotero/bindings/itembox.css b/chrome/skin/default/zotero/bindings/itembox.css index 688b008245..511bedb394 100644 --- a/chrome/skin/default/zotero/bindings/itembox.css +++ b/chrome/skin/default/zotero/bindings/itembox.css @@ -30,6 +30,11 @@ row > label:first-child, .creator-type-label margin-right: 0 !important; } +#more-creators-label +{ + font-weight: bold; +} + row > label { border: 1px solid transparent;