Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / fx / split.js @ 12

History | View | Annotate | Download (10.2 KB)

1
/*
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.split"]){
9
dojo._hasResource["dojox.fx.split"]=true;
10
dojo.provide("dojox.fx.split");
11
dojo.require("dojo.fx");
12
dojo.require("dojo.fx.easing");
13
dojo.mixin(dojox.fx,{_split:function(_1){
14
_1.rows=_1.rows||3;
15
_1.columns=_1.columns||3;
16
_1.duration=_1.duration||1000;
17
var _2=_1.node=dojo.byId(_1.node),_3=_2.parentNode,_4=_3,_5=dojo.body(),_6="position";
18
while(_4&&_4!=_5&&dojo.style(_4,_6)=="static"){
19
_4=_4.parentNode;
20
}
21
var _7=_4!=_5?dojo.position(_4,true):{x:0,y:0},_8=dojo.position(_2,true),_9=dojo.style(_2,"height"),_a=dojo.style(_2,"width"),_b=dojo.style(_2,"borderLeftWidth")+dojo.style(_2,"borderRightWidth"),_c=dojo.style(_2,"borderTopWidth")+dojo.style(_2,"borderBottomWidth"),_d=Math.ceil(_9/_1.rows),_e=Math.ceil(_a/_1.columns),_f=dojo.create(_2.tagName,{style:{position:"absolute",padding:0,margin:0,border:"none",top:_8.y-_7.y+"px",left:_8.x-_7.x+"px",height:_9+_c+"px",width:_a+_b+"px",background:"none",overflow:_1.crop?"hidden":"visible",zIndex:dojo.style(_2,"zIndex")}},_2,"after"),_10=[],_11=dojo.create(_2.tagName,{style:{position:"absolute",border:"none",padding:0,margin:0,height:_d+_b+"px",width:_e+_c+"px",overflow:"hidden"}});
22
for(var y=0,ly=_1.rows;y<ly;y++){
23
for(var x=0,lx=_1.columns;x<lx;x++){
24
var _12=dojo.clone(_11),_13=dojo.clone(_2),_14=y*_d,_15=x*_e;
25
_13.style.filter="";
26
dojo.removeAttr(_13,"id");
27
dojo.style(_12,{border:"none",overflow:"hidden",top:_14+"px",left:_15+"px"});
28
dojo.style(_13,{position:"static",opacity:"1",marginTop:-_14+"px",marginLeft:-_15+"px"});
29
_12.appendChild(_13);
30
_f.appendChild(_12);
31
var _16=_1.pieceAnimation(_12,x,y,_8);
32
if(dojo.isArray(_16)){
33
_10=_10.concat(_16);
34
}else{
35
_10.push(_16);
36
}
37
}
38
}
39
var _17=dojo.fx.combine(_10);
40
dojo.connect(_17,"onEnd",_17,function(){
41
_f.parentNode.removeChild(_f);
42
});
43
if(_1.onPlay){
44
dojo.connect(_17,"onPlay",_17,_1.onPlay);
45
}
46
if(_1.onEnd){
47
dojo.connect(_17,"onEnd",_17,_1.onEnd);
48
}
49
return _17;
50
},explode:function(_18){
51
var _19=_18.node=dojo.byId(_18.node);
52
_18.rows=_18.rows||3;
53
_18.columns=_18.columns||3;
54
_18.distance=_18.distance||1;
55
_18.duration=_18.duration||1000;
56
_18.random=_18.random||0;
57
if(!_18.fade){
58
_18.fade=true;
59
}
60
if(typeof _18.sync=="undefined"){
61
_18.sync=true;
62
}
63
_18.random=Math.abs(_18.random);
64
_18.pieceAnimation=function(_1a,x,y,_1b){
65
var _1c=_1b.h/_18.rows,_1d=_1b.w/_18.columns,_1e=_18.distance*2,_1f=_18.duration,ps=_1a.style,_20=parseInt(ps.top),_21=parseInt(ps.left),_22=0,_23=0,_24=0;
66
if(_18.random){
67
var _25=(Math.random()*_18.random)+Math.max(1-_18.random,0);
68
_1e*=_25;
69
_1f*=_25;
70
_22=((_18.unhide&&_18.sync)||(!_18.unhide&&!_18.sync))?(_18.duration-_1f):0;
71
_23=Math.random()-0.5;
72
_24=Math.random()-0.5;
73
}
74
var _26=((_1b.h-_1c)/2-_1c*y),_27=((_1b.w-_1d)/2-_1d*x),_28=Math.sqrt(Math.pow(_27,2)+Math.pow(_26,2)),_29=parseInt(_20-_26*_1e+_28*_24),_2a=parseInt(_21-_27*_1e+_28*_23);
75
var _2b=dojo.animateProperty({node:_1a,duration:_1f,delay:_22,easing:(_18.easing||(_18.unhide?dojo.fx.easing.sinOut:dojo.fx.easing.circOut)),beforeBegin:(_18.unhide?function(){
76
if(_18.fade){
77
dojo.style(_1a,{opacity:"0"});
78
}
79
ps.top=_29+"px";
80
ps.left=_2a+"px";
81
}:undefined),properties:{top:(_18.unhide?{start:_29,end:_20}:{start:_20,end:_29}),left:(_18.unhide?{start:_2a,end:_21}:{start:_21,end:_2a})}});
82
if(_18.fade){
83
var _2c=dojo.animateProperty({node:_1a,duration:_1f,delay:_22,easing:(_18.fadeEasing||dojo.fx.easing.quadOut),properties:{opacity:(_18.unhide?{start:"0",end:"1"}:{start:"1",end:"0"})}});
84
return (_18.unhide?[_2c,_2b]:[_2b,_2c]);
85
}else{
86
return _2b;
87
}
88
};
89
var _2d=dojox.fx._split(_18);
90
if(_18.unhide){
91
dojo.connect(_2d,"onEnd",null,function(){
92
dojo.style(_19,{opacity:"1"});
93
});
94
}else{
95
dojo.connect(_2d,"onPlay",null,function(){
96
dojo.style(_19,{opacity:"0"});
97
});
98
}
99
return _2d;
100
},converge:function(_2e){
101
_2e.unhide=true;
102
return dojox.fx.explode(_2e);
103
},disintegrate:function(_2f){
104
var _30=_2f.node=dojo.byId(_2f.node);
105
_2f.rows=_2f.rows||5;
106
_2f.columns=_2f.columns||5;
107
_2f.duration=_2f.duration||1500;
108
_2f.interval=_2f.interval||_2f.duration/(_2f.rows+_2f.columns*2);
109
_2f.distance=_2f.distance||1.5;
110
_2f.random=_2f.random||0;
111
if(typeof _2f.fade=="undefined"){
112
_2f.fade=true;
113
}
114
var _31=Math.abs(_2f.random),_32=_2f.duration-(_2f.rows+_2f.columns)*_2f.interval;
115
_2f.pieceAnimation=function(_33,x,y,_34){
116
var _35=Math.random()*(_2f.rows+_2f.columns)*_2f.interval,ps=_33.style,_36=(_2f.reverseOrder||_2f.distance<0)?((x+y)*_2f.interval):(((_2f.rows+_2f.columns)-(x+y))*_2f.interval),_37=_35*_31+Math.max(1-_31,0)*_36,_38={};
117
if(_2f.unhide){
118
_38.top={start:(parseInt(ps.top)-_34.h*_2f.distance),end:parseInt(ps.top)};
119
if(_2f.fade){
120
_38.opacity={start:"0",end:"1"};
121
}
122
}else{
123
_38.top={end:(parseInt(ps.top)+_34.h*_2f.distance)};
124
if(_2f.fade){
125
_38.opacity={end:"0"};
126
}
127
}
128
var _39=dojo.animateProperty({node:_33,duration:_32,delay:_37,easing:(_2f.easing||(_2f.unhide?dojo.fx.easing.sinIn:dojo.fx.easing.circIn)),properties:_38,beforeBegin:(_2f.unhide?function(){
129
if(_2f.fade){
130
dojo.style(_33,{opacity:"0"});
131
}
132
ps.top=_38.top.start+"px";
133
}:undefined)});
134
return _39;
135
};
136
var _3a=dojox.fx._split(_2f);
137
if(_2f.unhide){
138
dojo.connect(_3a,"onEnd",_3a,function(){
139
dojo.style(_30,{opacity:"1"});
140
});
141
}else{
142
dojo.connect(_3a,"onPlay",_3a,function(){
143
dojo.style(_30,{opacity:"0"});
144
});
145
}
146
return _3a;
147
},build:function(_3b){
148
_3b.unhide=true;
149
return dojox.fx.disintegrate(_3b);
150
},shear:function(_3c){
151
var _3d=_3c.node=dojo.byId(_3c.node);
152
_3c.rows=_3c.rows||6;
153
_3c.columns=_3c.columns||6;
154
_3c.duration=_3c.duration||1000;
155
_3c.interval=_3c.interval||0;
156
_3c.distance=_3c.distance||1;
157
_3c.random=_3c.random||0;
158
if(typeof (_3c.fade)=="undefined"){
159
_3c.fade=true;
160
}
161
var _3e=Math.abs(_3c.random),_3f=(_3c.duration-(_3c.rows+_3c.columns)*Math.abs(_3c.interval));
162
_3c.pieceAnimation=function(_40,x,y,_41){
163
var _42=!(x%2),_43=!(y%2),_44=Math.random()*_3f,_45=(_3c.reverseOrder)?(((_3c.rows+_3c.columns)-(x+y))*_3c.interval):((x+y)*_3c.interval),_46=_44*_3e+Math.max(1-_3e,0)*_45,_47={},ps=_40.style;
164
if(_3c.fade){
165
_47.opacity=(_3c.unhide?{start:"0",end:"1"}:{end:"0"});
166
}
167
if(_3c.columns==1){
168
_42=_43;
169
}else{
170
if(_3c.rows==1){
171
_43=!_42;
172
}
173
}
174
var _48=parseInt(ps.left),top=parseInt(ps.top),_49=_3c.distance*_41.w,_4a=_3c.distance*_41.h;
175
if(_3c.unhide){
176
if(_42==_43){
177
_47.left=_42?{start:(_48-_49),end:_48}:{start:(_48+_49),end:_48};
178
}else{
179
_47.top=_42?{start:(top+_4a),end:top}:{start:(top-_4a),end:top};
180
}
181
}else{
182
if(_42==_43){
183
_47.left=_42?{end:(_48-_49)}:{end:(_48+_49)};
184
}else{
185
_47.top=_42?{end:(top+_4a)}:{end:(top-_4a)};
186
}
187
}
188
var _4b=dojo.animateProperty({node:_40,duration:_3f,delay:_46,easing:(_3c.easing||dojo.fx.easing.sinInOut),properties:_47,beforeBegin:(_3c.unhide?function(){
189
if(_3c.fade){
190
ps.opacity="0";
191
}
192
if(_42==_43){
193
ps.left=_47.left.start+"px";
194
}else{
195
ps.top=_47.top.start+"px";
196
}
197
}:undefined)});
198
return _4b;
199
};
200
var _4c=dojox.fx._split(_3c);
201
if(_3c.unhide){
202
dojo.connect(_4c,"onEnd",_4c,function(){
203
dojo.style(_3d,{opacity:"1"});
204
});
205
}else{
206
dojo.connect(_4c,"onPlay",_4c,function(){
207
dojo.style(_3d,{opacity:"0"});
208
});
209
}
210
return _4c;
211
},unShear:function(_4d){
212
_4d.unhide=true;
213
return dojox.fx.shear(_4d);
214
},pinwheel:function(_4e){
215
var _4f=_4e.node=dojo.byId(_4e.node);
216
_4e.rows=_4e.rows||4;
217
_4e.columns=_4e.columns||4;
218
_4e.duration=_4e.duration||1000;
219
_4e.interval=_4e.interval||0;
220
_4e.distance=_4e.distance||1;
221
_4e.random=_4e.random||0;
222
if(typeof _4e.fade=="undefined"){
223
_4e.fade=true;
224
}
225
var _50=(_4e.duration-(_4e.rows+_4e.columns)*Math.abs(_4e.interval));
226
_4e.pieceAnimation=function(_51,x,y,_52){
227
var _53=_52.h/_4e.rows,_54=_52.w/_4e.columns,_55=!(x%2),_56=!(y%2),_57=Math.random()*_50,_58=(_4e.interval<0)?(((_4e.rows+_4e.columns)-(x+y))*_4e.interval*-1):((x+y)*_4e.interval),_59=_57*_4e.random+Math.max(1-_4e.random,0)*_58,_5a={},ps=_51.style;
228
if(_4e.fade){
229
_5a.opacity=(_4e.unhide?{start:0,end:1}:{end:0});
230
}
231
if(_4e.columns==1){
232
_55=!_56;
233
}else{
234
if(_4e.rows==1){
235
_56=_55;
236
}
237
}
238
var _5b=parseInt(ps.left),top=parseInt(ps.top);
239
if(_55){
240
if(_56){
241
_5a.top=_4e.unhide?{start:top+_53*_4e.distance,end:top}:{start:top,end:top+_53*_4e.distance};
242
}else{
243
_5a.left=_4e.unhide?{start:_5b+_54*_4e.distance,end:_5b}:{start:_5b,end:_5b+_54*_4e.distance};
244
}
245
}
246
if(_55!=_56){
247
_5a.width=_4e.unhide?{start:_54*(1-_4e.distance),end:_54}:{start:_54,end:_54*(1-_4e.distance)};
248
}else{
249
_5a.height=_4e.unhide?{start:_53*(1-_4e.distance),end:_53}:{start:_53,end:_53*(1-_4e.distance)};
250
}
251
var _5c=dojo.animateProperty({node:_51,duration:_50,delay:_59,easing:(_4e.easing||dojo.fx.easing.sinInOut),properties:_5a,beforeBegin:(_4e.unhide?function(){
252
if(_4e.fade){
253
dojo.style(_51,"opacity",0);
254
}
255
if(_55){
256
if(_56){
257
ps.top=(top+_53*(1-_4e.distance))+"px";
258
}else{
259
ps.left=(_5b+_54*(1-_4e.distance))+"px";
260
}
261
}else{
262
ps.left=_5b+"px";
263
ps.top=top+"px";
264
}
265
if(_55!=_56){
266
ps.width=(_54*(1-_4e.distance))+"px";
267
}else{
268
ps.height=(_53*(1-_4e.distance))+"px";
269
}
270
}:undefined)});
271
return _5c;
272
};
273
var _5d=dojox.fx._split(_4e);
274
if(_4e.unhide){
275
dojo.connect(_5d,"onEnd",_5d,function(){
276
dojo.style(_4f,{opacity:"1"});
277
});
278
}else{
279
dojo.connect(_5d,"play",_5d,function(){
280
dojo.style(_4f,{opacity:"0"});
281
});
282
}
283
return _5d;
284
},unPinwheel:function(_5e){
285
_5e.unhide=true;
286
return dojox.fx.pinwheel(_5e);
287
},blockFadeOut:function(_5f){
288
var _60=_5f.node=dojo.byId(_5f.node);
289
_5f.rows=_5f.rows||5;
290
_5f.columns=_5f.columns||5;
291
_5f.duration=_5f.duration||1000;
292
_5f.interval=_5f.interval||_5f.duration/(_5f.rows+_5f.columns*2);
293
_5f.random=_5f.random||0;
294
var _61=Math.abs(_5f.random),_62=_5f.duration-(_5f.rows+_5f.columns)*_5f.interval;
295
_5f.pieceAnimation=function(_63,x,y,_64){
296
var _65=Math.random()*_5f.duration,_66=(_5f.reverseOrder)?(((_5f.rows+_5f.columns)-(x+y))*Math.abs(_5f.interval)):((x+y)*_5f.interval),_67=_65*_61+Math.max(1-_61,0)*_66,_68=dojo.animateProperty({node:_63,duration:_62,delay:_67,easing:(_5f.easing||dojo.fx.easing.sinInOut),properties:{opacity:(_5f.unhide?{start:"0",end:"1"}:{start:"1",end:"0"})},beforeBegin:(_5f.unhide?function(){
297
dojo.style(_63,{opacity:"0"});
298
}:function(){
299
_63.style.filter="";
300
})});
301
return _68;
302
};
303
var _69=dojox.fx._split(_5f);
304
if(_5f.unhide){
305
dojo.connect(_69,"onEnd",_69,function(){
306
dojo.style(_60,{opacity:"1"});
307
});
308
}else{
309
dojo.connect(_69,"onPlay",_69,function(){
310
dojo.style(_60,{opacity:"0"});
311
});
312
}
313
return _69;
314
},blockFadeIn:function(_6a){
315
_6a.unhide=true;
316
return dojox.fx.blockFadeOut(_6a);
317
}});
318
}