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