yaz/commit
UPDATE update size of tag suggestions
author | Michiel Hildebrand |
---|---|
Mon Nov 7 11:59:32 2011 +0100 | |
committer | Michiel Hildebrand |
Mon Nov 7 11:59:32 2011 +0100 | |
commit | bbf2ec23e33931989c3a19a196b735d2b6f2996a |
tree | 13d691f0465d3ae1ef88a5e61211ca9908816730 |
parent | 2d618ba383469ce28f9b6f8e5c8a036e33451bdd |
Diff style: patch stat
diff --git a/applications/yaz_shot_annotation.pl b/applications/yaz_shot_annotation.pl index 9837687..07b3099 100644 --- a/applications/yaz_shot_annotation.pl +++ b/applications/yaz_shot_annotation.pl @@ -185,7 +185,8 @@ html_video_page_yui(Video, Shots, Sources) --> })), \js_new(tagList, 'Y.mazzle.TagList'({tags:[], - height:400 + height:400, + sizeAdjust:symbol(true) })), \js_new(tagLinker, 'Y.mazzle.TagLinker'({sources:Sources, diff --git a/web/js/tagplayer/taglist.js b/web/js/tagplayer/taglist.js index 92f812f..3442325 100644 --- a/web/js/tagplayer/taglist.js +++ b/web/js/tagplayer/taglist.js @@ -30,6 +30,15 @@ YUI.add('tag-list', function(Y) { }, active: { value: true + }, + sizeAdjust: { + value: false + }, + maxFont: { + value: 25 + }, + minFont : { + value: 12 } }; @@ -70,20 +79,48 @@ YUI.add('tag-list', function(Y) { }, _renderItems : function() { - var tags = this.get("tags"); - + var tags = this.get("tags"), + min = this._minEntries(tags), + max = this._maxEntries(tags); + this.listNode.setContent(""); // format the items for(var i=0; i < tags.length; i++) { - this.listNode.append('<li>'+this.formatItem(tags[i])+'</li>'); + this.listNode.append('<li>'+this.formatItem(tags[i], min, max)+'</li>'); } }, + + _minEntries : function(rs) { + var min = 50; + for (var i=0; i < rs.length; i++) { + if(rs[i].annotations) { + min = Math.min(rs[i].annotations.length, min); + } + } + return min; + }, + _maxEntries : function(rs) { + var max = 1; + for (var i=0; i < rs.length; i++) { + if(rs[i].annotations) { + max = Math.max(rs[i].annotations.length, max); + } + } + return max; + }, - formatItem : function(item) { + formatItem : function(item, min, max) { var tag = item.tag, - label = tag.label ? tag.label : tag.value; - - var html = '<div class="label">'+label+'</div>'; + label = tag.label ? tag.label : tag.value, + count = item.annotations ? item.annotations.length : 1, + maxF = this.get("maxFont"), + minF = this.get("minFont"), + d = (maxF-minF)/Math.max((max-min),1), + size = this.get("sizeAdjust") ? ((d*count) + (minF-d)) : minF; + + var html = '<div class="label">' + html += '<span style="font-size:'+size+'px">'+label+'</span>'; + html += '</div>'; if(item.uri) { html += '<a href="javascript:{}">'+html+'</a>'; }