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>
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.
13 * http://www.extjs.com/license
17 window.undefined = window.undefined;
19 <div id="cls-Ext"></div>/**
21 * Ext core utilities and functions.
26 <div id="prop-Ext-version"></div>/**
27 * The version of the framework
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
41 Ext.apply = function(o, c, defaults){
42 // no "this" reference for friendly out of scope calls
44 Ext.apply(o, defaults);
46 if(o && c && typeof c == 'object'){
56 toString = Object.prototype.toString,
57 ua = navigator.userAgent.toLowerCase(),
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);
84 // remove css image flicker
87 DOC.execCommand("BackgroundImageCache", false, true);
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>).
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
103 <div id="prop-Ext-isSecure"></div>/**
104 * True if the page is running over SSL
108 <div id="prop-Ext-isReady"></div>/**
109 * True when the document is fully initialized and ready for action
114 <div id="prop-Ext-enableFx"></div>/**
115 * True if the {@link Ext.Fx} Class is available
120 <div id="prop-Ext-enableGarbageCollector"></div>/**
121 * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
124 enableGarbageCollector : true,
126 <div id="prop-Ext-enableListenerCollection"></div>/**
127 * True to automatically purge event listeners during garbageCollection (defaults to false).
130 enableListenerCollection : false,
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.
137 enableNestedListenerRemoval : false,
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)
146 USE_NATIVE_JSON : false,
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
154 applyIf : function(o, c){
157 if(!Ext.isDefined(o[p])){
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.
171 id : function(el, prefix){
172 el = Ext.getDom(el, true) || {};
174 el.id = (prefix || "ext-gen") + (++idSeed);
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:
184 MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
185 constructor: function(config) {
187 // Create configuration for this Grid.
188 var store = new Ext.data.Store({...});
189 var colModel = new Ext.grid.ColumnModel({...});
191 // Create a new config object containing our computed properties
192 // *plus* whatever was in the config parameter.
198 MyGridPanel.superclass.constructor.call(this, config);
200 // Your postprocessing here
203 yourMethod: function() {
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>
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.
230 var io = function(o){
235 var oc = Object.prototype.constructor;
237 return function(sb, sp, overrides){
238 if(Ext.isObject(sp)){
241 sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
243 var F = function(){},
248 sbp = sb.prototype = new F();
251 if(spp.constructor == oc){
254 sb.override = function(o){
257 sbp.superclass = sbp.supr = (function(){
261 Ext.override(sb, overrides);
262 sb.extend = function(o){return Ext.extend(sb, o);};
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.
270 Ext.override(MyClass, {
271 newMethod1: function(){
274 newMethod2: function(foo){
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.
284 override : function(origclass, overrides){
286 var p = origclass.prototype;
287 Ext.apply(p, overrides);
288 if(Ext.isIE && overrides.hasOwnProperty('toString')){
289 p.toString = overrides.toString;
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:
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) { ... }
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)
309 namespace : function(){
311 Ext.each(arguments, function(v) {
313 o = window[d[0]] = window[d[0]] || {};
314 Ext.each(d.slice(1), function(v2){
315 o = o[v2] = o[v2] || {};
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.
324 * @param {String} pre (optional) A prefix to add to the url encoded string
327 urlEncode : function(o, pre){
330 e = encodeURIComponent;
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)) : '');
342 return pre + buf.join('');
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"]}
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
354 urlDecode : function(string, overwrite){
355 if(Ext.isEmpty(string)){
359 pairs = string.split('&'),
360 d = decodeURIComponent,
363 Ext.each(pairs, function(pair) {
364 pair = pair.split('=');
367 obj[name] = overwrite || !obj[name] ? value :
368 [].concat(obj[name]).concat(value);
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
380 urlAppend : function(url, s){
382 return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
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
394 toArray : function(){
396 function(a, i, j, res){
398 for(var x = 0, len = a.length; x < len; x++) {
401 return res.slice(i || 0, j || res.length);
404 return Array.prototype.slice.call(a, i || 0, j || a.length);
408 isIterable : function(v){
409 //check for array or arguments
410 if(Ext.isArray(v) || v.callee){
413 //check for node list type
414 if(/NodeList|HTMLCollection/.test(toString.call(v))){
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));
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>
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.
445 each : function(array, fn, scope){
446 if(Ext.isEmpty(array, true)){
449 if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
452 for(var i = 0, len = array.length; i < len; i++){
453 if(fn.call(scope || array[i], array[i], i, array) === false){
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>
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.
479 iterate : function(obj, fn, scope){
480 if(Ext.isEmpty(obj)){
483 if(Ext.isIterable(obj)){
484 Ext.each(obj, fn, scope);
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){
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:
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);
508 // If we don't know if we are working with an
509 // Ext.Element or a dom node use Ext.getDom
511 var dom = Ext.getDom(el);
512 // do something with the dom node
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.
518 * @return HTMLElement
520 getDom : function(el, strict){
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')) {
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
549 getBody : function(){
550 return Ext.get(DOC.body || DOC.documentElement);
553 <div id="prop-Ext-"></div>/**
554 * Removes a DOM node from the document.
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
563 removeNode : isIE && !isIE8 ? function(){
566 if(n && n.tagName != 'BODY'){
567 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
568 d = d || DOC.createElement('div');
571 delete Ext.elCache[n.id];
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];
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>
587 * <li>an empty array</li>
588 * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
590 * @param {Mixed} value The value to test
591 * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
594 isEmpty : function(v, allowBlank){
595 return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
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
603 isArray : function(v){
604 return toString.apply(v) === '[object Array]';
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
612 isDate : function(v){
613 return toString.apply(v) === '[object Date]';
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
621 isObject : function(v){
622 return !!v && Object.prototype.toString.call(v) === '[object Object]';
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
630 isPrimitive : function(v){
631 return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
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
639 isFunction : function(v){
640 return toString.apply(v) === '[object Function]';
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
648 isNumber : function(v){
649 return typeof v === 'number' && isFinite(v);
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
657 isString : function(v){
658 return typeof v === 'string';
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
666 isBoolean : function(v){
667 return typeof v === 'boolean';
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
675 isElement : function(v) {
676 return v ? !!v.tagName : false;
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
684 isDefined : function(v){
685 return typeof v !== 'undefined';
688 <div id="prop-Ext-isOpera"></div>/**
689 * True if the detected browser is Opera.
693 <div id="prop-Ext-isWebKit"></div>/**
694 * True if the detected browser uses WebKit.
698 <div id="prop-Ext-isChrome"></div>/**
699 * True if the detected browser is Chrome.
703 <div id="prop-Ext-isSafari"></div>/**
704 * True if the detected browser is Safari.
708 <div id="prop-Ext-isSafari3"></div>/**
709 * True if the detected browser is Safari 3.x.
712 isSafari3 : isSafari3,
713 <div id="prop-Ext-isSafari4"></div>/**
714 * True if the detected browser is Safari 4.x.
717 isSafari4 : isSafari4,
718 <div id="prop-Ext-isSafari2"></div>/**
719 * True if the detected browser is Safari 2.x.
722 isSafari2 : isSafari2,
723 <div id="prop-Ext-isIE"></div>/**
724 * True if the detected browser is Internet Explorer.
728 <div id="prop-Ext-isIE6"></div>/**
729 * True if the detected browser is Internet Explorer 6.x.
733 <div id="prop-Ext-isIE7"></div>/**
734 * True if the detected browser is Internet Explorer 7.x.
738 <div id="prop-Ext-isIE8"></div>/**
739 * True if the detected browser is Internet Explorer 8.x.
743 <div id="prop-Ext-isGecko"></div>/**
744 * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
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).
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).
758 <div id="prop-Ext-isBorderBox"></div>/**
759 * True if the detected browser is Internet Explorer running in non-strict mode.
762 isBorderBox : isBorderBox,
763 <div id="prop-Ext-isLinux"></div>/**
764 * True if the detected platform is Linux.
768 <div id="prop-Ext-isWindows"></div>/**
769 * True if the detected platform is Windows.
772 isWindows : isWindows,
773 <div id="prop-Ext-isMac"></div>/**
774 * True if the detected platform is Mac OS.
778 <div id="prop-Ext-isAir"></div>/**
779 * True if the detected platform is Adobe Air.
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:
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) { ... }
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)
800 Ext.ns = Ext.namespace;
803 Ext.ns("Ext.util", "Ext.lib", "Ext.data");
807 <div id="cls-Function"></div>/**
809 * These functions are available on every Function object (any JavaScript function).
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:
817 var sayHi = function(name){
818 alert('Hi, ' + name);
821 sayHi('Fred'); // alerts "Hi, Fred"
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';
829 sayHiToFriend('Fred'); // no alert
830 sayHiToFriend('Brian'); // alerts "Hi, Brian"
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
837 createInterceptor : function(fcn, scope){
839 return !Ext.isFunction(fcn) ?
846 return (fcn.apply(scope || me || window, args) !== false) ?
847 method.apply(me || window, args) :
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:
863 var sayHi = function(name){
864 alert('Hi, ' + name);
867 // clicking the button alerts "Hi, Fred"
870 renderTo: Ext.getBody(),
871 handler: sayHi.createCallback('Fred')
874 * @return {Function} The new function
876 createCallback : function(/*args...*/){
877 // make args available, in function below
878 var args = arguments,
881 return method.apply(window, args);
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:
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.');
899 var btn = new Ext.Button({
901 renderTo: Ext.getBody()
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']));
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
916 createDelegate : function(obj, args, appendArgs){
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
928 return method.apply(obj || window, callArgs);
932 <div id="method-Function-defer"></div>/**
933 * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
935 var sayHi = function(name){
936 alert('Hi, ' + name);
939 // executes immediately:
942 // executes after 2 seconds:
943 sayHi.defer(2000, this, ['Fred']);
945 // this syntax is sometimes useful for deferring
946 // execution of an anonymous function:
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
959 defer : function(millis, obj, args, appendArgs){
960 var fn = this.createDelegate(obj, args, appendArgs);
962 return setTimeout(fn, millis);
969 <div id="cls-String"></div>/**
971 * These functions are available on every String object.
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:
978 var cls = 'my-class', text = 'Some text';
979 var s = String.format('<div class="{0}">{1}</div>', cls, text);
980 // s now contains the string: '<div class="my-class">Some text</div>'
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
988 format : function(format){
989 var args = Ext.toArray(arguments, 1);
990 return format.replace(/\{(\d+)\}/g, function(m, i){
996 <div id="cls-Array"></div>/**
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)
1006 indexOf : function(o, from){
1007 var len = this.length;
1009 from += (from < 0) ? len : 0;
1010 for (; from < len; ++from){
1011 if(this[from] === o){
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
1023 remove : function(o){
1024 var index = this.indexOf(o);
1026 this.splice(index, 1);