root / trunk / web / dojo / dojox / fx / ext-dojo / complex.js
History | View | Annotate | Download (2.39 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.fx.ext-dojo.complex"]){ |
||
9 | dojo._hasResource["dojox.fx.ext-dojo.complex"]=true; |
||
10 | dojo.provide("dojox.fx.ext-dojo.complex");
|
||
11 | (function(){
|
||
12 | var da=dojo.animateProperty;
|
||
13 | dojo.animateProperty=function(_1){ |
||
14 | var d=dojo;
|
||
15 | var _2=da(_1);
|
||
16 | dojo.connect(_2,"beforeBegin",function(){ |
||
17 | _2.curve.getValue=function(r){ |
||
18 | var _3={};
|
||
19 | for(var p in this._properties){ |
||
20 | var _4=this._properties[p],_5=_4.start; |
||
21 | if(_5 instanceof d.Color){ |
||
22 | _3[p]=d.blendColors(_5,_4.end,r,_4.tempColor).toCss(); |
||
23 | }else{
|
||
24 | if(_5 instanceof dojox.fx._Complex){ |
||
25 | _3[p]=_5.getValue(r); |
||
26 | }else{
|
||
27 | if(!d.isArray(_5)){
|
||
28 | _3[p]=((_4.end-_5)*r)+_5+(p!="opacity"?_4.units||"px":0); |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | return _3;
|
||
34 | }; |
||
35 | var pm={};
|
||
36 | for(var p in this.properties){ |
||
37 | var o=this.properties[p]; |
||
38 | if(typeof (o.start)=="string"&&/\(/.test(o.start)){ |
||
39 | this.curve._properties[p].start=new dojox.fx._Complex(o); |
||
40 | } |
||
41 | } |
||
42 | }); |
||
43 | return _2;
|
||
44 | }; |
||
45 | })(); |
||
46 | dojo.declare("dojox.fx._Complex",null,{PROP:/\([+-]?[\w|,|#|\.|\s]*\)/g,constructor:function(_6){ |
||
47 | var _7=_6.start.match(this.PROP); |
||
48 | var _8=_6.end.match(this.PROP); |
||
49 | var _9=dojo.map(_7,this.getProps,this); |
||
50 | var _a=dojo.map(_8,this.getProps,this); |
||
51 | this._properties={};
|
||
52 | this.strProp=_6.start;
|
||
53 | dojo.forEach(_9,function(_b,i){
|
||
54 | dojo.forEach(_b,function(p,j){
|
||
55 | this.strProp=this.strProp.replace(p,"PROP_"+i+""+j); |
||
56 | this._properties["PROP_"+i+""+j]=this.makePropObject(p,_a[i][j]); |
||
57 | },this);
|
||
58 | },this);
|
||
59 | },getValue:function(r){ |
||
60 | var _c=this.strProp,u; |
||
61 | for(var nm in this._properties){ |
||
62 | var v,o=this._properties[nm]; |
||
63 | if(o.units=="isColor"){ |
||
64 | v=dojo.blendColors(o.beg,o.end,r).toCss(false);
|
||
65 | u="";
|
||
66 | }else{
|
||
67 | v=((o.end-o.beg)*r)+o.beg; |
||
68 | u=o.units; |
||
69 | } |
||
70 | _c=_c.replace(nm,v+u); |
||
71 | } |
||
72 | return _c;
|
||
73 | },makePropObject:function(_d,_e){ |
||
74 | var b=this.getNumAndUnits(_d); |
||
75 | var e=this.getNumAndUnits(_e); |
||
76 | return {beg:b.num,end:e.num,units:b.units}; |
||
77 | },getProps:function(_f){ |
||
78 | _f=_f.substring(1,_f.length-1); |
||
79 | var s;
|
||
80 | if(/,/.test(_f)){ |
||
81 | _f=_f.replace(/\s/g,""); |
||
82 | s=_f.split(",");
|
||
83 | }else{
|
||
84 | _f=_f.replace(/\s{2,}/g," "); |
||
85 | s=_f.split(" ");
|
||
86 | } |
||
87 | return s;
|
||
88 | },getNumAndUnits:function(_10){ |
||
89 | if(!_10){
|
||
90 | return {};
|
||
91 | } |
||
92 | if(/#/.test(_10)){ |
||
93 | return {num:new dojo.Color(_10),units:"isColor"}; |
||
94 | } |
||
95 | var o={num:parseFloat(/-*[\d\.\d|\d]{1,}/.exec(_10).join(""))}; |
||
96 | o.units=/[a-z]{1,}/.exec(_10);
|
||
97 | o.units=o.units&&o.units.length?o.units.join(""):""; |
||
98 | return o;
|
||
99 | }}); |
||
100 | } |