2 * Manage delayed and timed actions
4 * @license GPL2 (http://www.gnu.org/licenses/gpl.html)
5 * @author Adrian Lang <lang@cosmocode.de>
9 * Provide a global callback for window.setTimeout
11 * To get a timeout for non-global functions, just call
12 * delay.add(func, timeout).
18 execDispatch: function (id) {
19 timer._handlers[id]();
22 add: function (func, timeout) {
23 var id = ++timer._cur_id;
24 timer._handlers[id] = func;
25 return window.setTimeout('timer.execDispatch(' + id + ')', timeout);
30 * Provide a delayed start
32 * To call a function with a delay, just create a new Delay(func, timeout) and
33 * call that object’s method “start”.
35 function Delay (func, timeout) {
38 this.timeout = timeout;
46 delTimer: function () {
47 if (this.timer !== null) {
48 window.clearTimeout(this.timer);
54 DEPRECATED('don\'t use the Delay object, use window.timeout with a callback instead');
57 this.timer = timer.add(function () { _this.exec.call(_this); },
62 _params: Array.prototype.slice.call(arguments, 2)
68 this.func.call(this._data._this, this._data._params);