|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
2 <html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#"> |
|
3 <head> |
|
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> |
|
5 <title>API: queue queue-base.js (YUI Library)</title> |
|
6 |
|
7 <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" /> |
|
8 <link rel="stylesheet" type="text/css" href="assets/api.css" /> |
|
9 |
|
10 <script type="text/javascript" src="assets/api-js"></script> |
|
11 <script type="text/javascript" src="assets/ac-js"></script> |
|
12 </head> |
|
13 |
|
14 <body id="yahoo-com"> |
|
15 |
|
16 <div id="doc3" class="yui-t2"> |
|
17 <div id="hd"> |
|
18 <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1> |
|
19 <h3>queue <span class="subtitle">3.0.0b1</span></h3> |
|
20 <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> |
|
21 > <a href="./module_queue.html" title="queue">queue</a> |
|
22 |
|
23 > queue-base.js (source view) |
|
24 <form onsubmit="return false"> |
|
25 <div id="propertysearch"> |
|
26 Search: <input autocomplete="off" id="searchinput" /> |
|
27 <div id="searchresults"> |
|
28 |
|
29 </div> |
|
30 </div> |
|
31 </form> |
|
32 </div> |
|
33 |
|
34 <div id="bd"> |
|
35 <div id="yui-main"> |
|
36 <div class="yui-b"> |
|
37 <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form"> |
|
38 <fieldset> |
|
39 <legend>Filters</legend> |
|
40 <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span> |
|
41 <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span> |
|
42 <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span> |
|
43 </fieldset> |
|
44 </form> |
|
45 |
|
46 <div id="srcout"> |
|
47 <style> |
|
48 #doc3 .classopts { display:none; } |
|
49 </style> |
|
50 <div class="highlight" ><pre><span class="c">/**</span> |
|
51 <span class="c"> * <p>The Queue module adds a common data structure for FIFO operations. In its</span> |
|
52 <span class="c"> * simplest form, it is little more than an array wrapper. Additional</span> |
|
53 <span class="c"> * submodules introduce more functionality such as promotion and removal of</span> |
|
54 <span class="c"> * queued items.</p></span> |
|
55 <span class="c"> *</span> |
|
56 <span class="c"> * <p>An AsyncQueue class is provided in the queue-run submodule. This class</span> |
|
57 <span class="c"> * affords a mechanism to do complex sequential and iterative callback</span> |
|
58 <span class="c"> * execution across configured timeouts.</span> |
|
59 <span class="c"> *</span> |
|
60 <span class="c"> * @module queue</span> |
|
61 <span class="c"> */</span> |
|
62 |
|
63 <span class="c">/**</span> |
|
64 <span class="c"> * A simple FIFO queue. Items are added to the Queue with add(1..n items) and</span> |
|
65 <span class="c"> * removed using next().</span> |
|
66 <span class="c"> *</span> |
|
67 <span class="c"> * @module queue</span> |
|
68 <span class="c"> * @submodule queue-base</span> |
|
69 <span class="c"> * @class Queue</span> |
|
70 <span class="c"> * @param item* {MIXED} 0..n items to seed the queue</span> |
|
71 <span class="c"> */</span> |
|
72 <span class="k">function</span> <span class="nx">Queue</span><span class="o">()</span> <span class="o">{</span> |
|
73 <span class="k">this</span><span class="o">.</span><span class="nx">_init</span><span class="o">();</span> |
|
74 <span class="k">this</span><span class="o">.</span><span class="nx">add</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span> |
|
75 <span class="o">}</span> |
|
76 |
|
77 <span class="nx">Queue</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="o">{</span> |
|
78 <span class="c">/**</span> |
|
79 <span class="c"> * Initialize the queue</span> |
|
80 <span class="c"> *</span> |
|
81 <span class="c"> * @method _init</span> |
|
82 <span class="c"> * @protected</span> |
|
83 <span class="c"> */</span> |
|
84 <span class="nx">_init</span> <span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span> |
|
85 <span class="c">/**</span> |
|
86 <span class="c"> * The collection of enqueued items</span> |
|
87 <span class="c"> *</span> |
|
88 <span class="c"> * @property _q</span> |
|
89 <span class="c"> * @type {Array}</span> |
|
90 <span class="c"> * @protected</span> |
|
91 <span class="c"> */</span> |
|
92 <span class="k">this</span><span class="o">.</span><span class="nx">_q</span> <span class="o">=</span> <span class="o">[];</span> |
|
93 <span class="o">},</span> |
|
94 |
|
95 <span class="c">/**</span> |
|
96 <span class="c"> * Get the next item in the queue.</span> |
|
97 <span class="c"> *</span> |
|
98 <span class="c"> * @method next</span> |
|
99 <span class="c"> * @return {MIXED} the next item in the queue</span> |
|
100 <span class="c"> */</span> |
|
101 <span class="nx">next</span> <span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span> |
|
102 <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_q</span><span class="o">.</span><span class="nx">shift</span><span class="o">();</span> |
|
103 <span class="o">},</span> |
|
104 |
|
105 <span class="c">/**</span> |
|
106 <span class="c"> * Add 0..n items to the end of the queue</span> |
|
107 <span class="c"> *</span> |
|
108 <span class="c"> * @method add</span> |
|
109 <span class="c"> * @param item* {MIXED} 0..n items</span> |
|
110 <span class="c"> */</span> |
|
111 <span class="nx">add</span> <span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span> |
|
112 <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span><span class="m">0</span><span class="o">,</span><span class="kc">true</span><span class="o">),</span><span class="k">function</span> <span class="o">(</span><span class="nx">fn</span><span class="o">)</span> <span class="o">{</span> |
|
113 <span class="k">this</span><span class="o">.</span><span class="nx">_q</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">fn</span><span class="o">);</span> |
|
114 <span class="o">},</span><span class="k">this</span><span class="o">);</span> |
|
115 |
|
116 <span class="k">return</span> <span class="k">this</span><span class="o">;</span> |
|
117 <span class="o">},</span> |
|
118 |
|
119 <span class="c">/**</span> |
|
120 <span class="c"> * Returns the current number of queued items</span> |
|
121 <span class="c"> *</span> |
|
122 <span class="c"> * @method size</span> |
|
123 <span class="c"> * @return {Number}</span> |
|
124 <span class="c"> */</span> |
|
125 <span class="nx">size</span> <span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span> |
|
126 <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_q</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> |
|
127 <span class="o">}</span> |
|
128 <span class="o">};</span> |
|
129 |
|
130 <span class="nx">Y</span><span class="o">.</span><span class="nx">Queue</span> <span class="o">=</span> <span class="nx">Queue</span><span class="o">;</span> |
|
131 </pre></div> |
|
132 </div> |
|
133 </div> |
|
134 </div> |
|
135 <div class="yui-b"> |
|
136 <div class="nav"> |
|
137 |
|
138 <div id="moduleList" class="module"> |
|
139 <h4>Modules</h4> |
|
140 <ul class="content"> |
|
141 <li class=""><a href="module_anim.html" title="anim">anim</a></li> |
|
142 <li class=""><a href="module_attribute.html" title="attribute">attribute</a></li> |
|
143 <li class=""><a href="module_base.html" title="base">base</a></li> |
|
144 <li class=""><a href="module_cache.html" title="cache">cache</a></li> |
|
145 <li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li> |
|
146 <li class=""><a href="module_collection.html" title="collection">collection</a></li> |
|
147 <li class=""><a href="module_console.html" title="console">console</a></li> |
|
148 <li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li> |
|
149 <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li> |
|
150 <li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li> |
|
151 <li class=""><a href="module_datasource.html" title="datasource">datasource</a></li> |
|
152 <li class=""><a href="module_datatype.html" title="datatype">datatype</a></li> |
|
153 <li class=""><a href="module_dd.html" title="dd">dd</a></li> |
|
154 <li class=""><a href="module_dom.html" title="dom">dom</a></li> |
|
155 <li class=""><a href="module_dump.html" title="dump">dump</a></li> |
|
156 <li class=""><a href="module_event.html" title="event">event</a></li> |
|
157 <li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li> |
|
158 <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li> |
|
159 <li class=""><a href="module_history.html" title="history">history</a></li> |
|
160 <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li> |
|
161 <li class=""><a href="module_io.html" title="io">io</a></li> |
|
162 <li class=""><a href="module_json.html" title="json">json</a></li> |
|
163 <li class=""><a href="module_node.html" title="node">node</a></li> |
|
164 <li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li> |
|
165 <li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li> |
|
166 <li class=""><a href="module_oop.html" title="oop">oop</a></li> |
|
167 <li class=""><a href="module_overlay.html" title="overlay">overlay</a></li> |
|
168 <li class=""><a href="module_plugin.html" title="plugin">plugin</a></li> |
|
169 <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li> |
|
170 <li class="selected"><a href="module_queue.html" title="queue">queue</a></li> |
|
171 <li class=""><a href="module_slider.html" title="slider">slider</a></li> |
|
172 <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li> |
|
173 <li class=""><a href="module_substitute.html" title="substitute">substitute</a></li> |
|
174 <li class=""><a href="module_test.html" title="test">test</a></li> |
|
175 <li class=""><a href="module_widget.html" title="widget">widget</a></li> |
|
176 <li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li> |
|
177 <li class=""><a href="module_widget-position-ext.html" title="widget-position-ext">widget-position-ext</a></li> |
|
178 <li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li> |
|
179 <li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li> |
|
180 <li class=""><a href="module_yui.html" title="yui">yui</a></li> |
|
181 </ul> |
|
182 </div> |
|
183 |
|
184 <div id="classList" class="module"> |
|
185 <h4>Classes</h4> |
|
186 <ul class="content"> |
|
187 <li class=""><a href="AsyncQueue.html" title="AsyncQueue">AsyncQueue</a></li> |
|
188 <li class=""><a href="Queue.html" title="Queue">Queue</a></li> |
|
189 </ul> |
|
190 </div> |
|
191 |
|
192 <div id="fileList" class="module"> |
|
193 <h4>Files</h4> |
|
194 <ul class="content"> |
|
195 <li class="selected"><a href="queue-base.js.html" title="queue-base.js">queue-base.js</a></li> |
|
196 <li class=""><a href="queue-promote.js.html" title="queue-promote.js">queue-promote.js</a></li> |
|
197 <li class=""><a href="queue-run.js.html" title="queue-run.js">queue-run.js</a></li> |
|
198 </ul> |
|
199 </div> |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 </div> |
|
206 </div> |
|
207 </div> |
|
208 <div id="ft"> |
|
209 <hr /> |
|
210 Copyright © 2009 Yahoo! Inc. All rights reserved. |
|
211 </div> |
|
212 </div> |
|
213 <script type="text/javascript"> |
|
214 ALL_YUI_PROPS = [{"access": "", "host": "AsyncQueue", "name": "add", "url": "AsyncQueue.html#method_add", "type": "method"}, {"access": "", "host": "Queue", "name": "add", "url": "Queue.html#method_add", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "AsyncQueue.defaults", "url": "AsyncQueue.html#property_AsyncQueue.defaults", "type": "property"}, {"access": "", "host": "AsyncQueue", "name": "complete", "url": "AsyncQueue.html#event_complete", "type": "event"}, {"access": "protected", "host": "AsyncQueue", "name": "_defAddFn", "url": "AsyncQueue.html#method__defAddFn", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "defaults", "url": "AsyncQueue.html#property_defaults", "type": "property"}, {"access": "protected", "host": "AsyncQueue", "name": "_defExecFn", "url": "AsyncQueue.html#method__defExecFn", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_defPromoteFn", "url": "AsyncQueue.html#method__defPromoteFn", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_defRemoveFn", "url": "AsyncQueue.html#method__defRemoveFn", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_defShiftFn", "url": "AsyncQueue.html#method__defShiftFn", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_execute", "url": "AsyncQueue.html#method__execute", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "getCallback", "url": "AsyncQueue.html#method_getCallback", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "indexOf", "url": "AsyncQueue.html#method_indexOf", "type": "method"}, {"access": "", "host": "Queue", "name": "indexOf", "url": "Queue.html#method_indexOf", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_init", "url": "AsyncQueue.html#method__init", "type": "method"}, {"access": "protected", "host": "Queue", "name": "_init", "url": "Queue.html#method__init", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_initEvents", "url": "AsyncQueue.html#method__initEvents", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "isRunning", "url": "AsyncQueue.html#method_isRunning", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "next", "url": "AsyncQueue.html#method_next", "type": "method"}, {"access": "", "host": "Queue", "name": "next", "url": "Queue.html#method_next", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "pause", "url": "AsyncQueue.html#method_pause", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_prepare", "url": "AsyncQueue.html#method__prepare", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "promote", "url": "AsyncQueue.html#method_promote", "type": "method"}, {"access": "", "host": "Queue", "name": "promote", "url": "Queue.html#method_promote", "type": "method"}, {"access": "protected", "host": "Queue", "name": "_q", "url": "Queue.html#property__q", "type": "property"}, {"access": "", "host": "AsyncQueue", "name": "remove", "url": "AsyncQueue.html#method_remove", "type": "method"}, {"access": "", "host": "Queue", "name": "remove", "url": "Queue.html#method_remove", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "run", "url": "AsyncQueue.html#method_run", "type": "method"}, {"access": "protected", "host": "AsyncQueue", "name": "_running", "url": "AsyncQueue.html#property__running", "type": "property"}, {"access": "protected", "host": "AsyncQueue", "name": "_schedule", "url": "AsyncQueue.html#method__schedule", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "size", "url": "AsyncQueue.html#method_size", "type": "method"}, {"access": "", "host": "Queue", "name": "size", "url": "Queue.html#method_size", "type": "method"}, {"access": "", "host": "AsyncQueue", "name": "stop", "url": "AsyncQueue.html#method_stop", "type": "method"}]; |
|
215 </script> |
|
216 </body> |
|
217 </html> |