1
0
This repository has been archived on 2021-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
gallery3-contrib/3.0/modules/tag_cloud_html5/js/jquery.tagcanvas.mod.min.js

30 lines
20 KiB
JavaScript
Raw Normal View History

/**
* Copyright (C) 2010-2012 Graham Breach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* jQuery.tagcanvas 1.17.1
* For more information, please contact <graham@goat1000.com>
*/
/**
* Modified by Shad Laws 2012/06/08 -- all modified lines have "mod Shad Laws" comments
* - built a physics-based model for motion, which is activated with the physModel flag
* - included initialDecel, deadZone, maxInputZone, and physModel as options
* - set defaults of new options to mimic behavior without them (false, 0, 0, and false)
* - removed two unnecessary variable declarations caught by YUI Compressor
* - fixed initialization of a few variables (minSpeed, decel, yaw/pitch)
* - fixed problem with html margin-top changing coordinates in IE (but not Chrome or Firefox)
*/
(function(I){var S,R,G=Math.abs,r=Math.sin,h=Math.cos,z=Math.max,W=Math.min,M=Math.sqrt,B={},C={},D={0:"0,",1:"17,",2:"34,",3:"51,",4:"68,",5:"85,",6:"102,",7:"119,",8:"136,",9:"153,",a:"170,",A:"170,",b:"187,",B:"187,",c:"204,",C:"204,",d:"221,",D:"221,",e:"238,",E:"238,",f:"255,",F:"255,"},e,J,d,l=document,y,c={};for(S=0;S<256;++S){R=S.toString(16);if(S<16){R="0"+R}C[R]=C[R.toUpperCase()]=S.toString()+","}function O(i){return typeof(i)!="undefined"}function H(j){var Z=j.length-1,Y,aa;while(Z){aa=~~(Math.random()*Z);Y=j[Z];j[Z]=j[aa];j[aa]=Y;--Z}}function n(Z,ab,ag,ad){var ac,af,j,ae,ah=[],aa=Math.PI*(3-Math.sqrt(5)),Y=2/Z;for(ac=0;ac<Z;++ac){af=ac*Y-1+(Y/2);j=Math.sqrt(1-af*af);ae=ac*aa;ah.push([h(ae)*j*ab,af*ag,r(ae)*j*ad])}return ah}function V(aa,Y,ad,aj,ai,ag,af,ae,ac){var ah,ak=[],ab=Math.PI*(3-Math.sqrt(5)),Z=2/aa;for(ag=0;ag<aa;++ag){af=ag*Z-1+(Z/2);ah=ag*ab;ae=h(ah);ac=r(ah);ak.push(Y?[af*ad,ae*aj,ac*ai]:[ae*ad,af*aj,ac*ai])}return ak}function w(Z,i,j,Y){return V(Z,0,i,j,Y)}function F(Z,i,j,Y){return V(Z,1,i,j,Y)}function p(ab,i){var aa=ab,Z,Y,j=(i*1).toPrecision(3)+")";if(ab[0]==="#"){if(!B[ab]){if(ab.length===4){B[ab]="rgba("+D[ab[1]]+D[ab[2]]+D[ab[3]]}else{B[ab]="rgba("+C[ab.substr(1,2)]+C[ab.substr(3,2)]+C[ab.substr(5,2)]}}aa=B[ab]+j}else{if(ab.substr(0,4)==="rgb("||ab.substr(0,4)==="hsl("){aa=(ab.replace("(","a(").replace(")",","+j))}else{if(ab.substr(0,5)==="rgba("||ab.substr(0,5)==="hsla("){Z=ab.lastIndexOf(",")+1,Y=ab.indexOf(")");i*=parseFloat(ab.substring(Z,Y));aa=ab.substr(0,Z)+i.toPrecision(3)+")"}}}return aa}function g(i,j){if(window.G_vmlCanvasManager){return null}var Y=l.createElement("canvas");Y.width=i;Y.height=j;return Y}function v(){var j=g(3,3),Z,Y;if(!j){return false}Z=j.getContext("2d");Z.strokeStyle="#000";Z.shadowColor="#fff";Z.shadowBlur=3;Z.globalAlpha=0;Z.strokeRect(2,2,2,2);Z.globalAlpha=1;Y=Z.getImageData(2,2,1,1);j=null;return(Y.data[0]>0)}function X(af,j){var Y=1024,ab=af.weightGradient,aa,ad,Z,ae,ac;if(af.gCanvas){ad=af.gCanvas.getContext("2d")}else{af.gCanvas=aa=g(Y,1);if(!aa){return null}ad=aa.getContext("2d");ae=ad.createLinearGradient(0,0,Y,0);for(Z in ab){ae.addColorStop(1-Z,ab[Z])}ad.fillStyle=ae;ad.fillRect(0,0,Y,1)}ac=ad.getImageData(~~((Y-1)*j),0,1,1).data;return"rgba("+ac[0]+","+ac[1]+","+ac[2]+","+(ac[3]/255)+")"}function u(ab,aa,Y,ae,ac,ad,j){var Z=(ad||0)+(j&&j[0]<0?G(j[0]):0),i=(ad||0)+(j&&j[1]<0?G(j[1]):0);ab.font=aa;ab.textBaseline="top";ab.fillStyle=Y;ac&&(ab.shadowColor=ac);ad&&(ab.shadowBlur=ad);j&&(ab.shadowOffsetX=j[0],ab.shadowOffsetY=j[1]);ab.fillText(ae,Z,i)}function m(ak,ac,ag,ai,ab,Y,ae,af,j,aj,ah){var Z=ai+G(j[0])+af+af,i=ab+G(j[1])+af+af,aa,ad;aa=g(Z+aj,i+ah);if(!aa){return null}ad=aa.getContext("2d");u(ad,ac,Y,ak,ae,af,j);return aa}function Q(ac,af,ag,Z){var aa=ac.width+G(Z[0])+ag+ag,j=ac.height+G(Z[1])+ag+ag,ad,ae,ab=(ag||0)+(Z&&Z[0]<0?G(Z[0]):0),Y=(ag||0)+(Z&&Z[1]<0?G(Z[1]):0);ad=g(aa,j);if(!ad){return null}ae=ad.getContext("2d");af&&(ae.shadowColor=af);ag&&(ae.shadowBlur=ag);Z&&(ae.shadowOffsetX=Z[0],ae.shadowOffsetY=Z[1]);ae.drawImage(ac,ab,Y);return ad}function K(ak,ac,ai){var aj=parseInt(ak.length*ai),ab=parseInt(ai*2),Z=g(aj,ab),af,j,aa,ae,ah,ag,Y,ad;if(!Z){return null}af=Z.getContext("2d");af.fillStyle="#000";af.fillRect(0,0,aj,ab);u(af,ai+"px "+ac,"#fff",ak);j=af.getImageData(0,0,aj,ab);aa=j.width;ae=j.height;ad={min:{x:aa,y:ae},max:{x:-1,y:-1}};for(ag=0;ag<ae;++ag){for(ah=0;ah<aa;++ah){Y=(ag*aa+ah)*4;if(j.data[Y+1]>0){if(ah<ad.min.x){ad.min.x=ah}if(ah>ad.max.x){ad.max.x=ah}if(ag<ad.min.y){ad.min.y=ag}if(ag>ad.max.y){ad.max.y=ag}}}}if(aa!=aj){ad.min.x*=(aj/aa);ad.max.x*=(aj/aa)}if(ae!=ab){ad.min.y*=(aj/ae);ad.max.y*=(aj/ae)}Z=null;return ad}function t(i){return"'"+i.replace(/(\'|\")/g,"").replace(/\s*,\s*/g,"', '")+"'"}function A(i,j,Y){Y=Y||l;if(Y.addEventListener){Y.addEventListener(i,j,false)}else{Y.attachEvent("on"+i,j)}}function P(aa,ac,Z,j){var Y=j.taglist,ab=j.imageScale;if(ab&&!(ac.width&&ac.height)){A("load",function(){P(aa,ac,Z,j)},window);return}if(!aa.complete){A("load",function(){P(aa,ac,Z,j)},aa);return}ac.width=ac.width;ac.heig