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.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
16 window.undefined = window.undefined;
18 <div id="cls-Ext"></div>/**
20 * Ext core utilities and functions.
25 <div id="prop-Ext-version"></div>/**
26 * The version of the framework
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
45 Ext.apply = function(o, c, defaults){
46 // no "this" reference for friendly out of scope calls
48 Ext.apply(o, defaults);
50 if(o && c && typeof c == 'object'){
60 toString = Object.prototype.toString,
61 ua = navigator.userAgent.toLowerCase(),
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);
88 // remove css image flicker
91 DOC.execCommand("BackgroundImageCache", false, true);
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>).
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
107 <div id="prop-Ext-isSecure"></div>/**
108 * True if the page is running over SSL
112 <div id="prop-Ext-isReady"></div>/**
113 * True when the document is fully initialized and ready for action
118 <div id="prop-Ext-enableFx"></div>/**
119 * True if the {@link Ext.Fx} Class is available
124 <div id="prop-Ext-enableGarbageCollector"></div>/**
125 * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
128 enableGarbageCollector : true,
130 <div id="prop-Ext-enableListenerCollection"></div>/**
131 * True to automatically purge event listeners during garbageCollection (defaults to false).
134 enableListenerCollection : false,
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.
141 enableNestedListenerRemoval : false,
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)
150 USE_NATIVE_JSON : false,
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
158 applyIf : function(o, c){
161 if(!Ext.isDefined(o[p])){
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.
175 id : function(el, prefix){
176 el = Ext.getDom(el, true) || {};
178 el.id = (prefix || "ext-gen") + (++idSeed);
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:
188 MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
189 constructor: function(config) {
191 // Create configuration for this Grid.
192 var store = new Ext.data.Store({...});
193 var colModel = new Ext.grid.ColumnModel({...});
195 // Create a new config object containing our computed properties
196 // *plus* whatever was in the config parameter.
202 MyGridPanel.superclass.constructor.call(this, config);
204 // Your postprocessing here
207 yourMethod: function() {
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>
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.
234 var io = function(o){
239 var oc = Object.prototype.constructor;
241 return function(sb, sp, overrides){
242 if(typeof sp == 'object'){
245 sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
247 var F = function(){},
252 sbp = sb.prototype = new F();
255 if(spp.constructor == oc){
258 sb.override = function(o){
261 sbp.superclass = sbp.supr = (function(){
265 Ext.override(sb, overrides);
266 sb.extend = function(o){return Ext.extend(sb, o);};
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.
274 Ext.override(MyClass, {
275 newMethod1: function(){
278 newMethod2: function(foo){
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.
288 override : function(origclass, overrides){
290 var p = origclass.prototype;
291 Ext.apply(p, overrides);
292 if(Ext.isIE && overrides.hasOwnProperty('toString')){
293 p.toString = overrides.toString;
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:
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) { ... }
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)
313 namespace : function(){
315 Ext.each(arguments, function(v) {
317 o = window[d[0]] = window[d[0]] || {};
318 Ext.each(d.slice(1), function(v2){
319 o = o[v2] = o[v2] || {};
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.
328 * @param {String} pre (optional) A prefix to add to the url encoded string
331 urlEncode : function(o, pre){
334 e = encodeURIComponent;
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)) : '');
346 return pre + buf.join('');
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"]}
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
358 urlDecode : function(string, overwrite){
359 if(Ext.isEmpty(string)){
363 pairs = string.split('&'),
364 d = decodeURIComponent,
367 Ext.each(pairs, function(pair) {
368 pair = pair.split('=');
371 obj[name] = overwrite || !obj[name] ? value :
372 [].concat(obj[name]).concat(value);
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
384 urlAppend : function(url, s){
386 return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
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
398 toArray : function(){
400 function(a, i, j, res){
402 for(var x = 0, len = a.length; x < len; x++) {
405 return res.slice(i || 0, j || res.length);
408 return Array.prototype.slice.call(a, i || 0, j || a.length);
412 isIterable : function(v){
413 //check for array or arguments
414 if(Ext.isArray(v) || v.callee){
417 //check for node list type
418 if(/NodeList|HTMLCollection/.test(toString.call(v))){
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));
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>
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.
449 each : function(array, fn, scope){
450 if(Ext.isEmpty(array, true)){
453 if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
456 for(var i = 0, len = array.length; i < len; i++){
457 if(fn.call(scope || array[i], array[i], i, array) === false){
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>
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.
483 iterate : function(obj, fn, scope){
484 if(Ext.isEmpty(obj)){
487 if(Ext.isIterable(obj)){
488 Ext.each(obj, fn, scope);
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){
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:
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);
512 // If we don't know if we are working with an
513 // Ext.Element or a dom node use Ext.getDom
515 var dom = Ext.getDom(el);
516 // do something with the dom node
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.
522 * @return HTMLElement
524 getDom : function(el, strict){
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')) {
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
553 getBody : function(){
554 return Ext.get(DOC.body || DOC.documentElement);
557 <div id="prop-Ext-"></div>/**
558 * Removes a DOM node from the document.
560 <div id="method-Ext-removeNode"></div>/**
561 * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
562 * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
563 * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
564 * will be ignored if passed in.</p>
565 * @param {HTMLElement} node The node to remove
567 removeNode : isIE && !isIE8 ? function(){
570 if(n && n.tagName != 'BODY'){
571 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
572 d = d || DOC.createElement('div');
575 delete Ext.elCache[n.id];
579 if(n && n.parentNode && n.tagName != 'BODY'){
580 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
581 n.parentNode.removeChild(n);
582 delete Ext.elCache[n.id];
586 <div id="method-Ext-isEmpty"></div>/**
587 * <p>Returns true if the passed value is empty.</p>
588 * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
591 * <li>an empty array</li>
592 * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
594 * @param {Mixed} value The value to test
595 * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
598 isEmpty : function(v, allowBlank){
599 return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
602 <div id="method-Ext-isArray"></div>/**
603 * Returns true if the passed value is a JavaScript array, otherwise false.
604 * @param {Mixed} value The value to test
607 isArray : function(v){
608 return toString.apply(v) === '[object Array]';
611 <div id="method-Ext-isDate"></div>/**
612 * Returns true if the passed object is a JavaScript date object, otherwise false.
613 * @param {Object} object The object to test
616 isDate : function(v){
617 return toString.apply(v) === '[object Date]';
620 <div id="method-Ext-isObject"></div>/**
621 * Returns true if the passed value is a JavaScript Object, otherwise false.
622 * @param {Mixed} value The value to test
625 isObject : function(v){
626 return !!v && Object.prototype.toString.call(v) === '[object Object]';
629 <div id="method-Ext-isPrimitive"></div>/**
630 * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
631 * @param {Mixed} value The value to test
634 isPrimitive : function(v){
635 return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
638 <div id="method-Ext-isFunction"></div>/**
639 * Returns true if the passed value is a JavaScript Function, otherwise false.
640 * @param {Mixed} value The value to test
643 isFunction : function(v){
644 return toString.apply(v) === '[object Function]';
647 <div id="method-Ext-isNumber"></div>/**
648 * Returns true if the passed value is a number. Returns false for non-finite numbers.
649 * @param {Mixed} value The value to test
652 isNumber : function(v){
653 return typeof v === 'number' && isFinite(v);
656 <div id="method-Ext-isString"></div>/**
657 * Returns true if the passed value is a string.
658 * @param {Mixed} value The value to test
661 isString : function(v){
662 return typeof v === 'string';
665 <div id="method-Ext-isBoolean"></div>/**
666 * Returns true if the passed value is a boolean.
667 * @param {Mixed} value The value to test
670 isBoolean : function(v){
671 return typeof v === 'boolean';
674 <div id="method-Ext-isElement"></div>/**
675 * Returns true if the passed value is an HTMLElement
676 * @param {Mixed} value The value to test
679 isElement : function(v) {
680 return v ? !!v.tagName : false;
683 <div id="method-Ext-isDefined"></div>/**
684 * Returns true if the passed value is not undefined.
685 * @param {Mixed} value The value to test
688 isDefined : function(v){
689 return typeof v !== 'undefined';
692 <div id="prop-Ext-isOpera"></div>/**
693 * True if the detected browser is Opera.
697 <div id="prop-Ext-isWebKit"></div>/**
698 * True if the detected browser uses WebKit.
702 <div id="prop-Ext-isChrome"></div>/**
703 * True if the detected browser is Chrome.
707 <div id="prop-Ext-isSafari"></div>/**
708 * True if the detected browser is Safari.
712 <div id="prop-Ext-isSafari3"></div>/**
713 * True if the detected browser is Safari 3.x.
716 isSafari3 : isSafari3,
717 <div id="prop-Ext-isSafari4"></div>/**
718 * True if the detected browser is Safari 4.x.
721 isSafari4 : isSafari4,
722 <div id="prop-Ext-isSafari2"></div>/**
723 * True if the detected browser is Safari 2.x.
726 isSafari2 : isSafari2,
727 <div id="prop-Ext-isIE"></div>/**
728 * True if the detected browser is Internet Explorer.
732 <div id="prop-Ext-isIE6"></div>/**
733 * True if the detected browser is Internet Explorer 6.x.
737 <div id="prop-Ext-isIE7"></div>/**
738 * True if the detected browser is Internet Explorer 7.x.
742 <div id="prop-Ext-isIE8"></div>/**
743 * True if the detected browser is Internet Explorer 8.x.
747 <div id="prop-Ext-isGecko"></div>/**
748 * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
752 <div id="prop-Ext-isGecko2"></div>/**
753 * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
757 <div id="prop-Ext-isGecko3"></div>/**
758 * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
762 <div id="prop-Ext-isBorderBox"></div>/**
763 * True if the detected browser is Internet Explorer running in non-strict mode.
766 isBorderBox : isBorderBox,
767 <div id="prop-Ext-isLinux"></div>/**
768 * True if the detected platform is Linux.
772 <div id="prop-Ext-isWindows"></div>/**
773 * True if the detected platform is Windows.
776 isWindows : isWindows,
777 <div id="prop-Ext-isMac"></div>/**
778 * True if the detected platform is Mac OS.
782 <div id="prop-Ext-isAir"></div>/**
783 * True if the detected platform is Adobe Air.
789 <div id="method-Ext-ns"></div>/**
790 * Creates namespaces to be used for scoping variables and classes so that they are not global.
791 * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
793 Ext.namespace('Company', 'Company.data');
794 Ext.namespace('Company.data'); // equivalent and preferable to above syntax
795 Company.Widget = function() { ... }
796 Company.data.CustomStore = function(config) { ... }
798 * @param {String} namespace1
799 * @param {String} namespace2
800 * @param {String} etc
801 * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
804 Ext.ns = Ext.namespace;
807 Ext.ns("Ext.util", "Ext.lib", "Ext.data");
811 <div id="cls-Function"></div>/**
813 * These functions are available on every Function object (any JavaScript function).
815 Ext.apply(Function.prototype, {
816 <div id="method-Function-createInterceptor"></div>/**
817 * Creates an interceptor function. The passed function is called before the original one. If it returns false,
818 * the original one is not called. The resulting function returns the results of the original function.
819 * The passed function is called with the parameters of the original function. Example usage:
821 var sayHi = function(name){
822 alert('Hi, ' + name);
825 sayHi('Fred'); // alerts "Hi, Fred"
827 // create a new function that validates input without
828 // directly modifying the original function:
829 var sayHiToFriend = sayHi.createInterceptor(function(name){
830 return name == 'Brian';
833 sayHiToFriend('Fred'); // no alert
834 sayHiToFriend('Brian'); // alerts "Hi, Brian"
836 * @param {Function} fcn The function to call before the original
837 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
838 * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
839 * @return {Function} The new function
841 createInterceptor : function(fcn, scope){
843 return !Ext.isFunction(fcn) ?
850 return (fcn.apply(scope || me || window, args) !== false) ?
851 method.apply(me || window, args) :
856 <div id="method-Function-createCallback"></div>/**
857 * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
858 * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
859 * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
860 * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
861 * executes in the window scope.
862 * <p>This method is required when you want to pass arguments to a callback function. If no arguments
863 * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
864 * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
865 * would simply execute immediately when the code is parsed. Example usage:
867 var sayHi = function(name){
868 alert('Hi, ' + name);
871 // clicking the button alerts "Hi, Fred"
874 renderTo: Ext.getBody(),
875 handler: sayHi.createCallback('Fred')
878 * @return {Function} The new function
880 createCallback : function(/*args...*/){
881 // make args available, in function below
882 var args = arguments,
885 return method.apply(window, args);
889 <div id="method-Function-createDelegate"></div>/**
890 * Creates a delegate (callback) that sets the scope to obj.
891 * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
892 * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
893 * callback points to obj. Example usage:
895 var sayHi = function(name){
896 // Note this use of "this.text" here. This function expects to
897 // execute within a scope that contains a text property. In this
898 // example, the "this" variable is pointing to the btn object that
899 // was passed in createDelegate below.
900 alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
903 var btn = new Ext.Button({
905 renderTo: Ext.getBody()
908 // This callback will execute in the scope of the
909 // button instance. Clicking the button alerts
910 // "Hi, Fred. You clicked the "Say Hi" button."
911 btn.on('click', sayHi.createDelegate(btn, ['Fred']));
913 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
914 * <b>If omitted, defaults to the browser window.</b>
915 * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
916 * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
917 * if a number the args are inserted at the specified position
918 * @return {Function} The new function
920 createDelegate : function(obj, args, appendArgs){
923 var callArgs = args || arguments;
924 if (appendArgs === true){
925 callArgs = Array.prototype.slice.call(arguments, 0);
926 callArgs = callArgs.concat(args);
927 }else if (Ext.isNumber(appendArgs)){
928 callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
929 var applyArgs = [appendArgs, 0].concat(args); // create method call params
930 Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
932 return method.apply(obj || window, callArgs);
936 <div id="method-Function-defer"></div>/**
937 * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
939 var sayHi = function(name){
940 alert('Hi, ' + name);
943 // executes immediately:
946 // executes after 2 seconds:
947 sayHi.defer(2000, this, ['Fred']);
949 // this syntax is sometimes useful for deferring
950 // execution of an anonymous function:
955 * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
956 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
957 * <b>If omitted, defaults to the browser window.</b>
958 * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
959 * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
960 * if a number the args are inserted at the specified position
961 * @return {Number} The timeout id that can be used with clearTimeout
963 defer : function(millis, obj, args, appendArgs){
964 var fn = this.createDelegate(obj, args, appendArgs);
966 return setTimeout(fn, millis);
973 <div id="cls-String"></div>/**
975 * These functions are available on every String object.
977 Ext.applyIf(String, {
978 <div id="method-String-format"></div>/**
979 * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
980 * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
982 var cls = 'my-class', text = 'Some text';
983 var s = String.format('<div class="{0}">{1}</div>', cls, text);
984 // s now contains the string: '<div class="my-class">Some text</div>'
986 * @param {String} string The tokenized string to be formatted
987 * @param {String} value1 The value to replace token {0}
988 * @param {String} value2 Etc...
989 * @return {String} The formatted string
992 format : function(format){
993 var args = Ext.toArray(arguments, 1);
994 return format.replace(/\{(\d+)\}/g, function(m, i){
1000 <div id="cls-Array"></div>/**
1003 Ext.applyIf(Array.prototype, {
1004 <div id="method-Array-indexOf"></div>/**
1005 * Checks whether or not the specified object exists in the array.
1006 * @param {Object} o The object to check for
1007 * @param {Number} from (Optional) The index at which to begin the search
1008 * @return {Number} The index of o in the array (or -1 if it is not found)
1010 indexOf : function(o, from){
1011 var len = this.length;
1013 from += (from < 0) ? len : 0;
1014 for (; from < len; ++from){
1015 if(this[from] === o){
1022 <div id="method-Array-remove"></div>/**
1023 * Removes the specified object from the array. If the object is not found nothing happens.
1024 * @param {Object} o The object to remove
1025 * @return {Array} this array
1027 remove : function(o){
1028 var index = this.indexOf(o);
1030 this.splice(index, 1);