Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / Ext.html
1 <html>
2 <head>
3   <title>The source code</title>
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
6 </head>
7 <body  onload="prettyPrint();">
8     <pre class="prettyprint lang-js">/*!
9  * Ext JS Library 3.0.3
10  * Copyright(c) 2006-2009 Ext JS, LLC
11  * licensing@extjs.com
12  * http://www.extjs.com/license
13  */
14 \r
15 // for old browsers\r
16 window.undefined = window.undefined;\r
17 \r
18 <div id="cls-Ext"></div>/**\r
19  * @class Ext\r
20  * Ext core utilities and functions.\r
21  * @singleton\r
22  */\r
23 \r
24 Ext = {\r
25     <div id="prop-Ext-version"></div>/**\r
26      * The version of the framework\r
27      * @type String\r
28      */\r
29     version : '3.0.1'\r
30 };\r
31 \r
32 <div id="method-Ext-apply"></div>/**\r
33  * Copies all the properties of config to obj.\r
34  * @param {Object} obj The receiver of the properties\r
35  * @param {Object} config The source of the properties\r
36  * @param {Object} defaults A different object that will also be applied for default values\r
37  * @return {Object} returns obj\r
38  * @member Ext apply\r
39  */\r
40 Ext.apply = function(o, c, defaults){\r
41     // no "this" reference for friendly out of scope calls\r
42     if(defaults){\r
43         Ext.apply(o, defaults);\r
44     }\r
45     if(o && c && typeof c == 'object'){\r
46         for(var p in c){\r
47             o[p] = c[p];\r
48         }\r
49     }\r
50     return o;\r
51 };\r
52 \r
53 (function(){\r
54     var idSeed = 0,\r
55         toString = Object.prototype.toString,\r
56         ua = navigator.userAgent.toLowerCase(),\r
57         check = function(r){\r
58             return r.test(ua);\r
59         },\r
60         DOC = document,\r
61         isStrict = DOC.compatMode == "CSS1Compat",\r
62         isOpera = check(/opera/),\r
63         isChrome = check(/chrome/),\r
64         isWebKit = check(/webkit/),\r
65         isSafari = !isChrome && check(/safari/),\r
66         isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2\r
67         isSafari3 = isSafari && check(/version\/3/),\r
68         isSafari4 = isSafari && check(/version\/4/),\r
69         isIE = !isOpera && check(/msie/),\r
70         isIE7 = isIE && check(/msie 7/),\r
71         isIE8 = isIE && check(/msie 8/),\r
72         isIE6 = isIE && !isIE7 && !isIE8,\r
73         isGecko = !isWebKit && check(/gecko/),\r
74         isGecko2 = isGecko && check(/rv:1\.8/),\r
75         isGecko3 = isGecko && check(/rv:1\.9/),\r
76         isBorderBox = isIE && !isStrict,\r
77         isWindows = check(/windows|win32/),\r
78         isMac = check(/macintosh|mac os x/),\r
79         isAir = check(/adobeair/),\r
80         isLinux = check(/linux/),\r
81         isSecure = /^https/i.test(window.location.protocol);\r
82 \r
83     // remove css image flicker\r
84     if(isIE6){\r
85         try{\r
86             DOC.execCommand("BackgroundImageCache", false, true);\r
87         }catch(e){}\r
88     }\r
89 \r
90     Ext.apply(Ext, {\r
91         <div id="prop-Ext-SSL_SECURE_URL"></div>/**\r
92          * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent\r
93          * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).\r
94          * @type String\r
95          */\r
96         SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank', \r
97         <div id="prop-Ext-isStrict"></div>/**\r
98          * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode\r
99          * @type Boolean\r
100          */\r
101         isStrict : isStrict,\r
102         <div id="prop-Ext-isSecure"></div>/**\r
103          * True if the page is running over SSL\r
104          * @type Boolean\r
105          */\r
106         isSecure : isSecure,\r
107         <div id="prop-Ext-isReady"></div>/**\r
108          * True when the document is fully initialized and ready for action\r
109          * @type Boolean\r
110          */\r
111         isReady : false,\r
112 \r
113         <div id="prop-Ext-enableFx"></div>/**\r
114          * True if the {@link Ext.Fx} Class is available\r
115          * @type Boolean\r
116          * @property enableFx\r
117          */\r
118 \r
119         <div id="prop-Ext-enableGarbageCollector"></div>/**\r
120          * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)\r
121          * @type Boolean\r
122          */\r
123         enableGarbageCollector : true,\r
124 \r
125         <div id="prop-Ext-enableListenerCollection"></div>/**\r
126          * True to automatically purge event listeners after uncaching an element (defaults to false).\r
127          * Note: this only happens if {@link #enableGarbageCollector} is true.\r
128          * @type Boolean\r
129          */\r
130         enableListenerCollection : false,\r
131 \r
132         <div id="prop-Ext-USE_NATIVE_JSON"></div>/**\r
133          * Indicates whether to use native browser parsing for JSON methods.\r
134          * This option is ignored if the browser does not support native JSON methods.\r
135          * <b>Note: Native JSON methods will not work with objects that have functions.\r
136          * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)\r
137          * @type Boolean\r
138          */\r
139         USE_NATIVE_JSON : false,\r
140 \r
141         <div id="method-Ext-applyIf"></div>/**\r
142          * Copies all the properties of config to obj if they don't already exist.\r
143          * @param {Object} obj The receiver of the properties\r
144          * @param {Object} config The source of the properties\r
145          * @return {Object} returns obj\r
146          */\r
147         applyIf : function(o, c){\r
148             if(o){\r
149                 for(var p in c){\r
150                     if(!Ext.isDefined(o[p])){\r
151                         o[p] = c[p];\r
152                     }\r
153                 }\r
154             }\r
155             return o;\r
156         },\r
157 \r
158         <div id="method-Ext-id"></div>/**\r
159          * Generates unique ids. If the element already has an id, it is unchanged\r
160          * @param {Mixed} el (optional) The element to generate an id for\r
161          * @param {String} prefix (optional) Id prefix (defaults "ext-gen")\r
162          * @return {String} The generated Id.\r
163          */\r
164         id : function(el, prefix){\r
165             return (el = Ext.getDom(el) || {}).id = el.id || (prefix || "ext-gen") + (++idSeed);\r
166         },\r
167 \r
168         <div id="method-Ext-extend"></div>/**\r
169          * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method\r
170          * also adds the function "override()" to the subclass that can be used to override members of the class.</p>\r
171          * For example, to create a subclass of Ext GridPanel:\r
172          * <pre><code>\r
173 MyGridPanel = Ext.extend(Ext.grid.GridPanel, {\r
174     constructor: function(config) {\r
175 \r
176 //      Create configuration for this Grid.\r
177         var store = new Ext.data.Store({...});\r
178         var colModel = new Ext.grid.ColumnModel({...});\r
179 \r
180 //      Create a new config object containing our computed properties\r
181 //      *plus* whatever was in the config parameter.\r
182         config = Ext.apply({\r
183             store: store,\r
184             colModel: colModel\r
185         }, config);\r
186 \r
187         MyGridPanel.superclass.constructor.call(this, config);\r
188 \r
189 //      Your postprocessing here\r
190     },\r
191 \r
192     yourMethod: function() {\r
193         // etc.\r
194     }\r
195 });\r
196 </code></pre>\r
197          *\r
198          * <p>This function also supports a 3-argument call in which the subclass's constructor is\r
199          * passed as an argument. In this form, the parameters are as follows:</p>\r
200          * <div class="mdetail-params"><ul>\r
201          * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>\r
202          * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>\r
203          * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's\r
204          * prototype, and are therefore shared among all instances of the new class.</div></li>\r
205          * </ul></div>\r
206          *\r
207          * @param {Function} subclass The constructor of class being extended.\r
208          * @param {Object} overrides <p>A literal with members which are copied into the subclass's\r
209          * prototype, and are therefore shared between all instances of the new class.</p>\r
210          * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used\r
211          * to define the constructor of the new class, and is returned. If this property is\r
212          * <i>not</i> specified, a constructor is generated and returned which just calls the\r
213          * superclass's constructor passing on its parameters.</p>\r
214          * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>\r
215          * @return {Function} The subclass constructor.\r
216          */\r
217         extend : function(){\r
218             // inline overrides\r
219             var io = function(o){\r
220                 for(var m in o){\r
221                     this[m] = o[m];\r
222                 }\r
223             };\r
224             var oc = Object.prototype.constructor;\r
225 \r
226             return function(sb, sp, overrides){\r
227                 if(Ext.isObject(sp)){\r
228                     overrides = sp;\r
229                     sp = sb;\r
230                     sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};\r
231                 }\r
232                 var F = function(){},\r
233                     sbp,\r
234                     spp = sp.prototype;\r
235 \r
236                 F.prototype = spp;\r
237                 sbp = sb.prototype = new F();\r
238                 sbp.constructor=sb;\r
239                 sb.superclass=spp;\r
240                 if(spp.constructor == oc){\r
241                     spp.constructor=sp;\r
242                 }\r
243                 sb.override = function(o){\r
244                     Ext.override(sb, o);\r
245                 };\r
246                 sbp.superclass = sbp.supr = (function(){\r
247                     return spp;\r
248                 });\r
249                 sbp.override = io;\r
250                 Ext.override(sb, overrides);\r
251                 sb.extend = function(o){return Ext.extend(sb, o);};\r
252                 return sb;\r
253             };\r
254         }(),\r
255 \r
256         <div id="method-Ext-override"></div>/**\r
257          * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.\r
258          * Usage:<pre><code>\r
259 Ext.override(MyClass, {\r
260     newMethod1: function(){\r
261         // etc.\r
262     },\r
263     newMethod2: function(foo){\r
264         // etc.\r
265     }\r
266 });\r
267 </code></pre>\r
268          * @param {Object} origclass The class to override\r
269          * @param {Object} overrides The list of functions to add to origClass.  This should be specified as an object literal\r
270          * containing one or more methods.\r
271          * @method override\r
272          */\r
273         override : function(origclass, overrides){\r
274             if(overrides){\r
275                 var p = origclass.prototype;\r
276                 Ext.apply(p, overrides);\r
277                 if(Ext.isIE && overrides.toString != origclass.toString){\r
278                     p.toString = overrides.toString;\r
279                 }\r
280             }\r
281         },\r
282 \r
283         <div id="method-Ext-namespace"></div>/**\r
284          * Creates namespaces to be used for scoping variables and classes so that they are not global.\r
285          * Specifying the last node of a namespace implicitly creates all other nodes. Usage:\r
286          * <pre><code>\r
287 Ext.namespace('Company', 'Company.data');\r
288 Ext.namespace('Company.data'); // equivalent and preferable to above syntax\r
289 Company.Widget = function() { ... }\r
290 Company.data.CustomStore = function(config) { ... }\r
291 </code></pre>\r
292          * @param {String} namespace1\r
293          * @param {String} namespace2\r
294          * @param {String} etc\r
295          * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)\r
296          * @method namespace\r
297          */\r
298         namespace : function(){\r
299             var o, d;\r
300             Ext.each(arguments, function(v) {\r
301                 d = v.split(".");\r
302                 o = window[d[0]] = window[d[0]] || {};\r
303                 Ext.each(d.slice(1), function(v2){\r
304                     o = o[v2] = o[v2] || {};\r
305                 });\r
306             });\r
307             return o;\r
308         },\r
309 \r
310         <div id="method-Ext-urlEncode"></div>/**\r
311          * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2".  Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.\r
312          * @param {Object} o\r
313          * @param {String} pre (optional) A prefix to add to the url encoded string\r
314          * @return {String}\r
315          */\r
316         urlEncode : function(o, pre){\r
317             var empty,\r
318                 buf = [],\r
319                 e = encodeURIComponent;\r
320 \r
321             Ext.iterate(o, function(key, item){\r
322                 empty = Ext.isEmpty(item);\r
323                 Ext.each(empty ? key : item, function(val){\r
324                     buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');\r
325                 });\r
326             });\r
327             if(!pre){\r
328                 buf.shift();\r
329                 pre = '';\r
330             }\r
331             return pre + buf.join('');\r
332         },\r
333 \r
334         <div id="method-Ext-urlDecode"></div>/**\r
335          * Takes an encoded URL and and converts it to an object. Example: <pre><code>\r
336 Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}\r
337 Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}\r
338 </code></pre>\r
339          * @param {String} string\r
340          * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).\r
341          * @return {Object} A literal with members\r
342          */\r
343         urlDecode : function(string, overwrite){\r
344             if(Ext.isEmpty(string)){\r
345                 return {};\r
346             }\r
347             var obj = {},\r
348                 pairs = string.split('&'),\r
349                 d = decodeURIComponent,\r
350                 name,\r
351                 value;\r
352             Ext.each(pairs, function(pair) {\r
353                 pair = pair.split('=');\r
354                 name = d(pair[0]);\r
355                 value = d(pair[1]);\r
356                 obj[name] = overwrite || !obj[name] ? value :\r
357                             [].concat(obj[name]).concat(value);\r
358             });\r
359             return obj;\r
360         },\r
361 \r
362         <div id="method-Ext-urlAppend"></div>/**\r
363          * Appends content to the query string of a URL, handling logic for whether to place\r
364          * a question mark or ampersand.\r
365          * @param {String} url The URL to append to.\r
366          * @param {String} s The content to append to the URL.\r
367          * @return (String) The resulting URL\r
368          */\r
369         urlAppend : function(url, s){\r
370             if(!Ext.isEmpty(s)){\r
371                 return url + (url.indexOf('?') === -1 ? '?' : '&') + s;\r
372             }\r
373             return url;\r
374         },\r
375 \r
376         <div id="method-Ext-toArray"></div>/**\r
377          * Converts any iterable (numeric indices and a length property) into a true array\r
378          * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.\r
379          * For strings, use this instead: "abc".match(/./g) => [a,b,c];\r
380          * @param {Iterable} the iterable object to be turned into a true Array.\r
381          * @return (Array) array\r
382          */\r
383         toArray : function(){\r
384             return isIE ?\r
385                 function(a, i, j, res){\r
386                     res = [];\r
387                     Ext.each(a, function(v) {\r
388                         res.push(v);\r
389                     });\r
390                     return res.slice(i || 0, j || res.length);\r
391                 } :\r
392                 function(a, i, j){\r
393                     return Array.prototype.slice.call(a, i || 0, j || a.length);\r
394                 }\r
395         }(),\r
396 \r
397         isIterable : function(v){\r
398             //check for array or arguments\r
399             if(Ext.isArray(v) || v.callee){\r
400                 return true;\r
401             }\r
402             //check for node list type\r
403             if(/NodeList|HTMLCollection/.test(toString.call(v))){\r
404                 return true;\r
405             }\r
406             //NodeList has an item and length property\r
407             //IXMLDOMNodeList has nextNode method, needs to be checked first.\r
408             return ((v.nextNode || v.item) && Ext.isNumber(v.length));\r
409         },\r
410 \r
411         <div id="method-Ext-each"></div>/**\r
412          * Iterates an array calling the supplied function.\r
413          * @param {Array/NodeList/Mixed} array The array to be iterated. If this\r
414          * argument is not really an array, the supplied function is called once.\r
415          * @param {Function} fn The function to be called with each item. If the\r
416          * supplied function returns false, iteration stops and this method returns\r
417          * the current <code>index</code>. This function is called with\r
418          * the following arguments:\r
419          * <div class="mdetail-params"><ul>\r
420          * <li><code>item</code> : <i>Mixed</i>\r
421          * <div class="sub-desc">The item at the current <code>index</code>\r
422          * in the passed <code>array</code></div></li>\r
423          * <li><code>index</code> : <i>Number</i>\r
424          * <div class="sub-desc">The current index within the array</div></li>\r
425          * <li><code>allItems</code> : <i>Array</i>\r
426          * <div class="sub-desc">The <code>array</code> passed as the first\r
427          * argument to <code>Ext.each</code>.</div></li>\r
428          * </ul></div>\r
429          * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.\r
430          * Defaults to the <code>item</code> at the current <code>index</code>\r
431          * within the passed <code>array</code>.\r
432          * @return See description for the fn parameter.\r
433          */\r
434         each : function(array, fn, scope){\r
435             if(Ext.isEmpty(array, true)){\r
436                 return;\r
437             }\r
438             if(!Ext.isIterable(array) || Ext.isPrimitive(array)){\r
439                 array = [array];\r
440             }\r
441             for(var i = 0, len = array.length; i < len; i++){\r
442                 if(fn.call(scope || array[i], array[i], i, array) === false){\r
443                     return i;\r
444                 };\r
445             }\r
446         },\r
447 \r
448         <div id="method-Ext-iterate"></div>/**\r
449          * Iterates either the elements in an array, or each of the properties in an object.\r
450          * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.\r
451          * @param {Object/Array} object The object or array to be iterated\r
452          * @param {Function} fn The function to be called for each iteration.\r
453          * The iteration will stop if the supplied function returns false, or\r
454          * all array elements / object properties have been covered. The signature\r
455          * varies depending on the type of object being interated:\r
456          * <div class="mdetail-params"><ul>\r
457          * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>\r
458          * <div class="sub-desc">\r
459          * When iterating an array, the supplied function is called with each item.</div></li>\r
460          * <li>Objects : <tt>(String key, Object value)</tt>\r
461          * <div class="sub-desc">\r
462          * When iterating an object, the supplied function is called with each key-value pair in\r
463          * the object.</div></li>\r
464          * </ul></div>\r
465          * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to\r
466          * the <code>object</code> being iterated.\r
467          */\r
468         iterate : function(obj, fn, scope){\r
469             if(Ext.isEmpty(obj)){\r
470                 return;\r
471             }\r
472             if(Ext.isIterable(obj)){\r
473                 Ext.each(obj, fn, scope);\r
474                 return;\r
475             }else if(Ext.isObject(obj)){\r
476                 for(var prop in obj){\r
477                     if(obj.hasOwnProperty(prop)){\r
478                         if(fn.call(scope || obj, prop, obj[prop]) === false){\r
479                             return;\r
480                         };\r
481                     }\r
482                 }\r
483             }\r
484         },\r
485 \r
486         <div id="method-Ext-getDom"></div>/**\r
487          * Return the dom node for the passed String (id), dom node, or Ext.Element.\r
488          * Here are some examples:\r
489          * <pre><code>\r
490 // gets dom node based on id\r
491 var elDom = Ext.getDom('elId');\r
492 // gets dom node based on the dom node\r
493 var elDom1 = Ext.getDom(elDom);\r
494 \r
495 // If we don&#39;t know if we are working with an\r
496 // Ext.Element or a dom node use Ext.getDom\r
497 function(el){\r
498     var dom = Ext.getDom(el);\r
499     // do something with the dom node\r
500 }\r
501          * </code></pre>\r
502          * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)\r
503          * when this method is called to be successful.\r
504          * @param {Mixed} el\r
505          * @return HTMLElement\r
506          */\r
507         getDom : function(el){\r
508             if(!el || !DOC){\r
509                 return null;\r
510             }\r
511             return el.dom ? el.dom : (Ext.isString(el) ? DOC.getElementById(el) : el);\r
512         },\r
513 \r
514         <div id="method-Ext-getBody"></div>/**\r
515          * Returns the current document body as an {@link Ext.Element}.\r
516          * @return Ext.Element The document body\r
517          */\r
518         getBody : function(){\r
519             return Ext.get(DOC.body || DOC.documentElement);\r
520         },\r
521 \r
522         <div id="method-Ext-removeNode"></div>/**\r
523          * Removes a DOM node from the document.  The body node will be ignored if passed in.\r
524          * @param {HTMLElement} node The node to remove\r
525          */\r
526         removeNode : isIE ? function(){\r
527             var d;\r
528             return function(n){\r
529                 if(n && n.tagName != 'BODY'){\r
530                     d = d || DOC.createElement('div');\r
531                     d.appendChild(n);\r
532                     d.innerHTML = '';\r
533                 }\r
534             }\r
535         }() : function(n){\r
536             if(n && n.parentNode && n.tagName != 'BODY'){\r
537                 n.parentNode.removeChild(n);\r
538             }\r
539         },\r
540 \r
541         <div id="method-Ext-isEmpty"></div>/**\r
542          * <p>Returns true if the passed value is empty.</p>\r
543          * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>\r
544          * <li>null</li>\r
545          * <li>undefined</li>\r
546          * <li>an empty array</li>\r
547          * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>\r
548          * </ul></div>\r
549          * @param {Mixed} value The value to test\r
550          * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)\r
551          * @return {Boolean}\r
552          */\r
553         isEmpty : function(v, allowBlank){\r
554             return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);\r
555         },\r
556 \r
557         <div id="method-Ext-isArray"></div>/**\r
558          * Returns true if the passed value is a JavaScript array, otherwise false.\r
559          * @param {Mixed} value The value to test\r
560          * @return {Boolean}\r
561          */\r
562         isArray : function(v){\r
563             return toString.apply(v) === '[object Array]';\r
564         },\r
565 \r
566         <div id="method-Ext-isDate"></div>/**\r
567          * Returns true if the passed object is a JavaScript date object, otherwise false.\r
568          * @param {Object} object The object to test\r
569          * @return {Boolean}\r
570          */\r
571         isDate : function(v){\r
572             return toString.apply(v) === '[object Date]';\r
573         },\r
574 \r
575         <div id="method-Ext-isObject"></div>/**\r
576          * Returns true if the passed value is a JavaScript Object, otherwise false.\r
577          * @param {Mixed} value The value to test\r
578          * @return {Boolean}\r
579          */\r
580         isObject : function(v){\r
581             return v && typeof v == "object";\r
582         },\r
583 \r
584         <div id="method-Ext-isPrimitive"></div>/**\r
585          * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.\r
586          * @param {Mixed} value The value to test\r
587          * @return {Boolean}\r
588          */\r
589         isPrimitive : function(v){\r
590             return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);\r
591         },\r
592 \r
593         <div id="method-Ext-isFunction"></div>/**\r
594          * Returns true if the passed value is a JavaScript Function, otherwise false.\r
595          * @param {Mixed} value The value to test\r
596          * @return {Boolean}\r
597          */\r
598         isFunction : function(v){\r
599             return toString.apply(v) === '[object Function]';\r
600         },\r
601 \r
602         <div id="method-Ext-isNumber"></div>/**\r
603          * Returns true if the passed value is a number. Returns false for non-finite numbers.\r
604          * @param {Mixed} value The value to test\r
605          * @return {Boolean}\r
606          */\r
607         isNumber : function(v){\r
608             return typeof v === 'number' && isFinite(v);\r
609         },\r
610 \r
611         <div id="method-Ext-isString"></div>/**\r
612          * Returns true if the passed value is a string.\r
613          * @param {Mixed} value The value to test\r
614          * @return {Boolean}\r
615          */\r
616         isString : function(v){\r
617             return typeof v === 'string';\r
618         },\r
619 \r
620         <div id="method-Ext-isBoolean"></div>/**\r
621          * Returns true if the passed value is a boolean.\r
622          * @param {Mixed} value The value to test\r
623          * @return {Boolean}\r
624          */\r
625         isBoolean : function(v){\r
626             return typeof v === 'boolean';\r
627         },\r
628 \r
629         <div id="method-Ext-isDefined"></div>/**\r
630          * Returns true if the passed value is not undefined.\r
631          * @param {Mixed} value The value to test\r
632          * @return {Boolean}\r
633          */\r
634         isDefined : function(v){\r
635             return typeof v !== 'undefined';\r
636         },\r
637 \r
638         <div id="prop-Ext-isOpera"></div>/**\r
639          * True if the detected browser is Opera.\r
640          * @type Boolean\r
641          */\r
642         isOpera : isOpera,\r
643         <div id="prop-Ext-isWebKit"></div>/**\r
644          * True if the detected browser uses WebKit.\r
645          * @type Boolean\r
646          */\r
647         isWebKit : isWebKit,\r
648         <div id="prop-Ext-isChrome"></div>/**\r
649          * True if the detected browser is Chrome.\r
650          * @type Boolean\r
651          */\r
652         isChrome : isChrome,\r
653         <div id="prop-Ext-isSafari"></div>/**\r
654          * True if the detected browser is Safari.\r
655          * @type Boolean\r
656          */\r
657         isSafari : isSafari,\r
658         <div id="prop-Ext-isSafari3"></div>/**\r
659          * True if the detected browser is Safari 3.x.\r
660          * @type Boolean\r
661          */\r
662         isSafari3 : isSafari3,\r
663         <div id="prop-Ext-isSafari4"></div>/**\r
664          * True if the detected browser is Safari 4.x.\r
665          * @type Boolean\r
666          */\r
667         isSafari4 : isSafari4,\r
668         <div id="prop-Ext-isSafari2"></div>/**\r
669          * True if the detected browser is Safari 2.x.\r
670          * @type Boolean\r
671          */\r
672         isSafari2 : isSafari2,\r
673         <div id="prop-Ext-isIE"></div>/**\r
674          * True if the detected browser is Internet Explorer.\r
675          * @type Boolean\r
676          */\r
677         isIE : isIE,\r
678         <div id="prop-Ext-isIE6"></div>/**\r
679          * True if the detected browser is Internet Explorer 6.x.\r
680          * @type Boolean\r
681          */\r
682         isIE6 : isIE6,\r
683         <div id="prop-Ext-isIE7"></div>/**\r
684          * True if the detected browser is Internet Explorer 7.x.\r
685          * @type Boolean\r
686          */\r
687         isIE7 : isIE7,\r
688         <div id="prop-Ext-isIE8"></div>/**\r
689          * True if the detected browser is Internet Explorer 8.x.\r
690          * @type Boolean\r
691          */\r
692         isIE8 : isIE8,\r
693         <div id="prop-Ext-isGecko"></div>/**\r
694          * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).\r
695          * @type Boolean\r
696          */\r
697         isGecko : isGecko,\r
698         <div id="prop-Ext-isGecko2"></div>/**\r
699          * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).\r
700          * @type Boolean\r
701          */\r
702         isGecko2 : isGecko2,\r
703         <div id="prop-Ext-isGecko3"></div>/**\r
704          * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).\r
705          * @type Boolean\r
706          */\r
707         isGecko3 : isGecko3,\r
708         <div id="prop-Ext-isBorderBox"></div>/**\r
709          * True if the detected browser is Internet Explorer running in non-strict mode.\r
710          * @type Boolean\r
711          */\r
712         isBorderBox : isBorderBox,\r
713         <div id="prop-Ext-isLinux"></div>/**\r
714          * True if the detected platform is Linux.\r
715          * @type Boolean\r
716          */\r
717         isLinux : isLinux,\r
718         <div id="prop-Ext-isWindows"></div>/**\r
719          * True if the detected platform is Windows.\r
720          * @type Boolean\r
721          */\r
722         isWindows : isWindows,\r
723         <div id="prop-Ext-isMac"></div>/**\r
724          * True if the detected platform is Mac OS.\r
725          * @type Boolean\r
726          */\r
727         isMac : isMac,\r
728         <div id="prop-Ext-isAir"></div>/**\r
729          * True if the detected platform is Adobe Air.\r
730          * @type Boolean\r
731          */\r
732         isAir : isAir\r
733     });\r
734 \r
735     <div id="method-Ext-ns"></div>/**\r
736      * Creates namespaces to be used for scoping variables and classes so that they are not global.\r
737      * Specifying the last node of a namespace implicitly creates all other nodes. Usage:\r
738      * <pre><code>\r
739 Ext.namespace('Company', 'Company.data');\r
740 Ext.namespace('Company.data'); // equivalent and preferable to above syntax\r
741 Company.Widget = function() { ... }\r
742 Company.data.CustomStore = function(config) { ... }\r
743 </code></pre>\r
744      * @param {String} namespace1\r
745      * @param {String} namespace2\r
746      * @param {String} etc\r
747      * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)\r
748      * @method ns\r
749      */\r
750     Ext.ns = Ext.namespace;\r
751 })();\r
752 \r
753 Ext.ns("Ext", "Ext.util", "Ext.lib", "Ext.data");\r
754 \r
755 \r
756 <div id="cls-Function"></div>/**\r
757  * @class Function\r
758  * These functions are available on every Function object (any JavaScript function).\r
759  */\r
760 Ext.apply(Function.prototype, {\r
761      <div id="method-Function-createInterceptor"></div>/**\r
762      * Creates an interceptor function. The passed function is called before the original one. If it returns false,\r
763      * the original one is not called. The resulting function returns the results of the original function.\r
764      * The passed function is called with the parameters of the original function. Example usage:\r
765      * <pre><code>\r
766 var sayHi = function(name){\r
767     alert('Hi, ' + name);\r
768 }\r
769 \r
770 sayHi('Fred'); // alerts "Hi, Fred"\r
771 \r
772 // create a new function that validates input without\r
773 // directly modifying the original function:\r
774 var sayHiToFriend = sayHi.createInterceptor(function(name){\r
775     return name == 'Brian';\r
776 });\r
777 \r
778 sayHiToFriend('Fred');  // no alert\r
779 sayHiToFriend('Brian'); // alerts "Hi, Brian"\r
780 </code></pre>\r
781      * @param {Function} fcn The function to call before the original\r
782      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.\r
783      * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>\r
784      * @return {Function} The new function\r
785      */\r
786     createInterceptor : function(fcn, scope){\r
787         var method = this;\r
788         return !Ext.isFunction(fcn) ?\r
789                 this :\r
790                 function() {\r
791                     var me = this,\r
792                         args = arguments;\r
793                     fcn.target = me;\r
794                     fcn.method = method;\r
795                     return (fcn.apply(scope || me || window, args) !== false) ?\r
796                             method.apply(me || window, args) :\r
797                             null;\r
798                 };\r
799     },\r
800 \r
801      <div id="method-Function-createCallback"></div>/**\r
802      * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...\r
803      * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>\r
804      * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the\r
805      * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always\r
806      * executes in the window scope.\r
807      * <p>This method is required when you want to pass arguments to a callback function.  If no arguments\r
808      * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).\r
809      * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function\r
810      * would simply execute immediately when the code is parsed. Example usage:\r
811      * <pre><code>\r
812 var sayHi = function(name){\r
813     alert('Hi, ' + name);\r
814 }\r
815 \r
816 // clicking the button alerts "Hi, Fred"\r
817 new Ext.Button({\r
818     text: 'Say Hi',\r
819     renderTo: Ext.getBody(),\r
820     handler: sayHi.createCallback('Fred')\r
821 });\r
822 </code></pre>\r
823      * @return {Function} The new function\r
824     */\r
825     createCallback : function(/*args...*/){\r
826         // make args available, in function below\r
827         var args = arguments,\r
828             method = this;\r
829         return function() {\r
830             return method.apply(window, args);\r
831         };\r
832     },\r
833 \r
834     <div id="method-Function-createDelegate"></div>/**\r
835      * Creates a delegate (callback) that sets the scope to obj.\r
836      * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>\r
837      * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the\r
838      * callback points to obj. Example usage:\r
839      * <pre><code>\r
840 var sayHi = function(name){\r
841     // Note this use of "this.text" here.  This function expects to\r
842     // execute within a scope that contains a text property.  In this\r
843     // example, the "this" variable is pointing to the btn object that\r
844     // was passed in createDelegate below.\r
845     alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');\r
846 }\r
847 \r
848 var btn = new Ext.Button({\r
849     text: 'Say Hi',\r
850     renderTo: Ext.getBody()\r
851 });\r
852 \r
853 // This callback will execute in the scope of the\r
854 // button instance. Clicking the button alerts\r
855 // "Hi, Fred. You clicked the "Say Hi" button."\r
856 btn.on('click', sayHi.createDelegate(btn, ['Fred']));\r
857 </code></pre>\r
858      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.\r
859      * <b>If omitted, defaults to the browser window.</b>\r
860      * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\r
861      * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\r
862      * if a number the args are inserted at the specified position\r
863      * @return {Function} The new function\r
864      */\r
865     createDelegate : function(obj, args, appendArgs){\r
866         var method = this;\r
867         return function() {\r
868             var callArgs = args || arguments;\r
869             if (appendArgs === true){\r
870                 callArgs = Array.prototype.slice.call(arguments, 0);\r
871                 callArgs = callArgs.concat(args);\r
872             }else if (Ext.isNumber(appendArgs)){\r
873                 callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first\r
874                 var applyArgs = [appendArgs, 0].concat(args); // create method call params\r
875                 Array.prototype.splice.apply(callArgs, applyArgs); // splice them in\r
876             }\r
877             return method.apply(obj || window, callArgs);\r
878         };\r
879     },\r
880 \r
881     <div id="method-Function-defer"></div>/**\r
882      * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:\r
883      * <pre><code>\r
884 var sayHi = function(name){\r
885     alert('Hi, ' + name);\r
886 }\r
887 \r
888 // executes immediately:\r
889 sayHi('Fred');\r
890 \r
891 // executes after 2 seconds:\r
892 sayHi.defer(2000, this, ['Fred']);\r
893 \r
894 // this syntax is sometimes useful for deferring\r
895 // execution of an anonymous function:\r
896 (function(){\r
897     alert('Anonymous');\r
898 }).defer(100);\r
899 </code></pre>\r
900      * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)\r
901      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.\r
902      * <b>If omitted, defaults to the browser window.</b>\r
903      * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\r
904      * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\r
905      * if a number the args are inserted at the specified position\r
906      * @return {Number} The timeout id that can be used with clearTimeout\r
907      */\r
908     defer : function(millis, obj, args, appendArgs){\r
909         var fn = this.createDelegate(obj, args, appendArgs);\r
910         if(millis > 0){\r
911             return setTimeout(fn, millis);\r
912         }\r
913         fn();\r
914         return 0;\r
915     }\r
916 });\r
917 \r
918 <div id="cls-String"></div>/**\r
919  * @class String\r
920  * These functions are available on every String object.\r
921  */\r
922 Ext.applyIf(String, {\r
923     <div id="method-String-format"></div>/**\r
924      * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.  Each\r
925      * token must be unique, and must increment in the format {0}, {1}, etc.  Example usage:\r
926      * <pre><code>\r
927 var cls = 'my-class', text = 'Some text';\r
928 var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);\r
929 // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'\r
930      * </code></pre>\r
931      * @param {String} string The tokenized string to be formatted\r
932      * @param {String} value1 The value to replace token {0}\r
933      * @param {String} value2 Etc...\r
934      * @return {String} The formatted string\r
935      * @static\r
936      */\r
937     format : function(format){\r
938         var args = Ext.toArray(arguments, 1);\r
939         return format.replace(/\{(\d+)\}/g, function(m, i){\r
940             return args[i];\r
941         });\r
942     }\r
943 });\r
944 \r
945 <div id="cls-Array"></div>/**\r
946  * @class Array\r
947  */\r
948 Ext.applyIf(Array.prototype, {\r
949     <div id="method-Array-indexOf"></div>/**\r
950      * Checks whether or not the specified object exists in the array.\r
951      * @param {Object} o The object to check for\r
952      * @param {Number} from (Optional) The index at which to begin the search\r
953      * @return {Number} The index of o in the array (or -1 if it is not found)\r
954      */\r
955     indexOf : function(o, from){\r
956         var len = this.length;\r
957         from = from || 0;\r
958         from += (from < 0) ? len : 0;\r
959         for (; from < len; ++from){\r
960             if(this[from] === o){\r
961                 return from;\r
962             }\r
963         }\r
964         return -1;\r
965     },\r
966 \r
967     <div id="method-Array-remove"></div>/**\r
968      * Removes the specified object from the array.  If the object is not found nothing happens.\r
969      * @param {Object} o The object to remove\r
970      * @return {Array} this array\r
971      */\r
972     remove : function(o){\r
973         var index = this.indexOf(o);\r
974         if(index != -1){\r
975             this.splice(index, 1);\r
976         }\r
977         return this;\r
978     }\r
979 });\r
980 </pre>
981 </body>
982 </html>