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