Sha256: ddd155ecf06f4b6a04b489b45131cc89a4e36e0dbc894fc1c8c9bbf984515717
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
/* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * Tuxes3 wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return Tuxes3 * ---------------------------------------------------------------------------- */ (function($) { var settings; $.fn.tx3TagCloud = function(options) { // // DEFAULT SETTINGS // settings = $.extend({ multiplier : 1 }, options); main(this); } function main(element) { // adding style attr element.addClass("tx3-tag-cloud"); addListElementFontSize(element); } /** * calculates the font size on each li element * according to their data-weight attribut */ function addListElementFontSize(element) { var hDataWeight = -9007199254740992; var lDataWeight = 9007199254740992; $.each(element.find("li"), function(){ cDataWeight = getDataWeight(this); if (cDataWeight == undefined) { logWarning("No \"data-weight\" attribut defined on <li> element"); } else { hDataWeight = cDataWeight > hDataWeight ? cDataWeight : hDataWeight; lDataWeight = cDataWeight < lDataWeight ? cDataWeight : lDataWeight; } }); $.each(element.find("li"), function(){ var dataWeight = getDataWeight(this); var percent = Math.abs((dataWeight - lDataWeight)/(lDataWeight - hDataWeight)); $(this).css('font-size', (1 + (percent * settings['multiplier'])) + "em"); }); } function getDataWeight(element) { return parseInt($(element).attr("data-weight")); } function logWarning(message) { console.log("[WARNING] " + Date.now() + " : " + message); } }(jQuery));
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blacklight-citeproc-0.2.0 | .internal_test_app/solr/conf/velocity/js/jquery.tx3-tag-cloud.js |
blacklight-citeproc-0.1.0 | .internal_test_app/solr/conf/velocity/js/jquery.tx3-tag-cloud.js |