From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/widget/Loader.js | 103 +++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 includes/js/dojox/widget/Loader.js (limited to 'includes/js/dojox/widget/Loader.js') diff --git a/includes/js/dojox/widget/Loader.js b/includes/js/dojox/widget/Loader.js new file mode 100644 index 0000000..2493d5a --- /dev/null +++ b/includes/js/dojox/widget/Loader.js @@ -0,0 +1,103 @@ +if(!dojo._hasResource["dojox.widget.Loader"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.widget.Loader"] = true; +dojo.provide("dojox.widget.Loader"); +dojo.experimental("dojox.widget.Loader"); + +dojo.require("dijit._Widget"); +dojo.require("dijit._Templated"); + +dojo.declare("dojox.widget.Loader", [dijit._Widget,dijit._Templated], { + // summary: a configurable global xhr-listener to display + // a loading message during running xhr's or to simply provide + // base-level topic to subscribe to for custom loading messages + + // loadIcon: String + // location to the icon used. + loadIcon: dojo.moduleUrl("dojox.widget.Loader","icons/loading.gif"), + + // loadMessage: String + // string to use for progress loading + loadMessage: 'Loading ...', + + // hasVisuals: Boolean + // true to display a fixed loading message in TR cornder, false to unly provide + // "Loader" topic to subscribe to for your own custom loading message. + hasVisuals: true, + + // attachToPointer + // true to use visual indicator where cursor is + attachToPointer: true, + + // duration: Integer + // time in ms to toggle in/out the visual load indicator + duration: 125, + + // _offset: Integer + // distance in px from the mouse pointer to show attachToPointer avatar + _offset: 16, + + // holder for mousemove connection + _pointerConnect: null, + _xhrStart: null, + _xhrEnd: null, + + templateString: '
' + +' ' + +'
', + + postCreate: function(){ + // summary: setup the loader + + if(!this.hasVisuals){ + this.loadNode.style.display = "none"; // _destroy()? + }else{ + if(this.attachToPointer){ + dojo.removeClass(this.loadNode,"dojoxLoader"); + dojo.addClass(this.loadNode,"dojoxLoaderPointer"); + } + this._hide(); + } + this._setMessage(this.loadMessage); + + // FIXME: create our connections. would be easier, and this might be redundant + // if Deferred published something + this._xhrStart = dojo.connect(dojo,"_ioSetArgs",this,"_show"); + this._xhrEnd = dojo.connect(dojo.Deferred.prototype,"_fire",this,"_hide"); + + }, + + _setMessage: function(/* String */ message){ + // summary: set's the message in the loader + this.loadMessageNode.innerHTML = message; + }, + + _putLoader: function(/* Event */ e){ + // summary: place the floating loading element based on mousemove connection position + dijit.placeOnScreen(this.loadNode,{ x: e.clientX+this._offset, y:e.clientY+this._offset }, ["TL","BR"]); + }, + + _show: function(){ + // summary: publish and show progress indicator + dojo.publish("Loader",[{ message: 'started' }]); + if(this.hasVisuals){ + if(this.attachToPointer){ + this._pointerConnect = dojo.connect(document,"onmousemove",this,"_putLoader"); + } + dojo.fadeIn({ node: this.loadNode, duration:this.duration }).play(); + } + }, + + _hide: function(){ + // summary: publish "xhr ended" and hide progress indicator + dojo.publish("Loader",[{ message: 'ended' }]); + if(this.hasVisuals){ + if(this.attachToPointer){ + dojo.disconnect(this._pointerConnect); + } + dojo.fadeOut({ node: this.loadNode, duration:this.duration }).play(); + } + } + +}); + +} -- cgit v1.2.3