| 1 |
dojo.provide("dojox.widget.Loader"); |
| 2 |
dojo.deprecated("dojox.widget.Loader", "", "2.0"); |
| 3 |
|
| 4 |
dojo.require("dijit._Widget"); |
| 5 |
dojo.require("dijit._Templated"); |
| 6 |
|
| 7 |
dojo.declare("dojox.widget.Loader", [dijit._Widget,dijit._Templated], { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
loadIcon: dojo.moduleUrl("dojox.widget.Loader","icons/loading.gif"), |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
loadMessage: 'Loading ...', |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
hasVisuals: true, |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
attachToPointer: true, |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
duration: 125, |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
_offset: 16, |
| 37 |
|
| 38 |
|
| 39 |
_pointerConnect: null, |
| 40 |
_xhrStart: null, |
| 41 |
_xhrEnd: null, |
| 42 |
|
| 43 |
templateString: '<div dojoAttachPoint="loadNode" class="dojoxLoader">' |
| 44 |
+'<img src="${loadIcon}" class="dojoxLoaderIcon"> <span dojoAttachPoint="loadMessageNode" class="dojoxLoaderMessage"></span>' |
| 45 |
+'</div>', |
| 46 |
|
| 47 |
postCreate: function(){ |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
if(!this.hasVisuals){ |
| 52 |
this.loadNode.style.display = "none"; |
| 53 |
}else{ |
| 54 |
if(this.attachToPointer){ |
| 55 |
dojo.removeClass(this.loadNode,"dojoxLoader"); |
| 56 |
dojo.addClass(this.loadNode,"dojoxLoaderPointer"); |
| 57 |
} |
| 58 |
this._hide(); |
| 59 |
} |
| 60 |
this._setMessage(this.loadMessage); |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
this._xhrStart = this.connect(dojo,"_ioSetArgs","_show"); |
| 65 |
this._xhrEnd = this.connect(dojo.Deferred.prototype,"_fire","_hide"); |
| 66 |
|
| 67 |
}, |
| 68 |
|
| 69 |
_setMessage: function( message){ |
| 70 |
|
| 71 |
|
| 72 |
this.loadMessageNode.innerHTML = message; |
| 73 |
}, |
| 74 |
|
| 75 |
_putLoader: function( e){ |
| 76 |
|
| 77 |
|
| 78 |
dijit.placeOnScreen(this.loadNode,{ x: e.clientX+this._offset, y:e.clientY+this._offset }, ["TL","BR"]); |
| 79 |
}, |
| 80 |
|
| 81 |
_show: function(){ |
| 82 |
|
| 83 |
|
| 84 |
dojo.publish("Loader",[{ message: 'started' }]); |
| 85 |
if(this.hasVisuals){ |
| 86 |
if(this.attachToPointer){ |
| 87 |
this._pointerConnect = this.connect(document,"onmousemove","_putLoader"); |
| 88 |
} |
| 89 |
dojo.style(this.loadNode, { |
| 90 |
opacity:0, display:"" |
| 91 |
}); |
| 92 |
dojo.fadeIn({ node: this.loadNode, duration:this.duration }).play(); |
| 93 |
} |
| 94 |
}, |
| 95 |
|
| 96 |
_hide: function(){ |
| 97 |
|
| 98 |
|
| 99 |
dojo.publish("Loader",[{ message: 'ended' }]); |
| 100 |
if(this.hasVisuals){ |
| 101 |
if(this.attachToPointer){ |
| 102 |
this.disconnect(this._pointerConnect); |
| 103 |
} |
| 104 |
dojo.fadeOut({ |
| 105 |
node: this.loadNode, |
| 106 |
duration:this.duration, |
| 107 |
onEnd: dojo.partial(dojo.style, this.loadNode, "display", "none") |
| 108 |
}).play(); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
}); |