rendered paste body/* protoload 0.1 beta by Andreas Kalsch * last change: 09.07.2007 * * This simple piece of code automates the creating of Ajax loading symbols. * The loading symbol covers an HTML element with correct position and size - example: * $('myElement').startWaiting() and $('myElement').stopWaiting() */ function LoadVisual (){ this._timeUntilShow = 250; this._opacity = 0.8; this._waiting = true; this._loading = true; this._loadingelement = null; this._element = null; this._className = null; this.initilize = function() { } // Start waiting status - show loading element // element on which to display the loading progress // className picture to display // timeUntilShow default value is 250 this.startWaiting = function(element, className, timeUntilShow) { if (typeof(element) == 'string') this._element = $(element); else alert('loading error el'); if (typeof className == 'string') this._className = 'waiting'; else alert('loading error cl'); if (typeof timeUntilShow == 'number') this._timeUntilShow = timeUntilShow; else alert('loading error ti'); if (this._loading) { var e = document.createElement('div'); e.setAttribute('id','loadDiv'); e.innerHTML = '<img src="'+ this._className +'">'; this._loadingelement = e; this._element.appendChild(this._loadingelement); e.style.position = 'absolute'; try {e.style.opacity = this.opacity;} catch(e) {} try {e.style.MozOpacity = this.opacity;} catch(e) {} try {e.style.filter = 'alpha(opacity='+Math.round(this.opacity * 100)+')';} catch(e) {} try {e.style.KhtmlOpacity = this.opacity;} catch(e) {} this._loading = false; } window.setTimeout(function () { if (!this._loading) { var ele = this._element, l = this._loadingelement; alert(this._loadingelement); this._loadingelement.style.left = this._element.offsetLeft+'px'; l.style.top = ele.offsetTop+'px'; l.style.width = ele.offsetWidth+'px'; l.style.height = ele.offsetHeight+'px'; l.style.display = 'inline'; } }, this._timeUntilShow); }, // Stop waiting status - hide loading element this.stopWaiting = function() { if (this._waiting) { this._element.removeChild(this._loadingelement); this._waiting = false; this._loading = true; } }}