www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 005375cc3358e63e75d918e171a25a7104f8f91f
parent fad829635b8e92012589702e3bafe7d4bec5f5e4
Author: Asa Kusuma <asa.kusuma@gmail.com>
Date:   Fri,  8 Aug 2008 19:39:06 +0000

Adds tag cloud feature. Use about:config to turn on.


Diffstat:
Mchrome/content/zotero/bindings/tagselector.xml | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mdefaults/preferences/zotero.js | 3+++
2 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml @@ -177,19 +177,25 @@ tagsToggleBox.removeChild(tagsToggleBox.firstChild); } - // Regenerate list + + + var i=0; for (var tagID in this._tags) { // If the last tag was the same, add this tagID and tagType to it if (tagsToggleBox.lastChild && tagsToggleBox.lastChild.getAttribute('value') == this._tags[tagID].name) { tagsToggleBox.lastChild.setAttribute('tagID', tagsToggleBox.lastChild.getAttribute('tagID') + '-' + tagID); tagsToggleBox.lastChild.setAttribute('tagType', tagsToggleBox.lastChild.getAttribute('tagType') + '-' + this._tags[tagID].type); + + continue; } var label = document.createElement('label'); label.setAttribute('onclick', "this.parentNode.parentNode.parentNode.handleTagClick(event, this)"); label.className = 'zotero-clicky'; + + label.setAttribute('value', this._tags[tagID].name); label.setAttribute('tagID', tagID); label.setAttribute('tagType', this._tags[tagID].type); @@ -199,7 +205,7 @@ label.setAttribute('ondragdrop', 'nsDragAndDrop.drop(event, this.parentNode.parentNode.parentNode.dragObserver)'); tagsToggleBox.appendChild(label); } - + i++; this._dirty = false; } @@ -282,7 +288,76 @@ } } + //start tag cloud code + + var tagCloud = Zotero.Prefs.get('tagCloud'); + + if(tagCloud) { + var labels = tagsToggleBox.getElementsByTagName('label'); + //loop through displayed labels and find number of linked items + var numlinked= []; + for (var i=0; i<labels.length; i++){ + if(labels[i].getAttribute("hidden") != 'true') { + var tagIDs = labels[i].getAttribute('tagID').split('-'); + + + //replace getLinkedItems() with function that gets linked items within the current collection + var linked = this._tags[tagIDs[0]].getLinkedItems(); + + numlinked.push(parseInt(linked.length)); + } + } + // + numlinked.sort(); + + //Get number of attached items from tag with fewest items + var min = numlinked[0]; + + //Get number of attached items from tag with most items + var max = numlinked.pop(); + numlinked.push(max); + + //Create array of possible tag text sizes + var sizes = ["11", "12", "13", "14", "15", "16", "17", "18", "19","20","21","22"]; + + //Number of possible tag sizes + var categories = sizes.length; + + //inc is the size of each size category of tags, in terms of the number of attached items + var inc = Math.ceil((max-min)/categories); + if(inc<1) { + inc = 1; + } + + for (var i=0; i<labels.length; i++){ + if(labels[i].getAttribute("hidden") != 'true') { + var tagIDs = labels[i].getAttribute('tagID').split('-'); + + + //replace getLinkedItems() with function that gets linked items within the current collection + var linked = this._tags[tagIDs[0]].getLinkedItems(); + + numlink = linked.length; + + //range is the difference between how many items this tag has and how many items the smallest tag has + var range=(numlink-min); + + //Divide the range by the size of the categories + s=range/inc; + + if(s==categories) { + s=categories-1; + } + var stylestr = 'font-size:'+sizes[s]+'px;'; + labels[i].setAttribute('style',stylestr); + } + } + } + + //end tag cloud code + + this.updateNumSelected(); this._empty = empty; this.id('tags-toggle').setAttribute('collapsed', empty); diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js @@ -35,6 +35,9 @@ pref("extensions.zotero.lastAbstractExpand",0); pref("extensions.zotero.lastRenameAssociatedFile", false); pref("extensions.zotero.lastViewedFolder", 'L'); +//Tag Cloud +pref("extensions.zotero.tagCloud", true); + // Keyboard shortcuts pref("extensions.zotero.keys.overrideGlobal", false); pref("extensions.zotero.keys.openZotero", 'Z');