-
Notifications
You must be signed in to change notification settings - Fork 34
/
jquery-ba-dotimeout-js.html
54 lines (26 loc) · 15.5 KB
/
jquery-ba-dotimeout-js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>jQuery doTimeout: Like setTimeout, but better!</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.4 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="jQuery_doTimeout:Like_setTimeout,but_better!"></a>jQuery doTimeout: Like setTimeout, but better!</h1><div class=CBody><p><b>Version: 1.0, Last updated: 3/3/2010</b></p><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>Project Home</td><td class=CDLDescription><a href="http://benalman.com/projects/jquery-dotimeout-plugin/" class=LURL target=_top>http://benalman.com<wbr>/projects<wbr>/jquery-dotimeout-plugin<wbr>/</a></td></tr><tr><td class=CDLEntry>GitHub</td><td class=CDLDescription><a href="http://github.com/cowboy/jquery-dotimeout/" class=LURL target=_top>http://github.com/cowboy/jquery-dotimeout/</a></td></tr><tr><td class=CDLEntry>Source</td><td class=CDLDescription><a href="http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.js" class=LURL target=_top>http://github.com<wbr>/cowboy<wbr>/jquery-dotimeout<wbr>/raw<wbr>/master<wbr>/jquery.ba-dotimeout.js</a></td></tr><tr><td class=CDLEntry>(Minified)</td><td class=CDLDescription><a href="http://github.com/cowboy/jquery-dotimeout/raw/master/jquery.ba-dotimeout.min.js" class=LURL target=_top>http://github.com<wbr>/cowboy<wbr>/jquery-dotimeout<wbr>/raw<wbr>/master<wbr>/jquery.ba-dotimeout.min.js</a> (0.9kb)</td></tr></table><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#jQuery_doTimeout:Like_setTimeout,but_better!" >jQuery doTimeout: Like setTimeout, but better!</a></td><td class=SDescription><b>Version: 1.0, Last updated: 3/3/2010</b></td></tr><tr class="SGeneric SMarked"><td class=SEntry><a href="#License" >License</a></td><td class=SDescription>Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. </td></tr><tr class="SGeneric"><td class=SEntry><a href="#Examples" >Examples</a></td><td class=SDescription>These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.</td></tr><tr class="SGeneric SMarked"><td class=SEntry><a href="#Support_and_Testing" >Support and Testing</a></td><td class=SDescription>Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).</td></tr><tr class="SGeneric"><td class=SEntry><a href="#Release_History" >Release History</a></td><td class=SDescription></td></tr><tr class="SGroup"><td class=SEntry><a href="#Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#jQuery.doTimeout" >jQuery.<wbr>doTimeout</a></td><td class=SDescription>Initialize, cancel, or force execution of a callback after a delay.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#jQuery.fn.doTimeout" >jQuery.<wbr>fn.<wbr>doTimeout</a></td><td class=SDescription>Initialize, cancel, or force execution of a callback after a delay. </td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="License"></a>License</h3><div class=CBody><p>Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses. <a href="http://benalman.com/about/license/" class=LURL target=_top>http://benalman.com/about/license/</a></p></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Examples"></a>Examples</h3><div class=CBody><p>These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.</p><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>Debouncing</td><td class=CDLDescription><a href="http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/" class=LURL target=_top>http://benalman.com<wbr>/code<wbr>/projects<wbr>/jquery-dotimeout<wbr>/examples<wbr>/debouncing<wbr>/</a></td></tr><tr><td class=CDLEntry>Delays, Polling</td><td class=CDLDescription><a href="http://benalman.com/code/projects/jquery-dotimeout/examples/delay-poll/" class=LURL target=_top>http://benalman.com<wbr>/code<wbr>/projects<wbr>/jquery-dotimeout<wbr>/examples<wbr>/delay-poll<wbr>/</a></td></tr><tr><td class=CDLEntry>Hover Intent</td><td class=CDLDescription><a href="http://benalman.com/code/projects/jquery-dotimeout/examples/hoverintent/" class=LURL target=_top>http://benalman.com<wbr>/code<wbr>/projects<wbr>/jquery-dotimeout<wbr>/examples<wbr>/hoverintent<wbr>/</a></td></tr></table></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Support_and_Testing"></a>Support and Testing</h3><div class=CBody><p>Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).</p><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>jQuery Versions</td><td class=CDLDescription>1.3.2, 1.4.2</td></tr><tr><td class=CDLEntry>Browsers Tested</td><td class=CDLDescription>Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1.</td></tr><tr><td class=CDLEntry>Unit Tests</td><td class=CDLDescription><a href="http://benalman.com/code/projects/jquery-dotimeout/unit/" class=LURL target=_top>http://benalman.com<wbr>/code<wbr>/projects<wbr>/jquery-dotimeout<wbr>/unit<wbr>/</a></td></tr></table></div></div></div>
<div class="CGeneric"><div class=CTopic><h3 class=CTitle><a name="Release_History"></a>Release History</h3><div class=CBody><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>1.0</td><td class=CDLDescription>(3/3/2010) Callback can now be a string, in which case it will call the appropriate $.method or $.fn.method, depending on where .doTimeout was called. Callback must now return `true` (not just a truthy value) to poll.</td></tr><tr><td class=CDLEntry>0.4</td><td class=CDLDescription>(7/15/2009) Made the “id” argument optional, some other minor tweaks</td></tr><tr><td class=CDLEntry>0.3</td><td class=CDLDescription>(6/25/2009) Initial release</td></tr></table></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Functions"></a>Functions</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="jQuery.doTimeout"></a>jQuery.<wbr>doTimeout</h3><div class=CBody><p>Initialize, cancel, or force execution of a callback after a delay.</p><p>If delay and callback are specified, a doTimeout is initialized. The callback will execute, asynchronously, after the delay. If an id is specified, this doTimeout will override and cancel any existing doTimeout with the same id. Any additional arguments will be passed into callback when it is executed.</p><p>If the callback returns true, the doTimeout loop will execute again, after the delay, creating a polling loop until the callback returns a non-true value.</p><p>Note that if an id is not passed as the first argument, this doTimeout will NOT be able to be manually canceled or forced. (for debouncing, be sure to specify an id).</p><p>If id is specified, but delay and callback are not, the doTimeout will be canceled without executing the callback. If force_mode is specified, the callback will be executed, synchronously, but will only be allowed to continue a polling loop if force_mode is true (provided the callback returns true, of course). If force_mode is false, no polling loop will continue, even if the callback returns true.</p><h4 class=CHeading>Usage</h4><blockquote><pre>jQuery.doTimeout( [ id, ] delay, callback [, arg ... ] );
jQuery.doTimeout( id [, force_mode ] );</pre></blockquote><h4 class=CHeading>Arguments</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>id</td><td class=CDLDescription>(String) An optional unique identifier for this doTimeout. If id is not specified, the doTimeout will NOT be able to be manually canceled or forced.</td></tr><tr><td class=CDLEntry>delay</td><td class=CDLDescription>(Number) A zero-or-greater delay in milliseconds after which callback will be executed.</td></tr><tr><td class=CDLEntry>callback</td><td class=CDLDescription>(Function) A function to be executed after delay milliseconds.</td></tr><tr><td class=CDLEntry>callback</td><td class=CDLDescription>(String) A jQuery method to be executed after delay milliseconds. This method will only poll if it explicitly returns true.</td></tr><tr><td class=CDLEntry>force_mode</td><td class=CDLDescription>(Boolean) If true, execute that id’s doTimeout callback immediately and synchronously, continuing any callback return-true polling loop. If false, execute the callback immediately and synchronously but do NOT continue a callback return-true polling loop. If omitted, cancel that id’s doTimeout.</td></tr></table><h4 class=CHeading>Returns</h4><p>If force_mode is true, false or undefined and there is a yet-to-be-executed callback to cancel, true is returned, but if no callback remains to be executed, undefined is returned.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="jQuery.fn.doTimeout"></a>jQuery.<wbr>fn.<wbr>doTimeout</h3><div class=CBody><p>Initialize, cancel, or force execution of a callback after a delay. Operates like <a href="#jQuery.doTimeout" class=LFunction id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">jQuery.doTimeout</a>, but the passed callback executes in the context of the jQuery collection of elements, and the id is stored as data on the first element in that collection.</p><p>If delay and callback are specified, a doTimeout is initialized. The callback will execute, asynchronously, after the delay. If an id is specified, this doTimeout will override and cancel any existing doTimeout with the same id. Any additional arguments will be passed into callback when it is executed.</p><p>If the callback returns true, the doTimeout loop will execute again, after the delay, creating a polling loop until the callback returns a non-true value.</p><p>Note that if an id is not passed as the first argument, this doTimeout will NOT be able to be manually canceled or forced (for debouncing, be sure to specify an id).</p><p>If id is specified, but delay and callback are not, the doTimeout will be canceled without executing the callback. If force_mode is specified, the callback will be executed, synchronously, but will only be allowed to continue a polling loop if force_mode is true (provided the callback returns true, of course). If force_mode is false, no polling loop will continue, even if the callback returns true.</p><h4 class=CHeading>Usage</h4><blockquote><pre>jQuery('selector').doTimeout( [ id, ] delay, callback [, arg ... ] );
jQuery('selector').doTimeout( id [, force_mode ] );</pre></blockquote><h4 class=CHeading>Arguments</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>id</td><td class=CDLDescription>(String) An optional unique identifier for this doTimeout, stored as jQuery data on the element. If id is not specified, the doTimeout will NOT be able to be manually canceled or forced.</td></tr><tr><td class=CDLEntry>delay</td><td class=CDLDescription>(Number) A zero-or-greater delay in milliseconds after which callback will be executed.</td></tr><tr><td class=CDLEntry>callback</td><td class=CDLDescription>(Function) A function to be executed after delay milliseconds.</td></tr><tr><td class=CDLEntry>callback</td><td class=CDLDescription>(String) A jQuery.fn method to be executed after delay milliseconds. This method will only poll if it explicitly returns true (most jQuery.fn methods return a jQuery object, and not `true`, which allows them to be chained and prevents polling).</td></tr><tr><td class=CDLEntry>force_mode</td><td class=CDLDescription>(Boolean) If true, execute that id’s doTimeout callback immediately and synchronously, continuing any callback return-true polling loop. If false, execute the callback immediately and synchronously but do NOT continue a callback return-true polling loop. If omitted, cancel that id’s doTimeout.</td></tr></table><h4 class=CHeading>Returns</h4><p>When creating a <a href="#jQuery.fn.doTimeout" class=LFunction id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">jQuery.fn.doTimeout</a>, the initial jQuery collection of elements is returned. Otherwise, if force_mode is true, false or undefined and there is a yet-to-be-executed callback to cancel, true is returned, but if no callback remains to be executed, undefined is returned.</p></div></div></div>
</div><!--Content-->
<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<div id=Menu><div class=MEntry><div class=MFile id=MSelected>jQuery doTimeout: Like setTimeout, but better!</div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Index</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Files.html">Files</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Files">Files</option><option value="Functions">Functions</option></select></div></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction>Initialize, cancel, or force execution of a callback after a delay.</div></div><div class=CToolTip id="tt2"><div class=CFunction>Initialize, cancel, or force execution of a callback after a delay. </div></div><!--END_ND_TOOLTIPS-->
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>