/*! * jQCloud Plugin for jQuery * * Version 1.0.4 * * Copyright 2012, Luca Ongaro, Fabio Neves * Licensed under the MIT license. * * Date: 2012-12-03 15:04:52 -0500 */ (function(e){"use strict";e.fn.jQCloud=function(t,n){var r=this,i=r.attr("id")||Math.floor(Math.random()*1e6).toString(36),s={width:r.width(),height:r.height(),center:{x:n&&n.width?n.width:r.width()/2,y:n&&n.height?n.height:r.height()/2},delayedMode:t.length>50,shape:!1,encodeURI:!0,customClass:"",toggleClasses:!1,overlapFactor:0,testBoundaries:!1};n=e.extend(s,n||{}),r.addClass("jqcloud").width(n.width).height(n.height),r.css("position")==="static"&&r.css("position","relative");var o=function(){var s=function(e,t){var r=function(e,t){if(n.testBoundaries)if(e.offsetLeft<0||e.offsetTop<0||e.offsetTop+e.offsetHeight>n.height||e.offsetLeft+e.offsetWidth>n.width)return!0;var r=2+Math.abs(n.overlapFactor/10);return Math.abs(r*e.offsetLeft+e.offsetWidth-r*t.offsetLeft-t.offsetWidth)t.weight?-1:0});var u=n.shape==="rectangular"?18:2,a=[],f=n.width/n.height,l="a",c=function(o,c){var h=i+"_word_"+o,p="#"+h,d=6.28*Math.random(),v=0,m=0,g=0,y=5,b=n.customClass,w="",E="";c.html=e.extend(c.html,{id:h}),c.html&&c.html["class"]&&(b=c.html["class"],delete c.html["class"]),t[0].weight>t[t.length-1].weight&&(y=Math.round((c.weight-t[t.length-1].weight)/(t[0].weight-t[t.length-1].weight)*9)+1);var S="w";n.toggleClasses&&(S="w"+l,l=l==="a"?"b":"a"),E=e("").attr(c.html).addClass(S+y+" "+b),c.link?(typeof c.link=="string"&&(c.link={href:c.link}),n.encodeURI&&(c.link=e.extend(c.link,{href:encodeURI(c.link.href).replace(/'/g,"%27")})),w=e("").attr(c.link).text(c.text)):w=c.text,E.append(w);if(!!c.handlers)for(var x in c.handlers)c.handlers.hasOwnProperty(x)&&typeof c.handlers[x]=="function"&&e(E).bind(x,c.handlers[x]);r.append(E);var T=E.width(),N=E.height(),C=n.center.x-T/2,k=n.center.y-N/2,L=E[0].style;L.position="absolute",L.left=C+"px",L.top=k+"px";while(s(document.getElementById(h),a)){if(n.shape==="rectangular"){m++,m*u>(1+Math.floor(g/2))*u*(g%4%2===0?1:f)&&(m=0,g++);switch(g%4){case 1:C+=u*f+Math.random()*2;break;case 2:k-=u+Math.random()*2;break;case 3:C-=u*f+Math.random()*2;break;case 0:k+=u+Math.random()*2}}else v+=u,d+=(o%2===0?1:-1)*u,C=n.center.x-T/2+v*Math.cos(d)*f,k=n.center.y+v*Math.sin(d)-N/2;L.left=C+"px",L.top=k+"px"}a.push(document.getElementById(h)),e.isFunction(c.afterWordRender)&&c.afterWordRender.call(E)},h=function(i){i=i||0;if(!r.is(":visible")){setTimeout(function(){h(i)},10);return}i