Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / source / DelayedTask.html
index 792a3c9..53f1925 100644 (file)
@@ -1,63 +1,74 @@
+<!DOCTYPE html>
 <html>
 <head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+  <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
 </head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.util.DelayedTask"></div>/**
- * @class Ext.util.DelayedTask
- * <p> The DelayedTask class provides a convenient way to "buffer" the execution of a method,
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-util-DelayedTask-method-constructor'><span id='Ext-util-DelayedTask'>/**
+</span></span> * @class Ext.util.DelayedTask
+ * 
+ * The DelayedTask class provides a convenient way to &quot;buffer&quot; the execution of a method,
  * performing setTimeout where a new timeout cancels the old timeout. When called, the
  * task will wait the specified time period before executing. If durng that time period,
  * the task is called again, the original call will be cancelled. This continues so that
- * the function is only called a single time for each iteration.</p>
- * <p>This method is especially useful for things like detecting whether a user has finished
+ * the function is only called a single time for each iteration.
+ * 
+ * This method is especially useful for things like detecting whether a user has finished
  * typing in a text field. 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.  Usage:</p><pre><code>
-var task = new Ext.util.DelayedTask(function(){
-    alert(Ext.getDom('myInputField').value.length);
-});
-// Wait 500ms before calling our function. If the user presses another key 
-// during that 500ms, it will be cancelled and we'll wait another 500ms.
-Ext.get('myInputField').on('keypress', function(){
-    task.{@link #delay}(500); 
-});
- * </code></pre> 
- * <p>Note that we are using a DelayedTask here to illustrate a point. The configuration
- * option <tt>buffer</tt> for {@link Ext.util.Observable#addListener addListener/on} will
- * also setup a delayed task for you to buffer events.</p> 
+ * perform only if they stop for that amount of time.  
+ * 
+ * ## Usage
+ * 
+ *     var task = new Ext.util.DelayedTask(function(){
+ *         alert(Ext.getDom('myInputField').value.length);
+ *     });
+ *     
+ *     // Wait 500ms before calling our function. If the user presses another key
+ *     // during that 500ms, it will be cancelled and we'll wait another 500ms.
+ *     Ext.get('myInputField').on('keypress', function(){
+ *         task.{@link #delay}(500);
+ *     });
+ * 
+ * Note that we are using a DelayedTask here to illustrate a point. The configuration
+ * option `buffer` for {@link Ext.util.Observable#addListener addListener/on} will
+ * also setup a delayed task for you to buffer events.
+ * 
  * @constructor The parameters to this constructor serve as defaults and are not required.
  * @param {Function} fn (optional) The default function to call.
- * @param {Object} scope The default scope (The <code><b>this</b></code> reference) in which the
- * function is called. If not specified, <code>this</code> will refer to the browser window.
+ * @param {Object} scope (optional) The default scope (The &lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the
+ * function is called. If not specified, &lt;code&gt;this&lt;/code&gt; will refer to the browser window.
  * @param {Array} args (optional) The default Array of arguments.
  */
-Ext.util.DelayedTask = function(fn, scope, args){
+Ext.util.DelayedTask = function(fn, scope, args) {
     var me = this,
-       id,     
-       call = function(){
-               clearInterval(id);
-               id = null;
-               fn.apply(scope, args || []);
-           };
-           
-    <div id="method-Ext.util.DelayedTask-delay"></div>/**
-     * Cancels any pending timeout and queues a new one
+        id,
+        call = function() {
+            clearInterval(id);
+            id = null;
+            fn.apply(scope, args || []);
+        };
+
+<span id='Ext-util-DelayedTask-method-delay'>    /**
+</span>     * 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. Remember that if no scope
-     * is specified, <code>this</code> will refer to the browser window.
+     * is specified, &lt;code&gt;this&lt;/code&gt; will refer to the browser window.
      * @param {Array} newArgs (optional) Overrides args passed to constructor
      */
-    me.delay = function(delay, newFn, newScope, newArgs){
+    this.delay = function(delay, newFn, newScope, newArgs) {
         me.cancel();
         fn = newFn || fn;
         scope = newScope || scope;
@@ -65,15 +76,15 @@ Ext.util.DelayedTask = function(fn, scope, args){
         id = setInterval(call, delay);
     };
 
-    <div id="method-Ext.util.DelayedTask-cancel"></div>/**
-     * Cancel the last queued timeout
+<span id='Ext-util-DelayedTask-method-cancel'>    /**
+</span>     * Cancel the last queued timeout
      */
-    me.cancel = function(){
-        if(id){
+    this.cancel = function(){
+        if (id) {
             clearInterval(id);
             id = null;
         }
     };
 };</pre>
 </body>
-</html>
\ No newline at end of file
+</html>