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

27 lines
19 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/01 -- all modified lines have "mod Shad Laws" comments
* - included initialDecel and deadZone as options
* - set defaults of new options to mimic behavior without them (false and 0)
* - removed two unnecessary variable declarations caught by YUI Compressor
*/
(function(I){var R,Q,G=Math.abs,r=Math.sin,h=Math.cos,z=Math.max,V=Math.min,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(R=0;R<256;++R){Q=R.toString(16);if(R<16){Q="0"+Q}C[Q]=C[Q.toUpperCase()]=R.toString()+","}function N(i){return typeof(i)!="undefined"}function H(j){var Y=j.length-1,X,Z;while(Y){Z=~~(Math.random()*Y);X=j[Y];j[Y]=j[Z];j[Z]=X;--Y}}function n(Y,aa,af,ac){var ab,ae,j,ad,ag=[],Z=Math.PI*(3-Math.sqrt(5)),X=2/Y;for(ab=0;ab<Y;++ab){ae=ab*X-1+(X/2);j=Math.sqrt(1-ae*ae);ad=ab*Z;ag.push([h(ad)*j*aa,ae*af,r(ad)*j*ac])}return ag}function U(Z,X,ac,ai,ah,af,ae,ad,ab){var ag,aj=[],aa=Math.PI*(3-Math.sqrt(5)),Y=2/Z;for(af=0;af<Z;++af){ae=af*Y-1+(Y/2);ag=af*aa;ad=h(ag);ab=r(ag);aj.push(X?[ae*ac,ad*ai,ab*ah]:[ad*ac,ae*ai,ab*ah])}return aj}function w(Y,i,j,X){return U(Y,0,i,j,X)}function F(Y,i,j,X){return U(Y,1,i,j,X)}function p(aa,i){var Z=aa,Y,X,j=(i*1).toPrecision(3)+")";if(aa[0]==="#"){if(!B[aa]){if(aa.length===4){B[aa]="rgba("+D[aa[1]]+D[aa[2]]+D[aa[3]]}else{B[aa]="rgba("+C[aa.substr(1,2)]+C[aa.substr(3,2)]+C[aa.substr(5,2)]}}Z=B[aa]+j}else{if(aa.substr(0,4)==="rgb("||aa.substr(0,4)==="hsl("){Z=(aa.replace("(","a(").replace(")",","+j))}else{if(aa.substr(0,5)==="rgba("||aa.substr(0,5)==="hsla("){Y=aa.lastIndexOf(",")+1,X=aa.indexOf(")");i*=parseFloat(aa.substring(Y,X));Z=aa.substr(0,Y)+i.toPrecision(3)+")"}}}return Z}function g(i,j){if(window.G_vmlCanvasManager){return null}var X=l.createElement("canvas");X.width=i;X.height=j;return X}function v(){var j=g(3,3),Y,X;if(!j){return false}Y=j.getContext("2d");Y.strokeStyle="#000";Y.shadowColor="#fff";Y.shadowBlur=3;Y.globalAlpha=0;Y.strokeRect(2,2,2,2);Y.globalAlpha=1;X=Y.getImageData(2,2,1,1);j=null;return(X.data[0]>0)}function W(ae,j){var X=1024,aa=ae.weightGradient,Z,ac,Y,ad,ab;if(ae.gCanvas){ac=ae.gCanvas.getContext("2d")}else{ae.gCanvas=Z=g(X,1);if(!Z){return null}ac=Z.getContext("2d");ad=ac.createLinearGradient(0,0,X,0);for(Y in aa){ad.addColorStop(1-Y,aa[Y])}ac.fillStyle=ad;ac.fillRect(0,0,X,1)}ab=ac.getImageData(~~((X-1)*j),0,1,1).data;return"rgba("+ab[0]+","+ab[1]+","+ab[2]+","+(ab[3]/255)+")"}function u(aa,Z,X,ad,ab,ac,j){var Y=(ac||0)+(j&&j[0]<0?G(j[0]):0),i=(ac||0)+(j&&j[1]<0?G(j[1]):0);aa.font=Z;aa.textBaseline="top";aa.fillStyle=X;ab&&(aa.shadowColor=ab);ac&&(aa.shadowBlur=ac);j&&(aa.shadowOffsetX=j[0],aa.shadowOffsetY=j[1]);aa.fillText(ad,Y,i)}function m(aj,ab,af,ah,aa,X,ad,ae,j,ai,ag){var Y=ah+G(j[0])+ae+ae,i=aa+G(j[1])+ae+ae,Z,ac;Z=g(Y+ai,i+ag);if(!Z){return null}ac=Z.getContext("2d");u(ac,ab,X,aj,ad,ae,j);return Z}function P(ab,ae,af,Y){var Z=ab.width+G(Y[0])+af+af,j=ab.height+G(Y[1])+af+af,ac,ad,aa=(af||0)+(Y&&Y[0]<0?G(Y[0]):0),X=(af||0)+(Y&&Y[1]<0?G(Y[1]):0);ac=g(Z,j);if(!ac){return null}ad=ac.getContext("2d");ae&&(ad.shadowColor=ae);af&&(ad.shadowBlur=af);Y&&(ad.shadowOffsetX=Y[0],ad.shadowOffsetY=Y[1]);ad.drawImage(ab,aa,X);return ac}function K(aj,ab,ah){var ai=parseInt(aj.length*ah),aa=parseInt(ah*2),Y=g(ai,aa),ae,j,Z,ad,ag,af,X,ac;if(!Y){return null}ae=Y.getContext("2d");ae.fillStyle="#000";ae.fillRect(0,0,ai,aa);u(ae,ah+"px "+ab,"#fff",aj);j=ae.getImageData(0,0,ai,aa);Z=j.width;ad=j.height;ac={min:{x:Z,y:ad},max:{x:-1,y:-1}};for(af=0;af<ad;++af){for(ag=0;ag<Z;++ag){X=(af*Z+ag)*4;if(j.data[X+1]>0){if(ag<ac.min.x){ac.min.x=ag}if(ag>ac.max.x){ac.max.x=ag}if(af<ac.min.y){ac.min.y=af}if(af>ac.max.y){ac.max.y=af}}}}if(Z!=ai){ac.min.x*=(ai/Z);ac.max.x*=(ai/Z)}if(ad!=aa){ac.min.y*=(ai/ad);ac.max.y*=(ai/ad)}Y=null;return ac}function t(i){return"'"+i.replace(/(\'|\")/g,"").replace(/\s*,\s*/g,"', '")+"'"}function A(i,j,X){X=X||l;if(X.addEventListener){X.addEventListener(i,j,false)}else{X.attachEvent("on"+i,j)}}function O(Z,ab,Y,j){var X=j.taglist,aa=j.imageScale;if(aa&&!(ab.width&&ab.height)){A("load",function(){O(Z,ab,Y,j)},window);return}if(!Z.complete){A("load",function(){O(Z,ab,Y,j)},Z);return}ab.width=ab.width;ab.height=ab.height;if(aa){Z.width=ab.width*aa;Z.height=ab.