Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.widget.Loader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.widget.Loader"] = true;
3
dojo.provide("dojox.widget.Loader");
4
dojo.experimental("dojox.widget.Loader");
5
 
6
dojo.require("dijit._Widget");
7
dojo.require("dijit._Templated");
8
 
9
dojo.declare("dojox.widget.Loader", [dijit._Widget,dijit._Templated], {
10
	// summary: a configurable global xhr-listener to display
11
	// a loading message during running xhr's or to simply provide
12
	// base-level topic to subscribe to for custom loading messages
13
 
14
	// loadIcon: String
15
	// 	location to the icon used.
16
	loadIcon: dojo.moduleUrl("dojox.widget.Loader","icons/loading.gif"),
17
 
18
	// loadMessage: String
19
	//	string to use for progress loading
20
	loadMessage: 'Loading ...',
21
 
22
	// hasVisuals: Boolean
23
	// 	true to display a fixed loading message in TR cornder, false to unly provide
24
	//	"Loader" topic to subscribe to for your own custom loading message.
25
	hasVisuals: true,
26
 
27
	// attachToPointer
28
	// 	true to use visual indicator where cursor is
29
	attachToPointer: true,
30
 
31
	// duration: Integer
32
	//	time in ms to toggle in/out the visual load indicator
33
	duration: 125,
34
 
35
	// _offset: Integer
36
	//	distance in px from the mouse pointer to show attachToPointer avatar
37
	_offset: 16,
38
 
39
	// holder for mousemove connection
40
	_pointerConnect: null,
41
	_xhrStart: null,
42
	_xhrEnd: null,
43
 
44
	templateString: '<div dojoAttachPoint="loadNode" class="dojoxLoader">'
45
		+'<img src="${loadIcon}" class="dojoxLoaderIcon"> <span dojoAttachPoint="loadMessageNode" class="dojoxLoaderMessage"></span>'
46
		+'</div>',
47
 
48
	postCreate: function(){
49
		// summary: setup the loader
50
 
51
		if(!this.hasVisuals){
52
			this.loadNode.style.display = "none"; // _destroy()?
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
		// FIXME: create our connections.  would be easier, and this might be redundant
63
		// if Deferred published something
64
		this._xhrStart = dojo.connect(dojo,"_ioSetArgs",this,"_show");
65
		this._xhrEnd = dojo.connect(dojo.Deferred.prototype,"_fire",this,"_hide");
66
 
67
	},
68
 
69
	_setMessage: function(/* String */ message){
70
		// summary: set's the message in the loader
71
		this.loadMessageNode.innerHTML = message;
72
	},
73
 
74
	_putLoader: function(/* Event */ e){
75
		// summary: place the floating loading element based on mousemove connection position
76
		dijit.placeOnScreen(this.loadNode,{ x: e.clientX+this._offset, y:e.clientY+this._offset }, ["TL","BR"]);
77
	},
78
 
79
	_show: function(){
80
		// summary: publish and show progress indicator
81
		dojo.publish("Loader",[{ message: 'started' }]);
82
		if(this.hasVisuals){
83
			if(this.attachToPointer){
84
				this._pointerConnect = dojo.connect(document,"onmousemove",this,"_putLoader");
85
			}
86
			dojo.fadeIn({ node: this.loadNode, duration:this.duration }).play();
87
		}
88
	},
89
 
90
	_hide: function(){
91
		// summary: publish "xhr ended" and hide progress indicator
92
		dojo.publish("Loader",[{ message: 'ended' }]);
93
		if(this.hasVisuals){
94
			if(this.attachPointer){
95
				dojo.disconnect(this._pointerConnect);
96
			}
97
			dojo.fadeOut({ node: this.loadNode, duration:this.duration }).play();
98
		}
99
	}
100
 
101
});
102
 
103
}