text.js
5.1 KB
//>>built
define("dojo/_base/lang ./_base dojo/_base/fx dojo/fx dojo/fx/easing dojo/dom dojo/dom-style dojo/_base/html dojo/_base/connect".split(" "),function(w,A,q,y,p,k,r,x,v){var d=w.getObject("dojox.fx.text",!0);d._split=function(a){function f(b){var c=b.nextSibling;if("SPAN"==b.tagName&&1==b.childNodes.length&&3==b.firstChild.nodeType){var e=x.coords(b,!0);q++;r.set(b,{padding:0,margin:0,top:a.crop?"0px":e.t+"px",left:a.crop?"0px":e.l+"px",display:"inline"});b=a.pieceAnimation(b,e,g,q,p);w.isArray(b)?
m=m.concat(b):m[m.length]=b}else b.firstChild&&f(b.firstChild);c&&f(c)}var b=a.node=k.byId(a.node),c=b.style,e=r.getComputedStyle(b),g=x.coords(b,!0);a.duration=a.duration||1E3;a.words=a.words||!1;var h=a.text&&"string"==typeof a.text?a.text:b.innerHTML,d=c.height,n=c.width,m=[];r.set(b,{height:e.height,width:e.width});for(var c=/(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)/g,e=a.words?/(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)\s*|([^\s<]+\s*)/g:/(<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>)\s*|([^\s<]\s*)/g,
e="string"==typeof a.text?a.text.match(e):b.innerHTML.match(e),l="",p=0,q=0,t=0;t<e.length;t++){var u=e[t];u.match(c)?l+=u:(l+="\x3cspan\x3e"+u+"\x3c/span\x3e",p++)}b.innerHTML=l;f(b.firstChild);c=y.combine(m);v.connect(c,"onEnd",c,function(){b.innerHTML=h;r.set(b,{height:d,width:n})});a.onPlay&&v.connect(c,"onPlay",c,a.onPlay);a.onEnd&&v.connect(c,"onEnd",c,a.onEnd);return c};d.explode=function(a){a.node=k.byId(a.node);a.distance=a.distance||1;a.duration=a.duration||1E3;a.random=a.random||0;"undefined"==
typeof a.fade&&(a.fade=!0);"undefined"==typeof a.sync&&(a.sync=!0);a.random=Math.abs(a.random);a.pieceAnimation=function(f,b,c,e,g){var d=b.h,z=b.w;g=2*a.distance;e=a.duration;var n=parseFloat(f.style.top),m=parseFloat(f.style.left),l=0,k=0,v=0;a.random&&(l=Math.random()*a.random+Math.max(1-a.random,0),g*=l,e*=l,l=a.unhide&&a.sync||!a.unhide&&!a.sync?a.duration-e:0,k=Math.random()-.5,v=Math.random()-.5);d=(c.h-d)/2-(b.y-c.y);b=(c.w-z)/2-(b.x-c.x);c=Math.sqrt(Math.pow(b,2)+Math.pow(d,2));var t=n-d*
g+c*v,u=m-b*g+c*k;b=q.animateProperty({node:f,duration:e,delay:l,easing:a.easing||(a.unhide?p.sinOut:p.circOut),beforeBegin:a.unhide?function(){a.fade&&r.set(f,"opacity",0);f.style.position=a.crop?"relative":"absolute";f.style.top=t+"px";f.style.left=u+"px"}:function(){f.style.position=a.crop?"relative":"absolute"},properties:{top:a.unhide?{start:t,end:n}:{start:n,end:t},left:a.unhide?{start:u,end:m}:{start:m,end:u}}});return a.fade?(e=q.animateProperty({node:f,duration:e,delay:l,easing:a.fadeEasing||
p.quadOut,properties:{opacity:a.unhide?{start:0,end:1}:{end:0}}}),a.unhide?[e,b]:[b,e]):b};return d._split(a)};d.converge=function(a){a.unhide=!0;return d.explode(a)};d.disintegrate=function(a){a.node=k.byId(a.node);a.duration=a.duration||1500;a.distance=a.distance||1.5;a.random=a.random||0;a.fade||(a.fade=!0);var f=Math.abs(a.random);a.pieceAnimation=function(b,c,e,d,h){var g=a.interval||a.duration/(1.5*h);c=a.duration-h*g;d=Math.random()*h*g*f+Math.max(1-f,0)*(a.reverseOrder||0>a.distance?d*g:(h-
d)*g);var n={};a.unhide?(n.top={start:parseFloat(b.style.top)-e.h*a.distance,end:parseFloat(b.style.top)},a.fade&&(n.opacity={start:0,end:1})):(n.top={end:parseFloat(b.style.top)+e.h*a.distance},a.fade&&(n.opacity={end:0}));return q.animateProperty({node:b,duration:c,delay:d,easing:a.easing||(a.unhide?p.sinIn:p.circIn),properties:n,beforeBegin:a.unhide?function(){a.fade&&r.set(b,"opacity",0);b.style.position=a.crop?"relative":"absolute";b.style.top=n.top.start+"px"}:function(){b.style.position=a.crop?
"relative":"absolute"}})};return d._split(a)};d.build=function(a){a.unhide=!0;return d.disintegrate(a)};d.blockFadeOut=function(a){a.node=k.byId(a.node);a.duration=a.duration||1E3;a.random=a.random||0;var f=Math.abs(a.random);a.pieceAnimation=function(b,c,e,d,h){c=a.interval||a.duration/(1.5*h);return q.animateProperty({node:b,duration:a.duration-h*c,delay:Math.random()*h*c*f+Math.max(1-f,0)*(a.reverseOrder?(h-d)*c:d*c),easing:a.easing||p.sinInOut,properties:{opacity:a.unhide?{start:0,end:1}:{end:0}},
beforeBegin:a.unhide?function(){r.set(b,"opacity",0)}:void 0})};return d._split(a)};d.blockFadeIn=function(a){a.unhide=!0;return d.blockFadeOut(a)};d.backspace=function(a){a.node=k.byId(a.node);a.words=!1;a.duration=a.duration||2E3;a.random=a.random||0;var f=Math.abs(a.random),b=10;a.pieceAnimation=function(c,d,g,h,k){d=a.interval||a.duration/(1.5*k);g="textContent"in c?c.textContent:c.innerText;var e=g.match(/\s/g);"undefined"==typeof a.wordDelay&&(a.wordDelay=2*d);a.unhide||(b=(k-h-1)*d);var m,
l;a.fixed?a.unhide&&(m=function(){r.set(c,"opacity",0)}):a.unhide?(m=function(){c.style.display="none"},l=function(){c.style.display="inline"}):l=function(){c.style.display="none"};h=q.animateProperty({node:c,duration:1,delay:b,easing:a.easing||p.sinInOut,properties:{opacity:a.unhide?{start:0,end:1}:{end:0}},beforeBegin:m,onEnd:l});a.unhide&&(k=Math.random()*g.length*d,b+=k*f+Math.max(1-f,0)*d*g.length+(k*f/2+Math.max(1-f/2,0)*a.wordDelay)*(e&&g.lastIndexOf(e[e.length-1])==g.length-1));return h};
return d._split(a)};d.type=function(a){a.unhide=!0;return d.backspace(a)};return d});