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