/*! * jQCloud Plugin for jQuery * * Version 1.0.2 * * Copyright 2011, Luca Ongaro * Licensed under the MIT license. * * Date: Tue Oct 09 22:08:53 +0200 2012 */ (function(b){"use strict",b.fn.jQCloud=function(a,l){var k=this,j=k.attr("id")||Math.floor(Math.random()*1000000).toString(36),i={width:k.width(),height:k.height(),center:{x:(l&&l.width?l.width:k.width())/2,y:(l&&l.height?l.height:k.height())/2},delayedMode:a.length>50,shape:!1,encodeURI:!0};l=b.extend(i,l||{}),k.addClass("jqcloud").width(l.width).height(l.height),k.css("position")==="static"&&k.css("position","relative");var h=function(){var p=function(g,f){var r=function(t,s){return Math.abs(2*t.offsetLeft+t.offsetWidth-2*s.offsetLeft-s.offsetWidth)f.weight?-1:0});var n=l.shape==="rectangular"?18:2,m=[],e=l.width/l.height,d=function(R,Q){var P=j+"_word_"+R,O="#"+P,N=6.28*Math.random(),M=0,L=0,J=0,I=5,H="",G="",F="";Q.html=b.extend(Q.html,{id:P}),Q.html&&Q.html["class"]&&(H=Q.html["class"],delete Q.html["class"]),a[0].weight>a[a.length-1].weight&&(I=Math.round((Q.weight-a[a.length-1].weight)/(a[0].weight-a[a.length-1].weight)*9)+1),F=b("").attr(Q.html).addClass("w"+I+" "+H),Q.link?(typeof Q.link=="string"&&(Q.link={href:Q.link}),l.encodeURI&&(Q.link=b.extend(Q.link,{href:encodeURI(Q.link.href).replace(/'/g,"%27")})),G=b("").attr(Q.link).text(Q.text)):G=Q.text,F.append(G);if(!!Q.handlers){for(var E in Q.handlers){Q.handlers.hasOwnProperty(E)&&typeof Q.handlers[E]=="function"&&b(F).bind(E,Q.handlers[E])}}k.append(F);var D=F.width(),C=F.height(),B=l.center.x-D/2,f=l.center.y-C/2,K=F[0].style;K.position="absolute",K.left=B+"px",K.top=f+"px";while(p(document.getElementById(P),m)){if(l.shape==="rectangular"){L++,L*n>(1+Math.floor(J/2))*n*(J%4%2===0?1:e)&&(L=0,J++);switch(J%4){case 1:B+=n*e+Math.random()*2;break;case 2:f-=n+Math.random()*2;break;case 3:B-=n*e+Math.random()*2;break;case 0:f+=n+Math.random()*2}}else{M+=n,N+=(R%2===0?1:-1)*n,B=l.center.x-D/2+M*Math.cos(N)*e,f=l.center.y+M*Math.sin(N)-C/2}K.left=B+"px",K.top=f+"px"}m.push(document.getElementById(P)),b.isFunction(Q.afterWordRender)&&Q.afterWordRender.call(F)},c=function(f){f=f||0;if(!k.is(":visible")){setTimeout(function(){c(f)},10);return}f