Sha256: 2145bfb203a67749afc8ae20ad7195e09f526475a4d22137d1f811b0dcb4c8ef
Contents?: true
Size: 1.55 KB
Versions: 20
Compression:
Stored size: 1.55 KB
Contents
/* * jQCloud Plugin for jQuery * * Version 0.1.3 * * Copyright 2011, Luca Ongaro * Licensed under the MIT license. * * Date: Wed Feb 16 11:41:32 2011 +0100 */ (function(a){a.fn.jQCloud=function(c,e){var d=this;var b=function(){var g=function(o,m){var l=function(q,p){if(Math.abs(2*q.offsetLeft+q.offsetWidth-2*p.offsetLeft-p.offsetWidth)<q.offsetWidth+p.offsetWidth){if(Math.abs(2*q.offsetTop+q.offsetHeight-2*p.offsetTop-p.offsetHeight)<q.offsetHeight+p.offsetHeight){return true}}return false};var n=0;for(n=0;n<m.length;n++){if(l(o,m[n])){return true}}return false};c.sort(function(m,l){if(m.weight<l.weight){return 1}else{if(m.weight>l.weight){return -1}else{return 0}}});var i=2;var f=[];var h=d.width()/d.height();var k=d.width()/2;var j=d.height()/2;a.each(c,function(q,l){var o=6.28*Math.random();var r=0;var p=Math.round((l.weight-c[c.length-1].weight)/(c[0].weight-c[c.length-1].weight)*9)+1;var u=l.url!==undefined?"<a href='"+l.url+"'>"+l.text+"</a></span>":l.text;d.append("<span id='word_"+q+"' class='w"+p+"' title='"+(l.title||"")+"'>"+u+"</span>");var m=a("#word_"+q).width();var t=a("#word_"+q).height();var n=k-m/2;var s=j-t/2;a("#word_"+q).css("position","absolute");a("#word_"+q).css("left",n+"px");a("#word_"+q).css("top",s+"px");while(g(document.getElementById("word_"+q),f)){r+=i;o+=(q%2===0?1:-1)*i;n=k+(r*Math.cos(o)-(m/2))*h;s=j+r*Math.sin(o)-(t/2);a("#word_"+q).css("left",n+"px");a("#word_"+q).css("top",s+"px")}f.push(document.getElementById("word_"+q))});if(typeof e==="function"){e.call(this)}};setTimeout(function(){b()},100);return this}})(jQuery);
Version data entries
20 entries across 20 versions & 2 rubygems