- Replaced color picker form control with a more robust version.
This commit is contained in:
parent
6fe068e42d
commit
6e0470771e
1193 changed files with 342 additions and 223 deletions
62
www/extras/extjs/source/util/DelayedTask.js
vendored
Normal file
62
www/extras/extjs/source/util/DelayedTask.js
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Ext JS Library 1.0.1
|
||||
* Copyright(c) 2006-2007, Ext JS, LLC.
|
||||
* licensing@extjs.com
|
||||
*
|
||||
* http://www.extjs.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Ext.util.DelayedTask
|
||||
* Provides a convenient method of performing setTimeout where a new
|
||||
* timeout cancels the old timeout. An example would be performing validation on a keypress.
|
||||
* You can use this class to buffer
|
||||
* the keypress events for a certain number of milliseconds, and perform only if they stop
|
||||
* for that amount of time.
|
||||
* @constructor The parameters to this constructor serve as defaults and are not required.
|
||||
* @param {Function} fn (optional) The default function to timeout
|
||||
* @param {Object} scope (optional) The default scope of that timeout
|
||||
* @param {Array} args (optional) The default Array of arguments
|
||||
*/
|
||||
Ext.util.DelayedTask = function(fn, scope, args){
|
||||
var id = null, d, t;
|
||||
|
||||
var call = function(){
|
||||
var now = new Date().getTime();
|
||||
if(now - t >= d){
|
||||
clearInterval(id);
|
||||
id = null;
|
||||
fn.apply(scope, args || []);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Cancels any pending timeout and queues a new one
|
||||
* @param {Number} delay The milliseconds to delay
|
||||
* @param {Function} newFn (optional) Overrides function passed to constructor
|
||||
* @param {Object} newScope (optional) Overrides scope passed to constructor
|
||||
* @param {Array} newArgs (optional) Overrides args passed to constructor
|
||||
*/
|
||||
this.delay = function(delay, newFn, newScope, newArgs){
|
||||
if(id && delay != d){
|
||||
this.cancel();
|
||||
}
|
||||
d = delay;
|
||||
t = new Date().getTime();
|
||||
fn = newFn || fn;
|
||||
scope = newScope || scope;
|
||||
args = newArgs || args;
|
||||
if(!id){
|
||||
id = setInterval(call, d);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel the last queued timeout
|
||||
*/
|
||||
this.cancel = function(){
|
||||
if(id){
|
||||
clearInterval(id);
|
||||
id = null;
|
||||
}
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue