root / trunk / web / dojo / dojox / widget / Standby.js @ 11
History | View | Annotate | Download (9.83 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.widget.Standby"]){ |
9 |
dojo._hasResource["dojox.widget.Standby"]=true; |
10 |
dojo.provide("dojox.widget.Standby");
|
11 |
dojo.require("dojo.window");
|
12 |
dojo.require("dojo.fx");
|
13 |
dojo.require("dijit._Widget");
|
14 |
dojo.require("dijit._Templated");
|
15 |
dojo.experimental("dojox.widget.Standby");
|
16 |
dojo.declare("dojox.widget.Standby",[dijit._Widget,dijit._Templated],{templateString:"<div>"+"<div style=\"display: none; opacity: 0; z-index: 9999; "+"position: absolute; cursor:wait;\" dojoAttachPoint=\"_underlayNode\"></div>"+"<img src=\"${image}\" style=\"opacity: 0; display: none; z-index: -10000; "+"position: absolute; top: 0px; left: 0px; cursor:wait;\" "+"dojoAttachPoint=\"_imageNode\">"+"<div style=\"opacity: 0; display: none; z-index: -10000; position: absolute; "+"top: 0px;\" dojoAttachPoint=\"_textNode\"></div>"+"</div>",_underlayNode:null,_imageNode:null,_textNode:null,_centerNode:null,image:dojo.moduleUrl("dojox","widget/Standby/images/loading.gif").toString(),imageText:"Please Wait...",text:"Please wait...",centerIndicator:"image",_displayed:false,_resizeCheck:null,target:"",color:"#C0C0C0",duration:500,_started:false,_parent:null,zIndex:"auto",startup:function(_1){ |
17 |
if(!this._started){ |
18 |
if(typeof this.target==="string"){ |
19 |
var w=dijit.byId(this.target); |
20 |
if(w){
|
21 |
this.target=w.domNode;
|
22 |
}else{
|
23 |
this.target=dojo.byId(this.target); |
24 |
} |
25 |
} |
26 |
if(this.text){ |
27 |
this._textNode.innerHTML=this.text; |
28 |
} |
29 |
if(this.centerIndicator==="image"){ |
30 |
this._centerNode=this._imageNode; |
31 |
dojo.attr(this._imageNode,"src",this.image); |
32 |
dojo.attr(this._imageNode,"alt",this.imageText); |
33 |
}else{
|
34 |
this._centerNode=this._textNode; |
35 |
} |
36 |
dojo.style(this._underlayNode,{display:"none",backgroundColor:this.color}); |
37 |
dojo.style(this._centerNode,"display","none"); |
38 |
this.connect(this._underlayNode,"onclick","_ignore"); |
39 |
if(this.domNode.parentNode&&this.domNode.parentNode!=dojo.body()){ |
40 |
dojo.body().appendChild(this.domNode);
|
41 |
} |
42 |
if(dojo.isIE==7){ |
43 |
this._ieFixNode=dojo.doc.createElement("div"); |
44 |
dojo.style(this._ieFixNode,{opacity:"0",zIndex:"-1000",position:"absolute",top:"-1000px"}); |
45 |
dojo.body().appendChild(this._ieFixNode);
|
46 |
} |
47 |
} |
48 |
},show:function(){ |
49 |
if(!this._displayed){ |
50 |
this._displayed=true; |
51 |
this._size();
|
52 |
this._disableOverflow();
|
53 |
this._fadeIn();
|
54 |
} |
55 |
},hide:function(){ |
56 |
if(this._displayed){ |
57 |
this._size();
|
58 |
this._fadeOut();
|
59 |
this._displayed=false; |
60 |
if(this._resizeCheck!==null){ |
61 |
clearInterval(this._resizeCheck);
|
62 |
this._resizeCheck=null; |
63 |
} |
64 |
} |
65 |
},isVisible:function(){ |
66 |
return this._displayed; |
67 |
},onShow:function(){ |
68 |
},onHide:function(){ |
69 |
},uninitialize:function(){ |
70 |
this._displayed=false; |
71 |
if(this._resizeCheck){ |
72 |
clearInterval(this._resizeCheck);
|
73 |
} |
74 |
dojo.style(this._centerNode,"display","none"); |
75 |
dojo.style(this._underlayNode,"display","none"); |
76 |
if(dojo.isIE==7){ |
77 |
dojo.body().removeChild(this._ieFixNode);
|
78 |
delete this._ieFixNode; |
79 |
} |
80 |
this.target=null; |
81 |
this._imageNode=null; |
82 |
this._textNode=null; |
83 |
this._centerNode=null; |
84 |
this.inherited(arguments); |
85 |
},_size:function(){ |
86 |
if(this._displayed){ |
87 |
var _2=dojo.attr(dojo.body(),"dir"); |
88 |
if(_2){
|
89 |
_2=_2.toLowerCase(); |
90 |
} |
91 |
var _3;
|
92 |
var _4=this._scrollerWidths(); |
93 |
var _5=this.target; |
94 |
var _6=dojo.style(this._centerNode,"display"); |
95 |
dojo.style(this._centerNode,"display","block"); |
96 |
var _7=dojo.position(_5,true); |
97 |
if(_5===dojo.body()||_5===dojo.doc){
|
98 |
_7=dojo.window.getBox(); |
99 |
_7.x=_7.l; |
100 |
_7.y=_7.t; |
101 |
} |
102 |
var _8=dojo.marginBox(this._centerNode); |
103 |
dojo.style(this._centerNode,"display",_6); |
104 |
if(this._ieFixNode){ |
105 |
_3=-this._ieFixNode.offsetTop/1000; |
106 |
_7.x=Math.floor((_7.x+0.9)/_3);
|
107 |
_7.y=Math.floor((_7.y+0.9)/_3);
|
108 |
_7.w=Math.floor((_7.w+0.9)/_3);
|
109 |
_7.h=Math.floor((_7.h+0.9)/_3);
|
110 |
} |
111 |
var zi=dojo.style(_5,"zIndex"); |
112 |
var _9=zi;
|
113 |
var _a=zi;
|
114 |
if(this.zIndex==="auto"){ |
115 |
if(zi!="auto"){ |
116 |
_9=parseInt(_9,10)+1; |
117 |
_a=parseInt(_a,10)+2; |
118 |
}else{
|
119 |
var _b=_5.parentNode;
|
120 |
var _c=-100000; |
121 |
while(_b&&_b!==dojo.body()){
|
122 |
zi=dojo.style(_b,"zIndex");
|
123 |
if(!zi||zi==="auto"){ |
124 |
_b=_b.parentNode; |
125 |
}else{
|
126 |
var _d=parseInt(zi,10); |
127 |
if(_c<_d){
|
128 |
_c=_d; |
129 |
_9=_d+1;
|
130 |
_a=_d+2;
|
131 |
} |
132 |
_b=_b.parentNode; |
133 |
} |
134 |
} |
135 |
} |
136 |
}else{
|
137 |
_9=parseInt(this.zIndex,10)+1; |
138 |
_a=parseInt(this.zIndex,10)+2; |
139 |
} |
140 |
dojo.style(this._centerNode,"zIndex",_a); |
141 |
dojo.style(this._underlayNode,"zIndex",_9); |
142 |
var pn=_5.parentNode;
|
143 |
if(pn&&pn!==dojo.body()&&_5!==dojo.body()&&_5!==dojo.doc){
|
144 |
var _e=_7.h;
|
145 |
var _f=_7.w;
|
146 |
var _10=dojo.position(pn,true); |
147 |
if(this._ieFixNode){ |
148 |
_3=-this._ieFixNode.offsetTop/1000; |
149 |
_10.x=Math.floor((_10.x+0.9)/_3);
|
150 |
_10.y=Math.floor((_10.y+0.9)/_3);
|
151 |
_10.w=Math.floor((_10.w+0.9)/_3);
|
152 |
_10.h=Math.floor((_10.h+0.9)/_3);
|
153 |
} |
154 |
_10.w-=pn.scrollHeight>pn.clientHeight&&pn.clientHeight>0?_4.v:0; |
155 |
_10.h-=pn.scrollWidth>pn.clientWidth&&pn.clientWidth>0?_4.h:0; |
156 |
if(_2==="rtl"){ |
157 |
if(dojo.isOpera){
|
158 |
_7.x+=pn.scrollHeight>pn.clientHeight&&pn.clientHeight>0?_4.v:0; |
159 |
_10.x+=pn.scrollHeight>pn.clientHeight&&pn.clientHeight>0?_4.v:0; |
160 |
}else{
|
161 |
if(dojo.isIE){
|
162 |
_10.x+=pn.scrollHeight>pn.clientHeight&&pn.clientHeight>0?_4.v:0; |
163 |
}else{
|
164 |
if(dojo.isWebKit){
|
165 |
} |
166 |
} |
167 |
} |
168 |
} |
169 |
if(_10.w<_7.w){
|
170 |
_7.w=_7.w-_10.w; |
171 |
} |
172 |
if(_10.h<_7.h){
|
173 |
_7.h=_7.h-_10.h; |
174 |
} |
175 |
var _11=_10.y;
|
176 |
var _12=_10.y+_10.h;
|
177 |
var _13=_7.y;
|
178 |
var _14=_7.y+_e;
|
179 |
var _15=_10.x;
|
180 |
var _16=_10.x+_10.w;
|
181 |
var _17=_7.x;
|
182 |
var _18=_7.x+_f;
|
183 |
var _19;
|
184 |
if(_14>_11&&_13<_11){
|
185 |
_7.y=_10.y; |
186 |
_19=_11-_13; |
187 |
var _1a=_e-_19;
|
188 |
if(_1a<_10.h){
|
189 |
_7.h=_1a; |
190 |
}else{
|
191 |
_7.h-=2*(pn.scrollWidth>pn.clientWidth&&pn.clientWidth>0?_4.h:0); |
192 |
} |
193 |
}else{
|
194 |
if(_13<_12&&_14>_12){
|
195 |
_7.h=_12-_13; |
196 |
}else{
|
197 |
if(_14<=_11||_13>=_12){
|
198 |
_7.h=0;
|
199 |
} |
200 |
} |
201 |
} |
202 |
if(_18>_15&&_17<_15){
|
203 |
_7.x=_10.x; |
204 |
_19=_15-_17; |
205 |
var _1b=_f-_19;
|
206 |
if(_1b<_10.w){
|
207 |
_7.w=_1b; |
208 |
}else{
|
209 |
_7.w-=2*(pn.scrollHeight>pn.clientHeight&&pn.clientHeight>0?_4.w:0); |
210 |
} |
211 |
}else{
|
212 |
if(_17<_16&&_18>_16){
|
213 |
_7.w=_16-_17; |
214 |
}else{
|
215 |
if(_18<=_15||_17>=_16){
|
216 |
_7.w=0;
|
217 |
} |
218 |
} |
219 |
} |
220 |
} |
221 |
if(_7.h>0&&_7.w>0){ |
222 |
dojo.style(this._underlayNode,{display:"block",width:_7.w+"px",height:_7.h+"px",top:_7.y+"px",left:_7.x+"px"}); |
223 |
var _1c=["borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]; |
224 |
this._cloneStyles(_1c);
|
225 |
if(!dojo.isIE){
|
226 |
_1c=["MozBorderRadius","MozBorderRadiusTopleft","MozBorderRadiusTopright","MozBorderRadiusBottomleft","MozBorderRadiusBottomright","WebkitBorderRadius","WebkitBorderTopLeftRadius","WebkitBorderTopRightRadius","WebkitBorderBottomLeftRadius","WebkitBorderBottomRightRadius"]; |
227 |
this._cloneStyles(_1c,this); |
228 |
} |
229 |
var _1d=(_7.h/2)-(_8.h/2); |
230 |
var _1e=(_7.w/2)-(_8.w/2); |
231 |
if(_7.h>=_8.h&&_7.w>=_8.w){
|
232 |
dojo.style(this._centerNode,{top:(_1d+_7.y)+"px",left:(_1e+_7.x)+"px",display:"block"}); |
233 |
}else{
|
234 |
dojo.style(this._centerNode,"display","none"); |
235 |
} |
236 |
}else{
|
237 |
dojo.style(this._underlayNode,"display","none"); |
238 |
dojo.style(this._centerNode,"display","none"); |
239 |
} |
240 |
if(this._resizeCheck===null){ |
241 |
var _1f=this; |
242 |
this._resizeCheck=setInterval(function(){ |
243 |
_1f._size(); |
244 |
},100);
|
245 |
} |
246 |
} |
247 |
},_cloneStyles:function(_20){ |
248 |
dojo.forEach(_20,function(_21){
|
249 |
dojo.style(this._underlayNode,_21,dojo.style(this.target,_21)); |
250 |
},this);
|
251 |
},_fadeIn:function(){ |
252 |
var _22=this; |
253 |
var _23=dojo.animateProperty({duration:_22.duration,node:_22._underlayNode,properties:{opacity:{start:0,end:0.75}}}); |
254 |
var _24=dojo.animateProperty({duration:_22.duration,node:_22._centerNode,properties:{opacity:{start:0,end:1}},onEnd:function(){ |
255 |
_22.onShow(); |
256 |
}}); |
257 |
var _25=dojo.fx.combine([_23,_24]);
|
258 |
_25.play(); |
259 |
},_fadeOut:function(){ |
260 |
var _26=this; |
261 |
var _27=dojo.animateProperty({duration:_26.duration,node:_26._underlayNode,properties:{opacity:{start:0.75,end:0}},onEnd:function(){ |
262 |
dojo.style(this.node,{"display":"none","zIndex":"-1000"}); |
263 |
}}); |
264 |
var _28=dojo.animateProperty({duration:_26.duration,node:_26._centerNode,properties:{opacity:{start:1,end:0}},onEnd:function(){ |
265 |
dojo.style(this.node,{"display":"none","zIndex":"-1000"}); |
266 |
_26.onHide(); |
267 |
_26._enableOverflow(); |
268 |
}}); |
269 |
var _29=dojo.fx.combine([_27,_28]);
|
270 |
_29.play(); |
271 |
},_ignore:function(_2a){ |
272 |
if(_2a){
|
273 |
dojo.stopEvent(_2a); |
274 |
} |
275 |
},_scrollerWidths:function(){ |
276 |
var div=dojo.doc.createElement("div"); |
277 |
dojo.style(div,{position:"absolute",opacity:0,overflow:"hidden",width:"50px",height:"50px",zIndex:"-100",top:"-200px",left:"-200px",padding:"0px",margin:"0px"}); |
278 |
var _2b=dojo.doc.createElement("div"); |
279 |
dojo.style(_2b,{width:"200px",height:"10px"}); |
280 |
div.appendChild(_2b); |
281 |
dojo.body().appendChild(div); |
282 |
var b=dojo.contentBox(div);
|
283 |
dojo.style(div,"overflow","scroll"); |
284 |
var a=dojo.contentBox(div);
|
285 |
dojo.body().removeChild(div); |
286 |
return {v:b.w-a.w,h:b.h-a.h}; |
287 |
},_setTextAttr:function(_2c){ |
288 |
this._textNode.innerHTML=_2c;
|
289 |
this.text=_2c;
|
290 |
},_setColorAttr:function(c){ |
291 |
dojo.style(this._underlayNode,"backgroundColor",c); |
292 |
this.color=c;
|
293 |
},_setImageTextAttr:function(_2d){ |
294 |
dojo.attr(this._imageNode,"alt",_2d); |
295 |
this.imageText=_2d;
|
296 |
},_setImageAttr:function(url){ |
297 |
dojo.attr(this._imageNode,"src",url); |
298 |
this.image=url;
|
299 |
},_setCenterIndicatorAttr:function(_2e){ |
300 |
this.centerIndicator=_2e;
|
301 |
if(_2e==="image"){ |
302 |
this._centerNode=this._imageNode; |
303 |
dojo.style(this._textNode,"display","none"); |
304 |
}else{
|
305 |
this._centerNode=this._textNode; |
306 |
dojo.style(this._imageNode,"display","none"); |
307 |
} |
308 |
},_disableOverflow:function(){ |
309 |
if(this.target===dojo.body()||this.target===dojo.doc){ |
310 |
this._overflowDisabled=true; |
311 |
var _2f=dojo.body();
|
312 |
if(_2f.style&&_2f.style.overflow){
|
313 |
this._oldOverflow=dojo.style(_2f,"overflow"); |
314 |
}else{
|
315 |
this._oldOverflow=""; |
316 |
} |
317 |
if(dojo.isIE&&!dojo.isQuirks){
|
318 |
if(_2f.parentNode&&_2f.parentNode.style&&_2f.parentNode.style.overflow){
|
319 |
this._oldBodyParentOverflow=_2f.parentNode.style.overflow;
|
320 |
}else{
|
321 |
try{
|
322 |
this._oldBodyParentOverflow=dojo.style(_2f.parentNode,"overflow"); |
323 |
} |
324 |
catch(e){
|
325 |
this._oldBodyParentOverflow="scroll"; |
326 |
} |
327 |
} |
328 |
dojo.style(_2f.parentNode,"overflow","hidden"); |
329 |
} |
330 |
dojo.style(_2f,"overflow","hidden"); |
331 |
} |
332 |
},_enableOverflow:function(){ |
333 |
if(this._overflowDisabled){ |
334 |
delete this._overflowDisabled; |
335 |
var _30=dojo.body();
|
336 |
if(dojo.isIE&&!dojo.isQuirks){
|
337 |
_30.parentNode.style.overflow=this._oldBodyParentOverflow;
|
338 |
delete this._oldBodyParentOverflow; |
339 |
} |
340 |
dojo.style(_30,"overflow",this._oldOverflow); |
341 |
if(dojo.isWebKit){
|
342 |
var div=dojo.create("div",{style:{height:"2px"}}); |
343 |
_30.appendChild(div); |
344 |
setTimeout(function(){
|
345 |
_30.removeChild(div); |
346 |
},0);
|
347 |
} |
348 |
delete this._oldOverflow; |
349 |
} |
350 |
}}); |
351 |
} |