root / trunk / web / dojo / dojox / widget / Loader.js
History | View | Annotate | Download (2.05 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.Loader"]){ |
9 |
dojo._hasResource["dojox.widget.Loader"]=true; |
10 |
dojo.provide("dojox.widget.Loader");
|
11 |
dojo.deprecated("dojox.widget.Loader","","2.0"); |
12 |
dojo.require("dijit._Widget");
|
13 |
dojo.require("dijit._Templated");
|
14 |
dojo.declare("dojox.widget.Loader",[dijit._Widget,dijit._Templated],{loadIcon:dojo.moduleUrl("dojox.widget.Loader","icons/loading.gif"),loadMessage:"Loading ...",hasVisuals:true,attachToPointer:true,duration:125,_offset:16,_pointerConnect:null,_xhrStart:null,_xhrEnd:null,templateString:"<div dojoAttachPoint=\"loadNode\" class=\"dojoxLoader\">"+"<img src=\"${loadIcon}\" class=\"dojoxLoaderIcon\"> <span dojoAttachPoint=\"loadMessageNode\" class=\"dojoxLoaderMessage\"></span>"+"</div>",postCreate:function(){ |
15 |
if(!this.hasVisuals){ |
16 |
this.loadNode.style.display="none"; |
17 |
}else{
|
18 |
if(this.attachToPointer){ |
19 |
dojo.removeClass(this.loadNode,"dojoxLoader"); |
20 |
dojo.addClass(this.loadNode,"dojoxLoaderPointer"); |
21 |
} |
22 |
this._hide();
|
23 |
} |
24 |
this._setMessage(this.loadMessage); |
25 |
this._xhrStart=this.connect(dojo,"_ioSetArgs","_show"); |
26 |
this._xhrEnd=this.connect(dojo.Deferred.prototype,"_fire","_hide"); |
27 |
},_setMessage:function(_1){ |
28 |
this.loadMessageNode.innerHTML=_1;
|
29 |
},_putLoader:function(e){ |
30 |
dijit.placeOnScreen(this.loadNode,{x:e.clientX+this._offset,y:e.clientY+this._offset},["TL","BR"]); |
31 |
},_show:function(){ |
32 |
dojo.publish("Loader",[{message:"started"}]); |
33 |
if(this.hasVisuals){ |
34 |
if(this.attachToPointer){ |
35 |
this._pointerConnect=this.connect(document,"onmousemove","_putLoader"); |
36 |
} |
37 |
dojo.style(this.loadNode,{opacity:0,display:""}); |
38 |
dojo.fadeIn({node:this.loadNode,duration:this.duration}).play(); |
39 |
} |
40 |
},_hide:function(){ |
41 |
dojo.publish("Loader",[{message:"ended"}]); |
42 |
if(this.hasVisuals){ |
43 |
if(this.attachToPointer){ |
44 |
this.disconnect(this._pointerConnect); |
45 |
} |
46 |
dojo.fadeOut({node:this.loadNode,duration:this.duration,onEnd:dojo.partial(dojo.style,this.loadNode,"display","none")}).play(); |
47 |
} |
48 |
}}); |
49 |
} |