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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.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 docMode = DOC.documentMode,
67 isStrict = DOC.compatMode == "CSS1Compat",
68 isOpera = check(/opera/),
69 isChrome = check(/\bchrome\b/),
70 isWebKit = check(/webkit/),
71 isSafari = !isChrome && check(/safari/),
72 isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
73 isSafari3 = isSafari && check(/version\/3/),
74 isSafari4 = isSafari && check(/version\/4/),
75 isIE = !isOpera && check(/msie/),
76 isIE7 = isIE && (check(/msie 7/) || docMode == 7),
77 isIE8 = isIE && (check(/msie 8/) && docMode != 7),
78 isIE6 = isIE && !isIE7 && !isIE8,
79 isGecko = !isWebKit && check(/gecko/),
80 isGecko2 = isGecko && check(/rv:1\.8/),
81 isGecko3 = isGecko && check(/rv:1\.9/),
82 isBorderBox = isIE && !isStrict,
83 isWindows = check(/windows|win32/),
84 isMac = check(/macintosh|mac os x/),
85 isAir = check(/adobeair/),
86 isLinux = check(/linux/),
87 isSecure = /^https/i.test(window.location.protocol);
89 // remove css image flicker
92 DOC.execCommand("BackgroundImageCache", false, true);
97 <div id="prop-Ext-SSL_SECURE_URL"></div>/**
98 * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
99 * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
102 SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
103 <div id="prop-Ext-isStrict"></div>/**
104 * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
108 <div id="prop-Ext-isSecure"></div>/**
109 * True if the page is running over SSL
113 <div id="prop-Ext-isReady"></div>/**
114 * True when the document is fully initialized and ready for action
119 <div id="prop-Ext-enableFx"></div>/**
120 * True if the {@link Ext.Fx} Class is available
125 <div id="prop-Ext-enableForcedBoxModel"></div>/**
126 * HIGHLY EXPERIMENTAL
127 * True to force css based border-box model override and turning off javascript based adjustments. This is a
128 * runtime configuration and must be set before onReady.
131 enableForcedBoxModel : false,
133 <div id="prop-Ext-enableGarbageCollector"></div>/**
134 * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
137 enableGarbageCollector : true,
139 <div id="prop-Ext-enableListenerCollection"></div>/**
140 * True to automatically purge event listeners during garbageCollection (defaults to false).
143 enableListenerCollection : false,
145 <div id="prop-Ext-enableNestedListenerRemoval"></div>/**
146 * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
147 * Currently not optimized for performance.
150 enableNestedListenerRemoval : false,
152 <div id="prop-Ext-USE_NATIVE_JSON"></div>/**
153 * Indicates whether to use native browser parsing for JSON methods.
154 * This option is ignored if the browser does not support native JSON methods.
155 * <b>Note: Native JSON methods will not work with objects that have functions.
156 * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
159 USE_NATIVE_JSON : false,
161 <div id="method-Ext-applyIf"></div>/**
162 * Copies all the properties of config to obj if they don't already exist.
163 * @param {Object} obj The receiver of the properties
164 * @param {Object} config The source of the properties
165 * @return {Object} returns obj
167 applyIf : function(o, c){
170 if(!Ext.isDefined(o[p])){
178 <div id="method-Ext-id"></div>/**
179 * Generates unique ids. If the element already has an id, it is unchanged
180 * @param {Mixed} el (optional) The element to generate an id for
181 * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
182 * @return {String} The generated Id.
184 id : function(el, prefix){
185 el = Ext.getDom(el, true) || {};
187 el.id = (prefix || "ext-gen") + (++idSeed);
192 <div id="method-Ext-extend"></div>/**
193 * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
194 * also adds the function "override()" to the subclass that can be used to override members of the class.</p>
195 * For example, to create a subclass of Ext GridPanel:
197 MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
198 constructor: function(config) {
200 // Create configuration for this Grid.
201 var store = new Ext.data.Store({...});
202 var colModel = new Ext.grid.ColumnModel({...});
204 // Create a new config object containing our computed properties
205 // *plus* whatever was in the config parameter.
211 MyGridPanel.superclass.constructor.call(this, config);
213 // Your postprocessing here
216 yourMethod: function() {
222 * <p>This function also supports a 3-argument call in which the subclass's constructor is
223 * passed as an argument. In this form, the parameters are as follows:</p>
224 * <div class="mdetail-params"><ul>
225 * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
226 * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
227 * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
228 * prototype, and are therefore shared among all instances of the new class.</div></li>
231 * @param {Function} superclass The constructor of class being extended.
232 * @param {Object} overrides <p>A literal with members which are copied into the subclass's
233 * prototype, and are therefore shared between all instances of the new class.</p>
234 * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
235 * to define the constructor of the new class, and is returned. If this property is
236 * <i>not</i> specified, a constructor is generated and returned which just calls the
237 * superclass's constructor passing on its parameters.</p>
238 * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
239 * @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
243 var io = function(o){
248 var oc = Object.prototype.constructor;
250 return function(sb, sp, overrides){
251 if(typeof sp == 'object'){
254 sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
256 var F = function(){},
261 sbp = sb.prototype = new F();
264 if(spp.constructor == oc){
267 sb.override = function(o){
270 sbp.superclass = sbp.supr = (function(){
274 Ext.override(sb, overrides);
275 sb.extend = function(o){return Ext.extend(sb, o);};
280 <div id="method-Ext-override"></div>/**
281 * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
283 Ext.override(MyClass, {
284 newMethod1: function(){
287 newMethod2: function(foo){
292 * @param {Object} origclass The class to override
293 * @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
294 * containing one or more methods.
297 override : function(origclass, overrides){
299 var p = origclass.prototype;
300 Ext.apply(p, overrides);
301 if(Ext.isIE && overrides.hasOwnProperty('toString')){
302 p.toString = overrides.toString;
307 <div id="method-Ext-namespace"></div>/**
308 * Creates namespaces to be used for scoping variables and classes so that they are not global.
309 * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
311 Ext.namespace('Company', 'Company.data');
312 Ext.namespace('Company.data'); // equivalent and preferable to above syntax
313 Company.Widget = function() { ... }
314 Company.data.CustomStore = function(config) { ... }
316 * @param {String} namespace1
317 * @param {String} namespace2
318 * @param {String} etc
319 * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
322 namespace : function(){
324 Ext.each(arguments, function(v) {
326 o = window[d[0]] = window[d[0]] || {};
327 Ext.each(d.slice(1), function(v2){
328 o = o[v2] = o[v2] || {};
334 <div id="method-Ext-urlEncode"></div>/**
335 * 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.
337 * @param {String} pre (optional) A prefix to add to the url encoded string
340 urlEncode : function(o, pre){
343 e = encodeURIComponent;
345 Ext.iterate(o, function(key, item){
346 empty = Ext.isEmpty(item);
347 Ext.each(empty ? key : item, function(val){
348 buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
355 return pre + buf.join('');
358 <div id="method-Ext-urlDecode"></div>/**
359 * Takes an encoded URL and and converts it to an object. Example: <pre><code>
360 Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
361 Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
363 * @param {String} string
364 * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
365 * @return {Object} A literal with members
367 urlDecode : function(string, overwrite){
368 if(Ext.isEmpty(string)){
372 pairs = string.split('&'),
373 d = decodeURIComponent,
376 Ext.each(pairs, function(pair) {
377 pair = pair.split('=');
380 obj[name] = overwrite || !obj[name] ? value :
381 [].concat(obj[name]).concat(value);
386 <div id="method-Ext-urlAppend"></div>/**
387 * Appends content to the query string of a URL, handling logic for whether to place
388 * a question mark or ampersand.
389 * @param {String} url The URL to append to.
390 * @param {String} s The content to append to the URL.
391 * @return (String) The resulting URL
393 urlAppend : function(url, s){
395 return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
400 <div id="method-Ext-toArray"></div>/**
401 * Converts any iterable (numeric indices and a length property) into a true array
402 * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
403 * For strings, use this instead: "abc".match(/./g) => [a,b,c];
404 * @param {Iterable} the iterable object to be turned into a true Array.
405 * @return (Array) array
407 toArray : function(){
409 function(a, i, j, res){
411 for(var x = 0, len = a.length; x < len; x++) {
414 return res.slice(i || 0, j || res.length);
417 return Array.prototype.slice.call(a, i || 0, j || a.length);
421 isIterable : function(v){
422 //check for array or arguments
423 if(Ext.isArray(v) || v.callee){
426 //check for node list type
427 if(/NodeList|HTMLCollection/.test(toString.call(v))){
430 //NodeList has an item and length property
431 //IXMLDOMNodeList has nextNode method, needs to be checked first.
432 return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
435 <div id="method-Ext-each"></div>/**
436 * Iterates an array calling the supplied function.
437 * @param {Array/NodeList/Mixed} array The array to be iterated. If this
438 * argument is not really an array, the supplied function is called once.
439 * @param {Function} fn The function to be called with each item. If the
440 * supplied function returns false, iteration stops and this method returns
441 * the current <code>index</code>. This function is called with
442 * the following arguments:
443 * <div class="mdetail-params"><ul>
444 * <li><code>item</code> : <i>Mixed</i>
445 * <div class="sub-desc">The item at the current <code>index</code>
446 * in the passed <code>array</code></div></li>
447 * <li><code>index</code> : <i>Number</i>
448 * <div class="sub-desc">The current index within the array</div></li>
449 * <li><code>allItems</code> : <i>Array</i>
450 * <div class="sub-desc">The <code>array</code> passed as the first
451 * argument to <code>Ext.each</code>.</div></li>
453 * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
454 * Defaults to the <code>item</code> at the current <code>index</code>
455 * within the passed <code>array</code>.
456 * @return See description for the fn parameter.
458 each : function(array, fn, scope){
459 if(Ext.isEmpty(array, true)){
462 if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
465 for(var i = 0, len = array.length; i < len; i++){
466 if(fn.call(scope || array[i], array[i], i, array) === false){
472 <div id="method-Ext-iterate"></div>/**
473 * Iterates either the elements in an array, or each of the properties in an object.
474 * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
475 * @param {Object/Array} object The object or array to be iterated
476 * @param {Function} fn The function to be called for each iteration.
477 * The iteration will stop if the supplied function returns false, or
478 * all array elements / object properties have been covered. The signature
479 * varies depending on the type of object being interated:
480 * <div class="mdetail-params"><ul>
481 * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
482 * <div class="sub-desc">
483 * When iterating an array, the supplied function is called with each item.</div></li>
484 * <li>Objects : <tt>(String key, Object value, Object)</tt>
485 * <div class="sub-desc">
486 * When iterating an object, the supplied function is called with each key-value pair in
487 * the object, and the iterated object</div></li>
489 * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
490 * the <code>object</code> being iterated.
492 iterate : function(obj, fn, scope){
493 if(Ext.isEmpty(obj)){
496 if(Ext.isIterable(obj)){
497 Ext.each(obj, fn, scope);
499 }else if(typeof obj == 'object'){
500 for(var prop in obj){
501 if(obj.hasOwnProperty(prop)){
502 if(fn.call(scope || obj, prop, obj[prop], obj) === false){
510 <div id="method-Ext-getDom"></div>/**
511 * Return the dom node for the passed String (id), dom node, or Ext.Element.
512 * Optional 'strict' flag is needed for IE since it can return 'name' and
513 * 'id' elements by using getElementById.
514 * Here are some examples:
516 // gets dom node based on id
517 var elDom = Ext.getDom('elId');
518 // gets dom node based on the dom node
519 var elDom1 = Ext.getDom(elDom);
521 // If we don't know if we are working with an
522 // Ext.Element or a dom node use Ext.getDom
524 var dom = Ext.getDom(el);
525 // do something with the dom node
528 * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
529 * when this method is called to be successful.
531 * @return HTMLElement
533 getDom : function(el, strict){
540 if (typeof el == 'string') {
541 var e = DOC.getElementById(el);
542 // IE returns elements with the 'name' and 'id' attribute.
543 // we do a strict check to return the element with only the id attribute
544 if (e && isIE && strict) {
545 if (el == e.getAttribute('id')) {
558 <div id="method-Ext-getBody"></div>/**
559 * Returns the current document body as an {@link Ext.Element}.
560 * @return Ext.Element The document body
562 getBody : function(){
563 return Ext.get(DOC.body || DOC.documentElement);
566 <div id="method-Ext-getHead"></div>/**
567 * Returns the current document body as an {@link Ext.Element}.
568 * @return Ext.Element The document body
570 getHead : function() {
574 if (head == undefined) {
575 head = Ext.get(DOC.getElementsByTagName("head")[0]);
582 <div id="prop-Ext-"></div>/**
583 * Removes a DOM node from the document.
585 <div id="method-Ext-removeNode"></div>/**
586 * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
587 * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
588 * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
589 * will be ignored if passed in.</p>
590 * @param {HTMLElement} node The node to remove
592 removeNode : isIE && !isIE8 ? function(){
595 if(n && n.tagName != 'BODY'){
596 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
597 d = d || DOC.createElement('div');
600 delete Ext.elCache[n.id];
604 if(n && n.parentNode && n.tagName != 'BODY'){
605 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
606 n.parentNode.removeChild(n);
607 delete Ext.elCache[n.id];
611 <div id="method-Ext-isEmpty"></div>/**
612 * <p>Returns true if the passed value is empty.</p>
613 * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
616 * <li>an empty array</li>
617 * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
619 * @param {Mixed} value The value to test
620 * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
623 isEmpty : function(v, allowBlank){
624 return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
627 <div id="method-Ext-isArray"></div>/**
628 * Returns true if the passed value is a JavaScript array, otherwise false.
629 * @param {Mixed} value The value to test
632 isArray : function(v){
633 return toString.apply(v) === '[object Array]';
636 <div id="method-Ext-isDate"></div>/**
637 * Returns true if the passed object is a JavaScript date object, otherwise false.
638 * @param {Object} object The object to test
641 isDate : function(v){
642 return toString.apply(v) === '[object Date]';
645 <div id="method-Ext-isObject"></div>/**
646 * Returns true if the passed value is a JavaScript Object, otherwise false.
647 * @param {Mixed} value The value to test
650 isObject : function(v){
651 return !!v && Object.prototype.toString.call(v) === '[object Object]';
654 <div id="method-Ext-isPrimitive"></div>/**
655 * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
656 * @param {Mixed} value The value to test
659 isPrimitive : function(v){
660 return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
663 <div id="method-Ext-isFunction"></div>/**
664 * Returns true if the passed value is a JavaScript Function, otherwise false.
665 * @param {Mixed} value The value to test
668 isFunction : function(v){
669 return toString.apply(v) === '[object Function]';
672 <div id="method-Ext-isNumber"></div>/**
673 * Returns true if the passed value is a number. Returns false for non-finite numbers.
674 * @param {Mixed} value The value to test
677 isNumber : function(v){
678 return typeof v === 'number' && isFinite(v);
681 <div id="method-Ext-isString"></div>/**
682 * Returns true if the passed value is a string.
683 * @param {Mixed} value The value to test
686 isString : function(v){
687 return typeof v === 'string';
690 <div id="method-Ext-isBoolean"></div>/**
691 * Returns true if the passed value is a boolean.
692 * @param {Mixed} value The value to test
695 isBoolean : function(v){
696 return typeof v === 'boolean';
699 <div id="method-Ext-isElement"></div>/**
700 * Returns true if the passed value is an HTMLElement
701 * @param {Mixed} value The value to test
704 isElement : function(v) {
705 return v ? !!v.tagName : false;
708 <div id="method-Ext-isDefined"></div>/**
709 * Returns true if the passed value is not undefined.
710 * @param {Mixed} value The value to test
713 isDefined : function(v){
714 return typeof v !== 'undefined';
717 <div id="prop-Ext-isOpera"></div>/**
718 * True if the detected browser is Opera.
722 <div id="prop-Ext-isWebKit"></div>/**
723 * True if the detected browser uses WebKit.
727 <div id="prop-Ext-isChrome"></div>/**
728 * True if the detected browser is Chrome.
732 <div id="prop-Ext-isSafari"></div>/**
733 * True if the detected browser is Safari.
737 <div id="prop-Ext-isSafari3"></div>/**
738 * True if the detected browser is Safari 3.x.
741 isSafari3 : isSafari3,
742 <div id="prop-Ext-isSafari4"></div>/**
743 * True if the detected browser is Safari 4.x.
746 isSafari4 : isSafari4,
747 <div id="prop-Ext-isSafari2"></div>/**
748 * True if the detected browser is Safari 2.x.
751 isSafari2 : isSafari2,
752 <div id="prop-Ext-isIE"></div>/**
753 * True if the detected browser is Internet Explorer.
757 <div id="prop-Ext-isIE6"></div>/**
758 * True if the detected browser is Internet Explorer 6.x.
762 <div id="prop-Ext-isIE7"></div>/**
763 * True if the detected browser is Internet Explorer 7.x.
767 <div id="prop-Ext-isIE8"></div>/**
768 * True if the detected browser is Internet Explorer 8.x.
772 <div id="prop-Ext-isGecko"></div>/**
773 * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
777 <div id="prop-Ext-isGecko2"></div>/**
778 * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
782 <div id="prop-Ext-isGecko3"></div>/**
783 * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
787 <div id="prop-Ext-isBorderBox"></div>/**
788 * True if the detected browser is Internet Explorer running in non-strict mode.
791 isBorderBox : isBorderBox,
792 <div id="prop-Ext-isLinux"></div>/**
793 * True if the detected platform is Linux.
797 <div id="prop-Ext-isWindows"></div>/**
798 * True if the detected platform is Windows.
801 isWindows : isWindows,
802 <div id="prop-Ext-isMac"></div>/**
803 * True if the detected platform is Mac OS.
807 <div id="prop-Ext-isAir"></div>/**
808 * True if the detected platform is Adobe Air.
814 <div id="method-Ext-ns"></div>/**
815 * Creates namespaces to be used for scoping variables and classes so that they are not global.
816 * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
818 Ext.namespace('Company', 'Company.data');
819 Ext.namespace('Company.data'); // equivalent and preferable to above syntax
820 Company.Widget = function() { ... }
821 Company.data.CustomStore = function(config) { ... }
823 * @param {String} namespace1
824 * @param {String} namespace2
825 * @param {String} etc
826 * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
829 Ext.ns = Ext.namespace;
832 Ext.ns('Ext.util', 'Ext.lib', 'Ext.data', 'Ext.supports');
836 <div id="cls-Function"></div>/**
838 * These functions are available on every Function object (any JavaScript function).
840 Ext.apply(Function.prototype, {
841 <div id="method-Function-createInterceptor"></div>/**
842 * Creates an interceptor function. The passed function is called before the original one. If it returns false,
843 * the original one is not called. The resulting function returns the results of the original function.
844 * The passed function is called with the parameters of the original function. Example usage:
846 var sayHi = function(name){
847 alert('Hi, ' + name);
850 sayHi('Fred'); // alerts "Hi, Fred"
852 // create a new function that validates input without
853 // directly modifying the original function:
854 var sayHiToFriend = sayHi.createInterceptor(function(name){
855 return name == 'Brian';
858 sayHiToFriend('Fred'); // no alert
859 sayHiToFriend('Brian'); // alerts "Hi, Brian"
861 * @param {Function} fcn The function to call before the original
862 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
863 * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
864 * @return {Function} The new function
866 createInterceptor : function(fcn, scope){
868 return !Ext.isFunction(fcn) ?
875 return (fcn.apply(scope || me || window, args) !== false) ?
876 method.apply(me || window, args) :
881 <div id="method-Function-createCallback"></div>/**
882 * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
883 * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
884 * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
885 * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
886 * executes in the window scope.
887 * <p>This method is required when you want to pass arguments to a callback function. If no arguments
888 * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
889 * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
890 * would simply execute immediately when the code is parsed. Example usage:
892 var sayHi = function(name){
893 alert('Hi, ' + name);
896 // clicking the button alerts "Hi, Fred"
899 renderTo: Ext.getBody(),
900 handler: sayHi.createCallback('Fred')
903 * @return {Function} The new function
905 createCallback : function(/*args...*/){
906 // make args available, in function below
907 var args = arguments,
910 return method.apply(window, args);
914 <div id="method-Function-createDelegate"></div>/**
915 * Creates a delegate (callback) that sets the scope to obj.
916 * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
917 * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
918 * callback points to obj. Example usage:
920 var sayHi = function(name){
921 // Note this use of "this.text" here. This function expects to
922 // execute within a scope that contains a text property. In this
923 // example, the "this" variable is pointing to the btn object that
924 // was passed in createDelegate below.
925 alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
928 var btn = new Ext.Button({
930 renderTo: Ext.getBody()
933 // This callback will execute in the scope of the
934 // button instance. Clicking the button alerts
935 // "Hi, Fred. You clicked the "Say Hi" button."
936 btn.on('click', sayHi.createDelegate(btn, ['Fred']));
938 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
939 * <b>If omitted, defaults to the browser window.</b>
940 * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
941 * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
942 * if a number the args are inserted at the specified position
943 * @return {Function} The new function
945 createDelegate : function(obj, args, appendArgs){
948 var callArgs = args || arguments;
949 if (appendArgs === true){
950 callArgs = Array.prototype.slice.call(arguments, 0);
951 callArgs = callArgs.concat(args);
952 }else if (Ext.isNumber(appendArgs)){
953 callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
954 var applyArgs = [appendArgs, 0].concat(args); // create method call params
955 Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
957 return method.apply(obj || window, callArgs);
961 <div id="method-Function-defer"></div>/**
962 * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
964 var sayHi = function(name){
965 alert('Hi, ' + name);
968 // executes immediately:
971 // executes after 2 seconds:
972 sayHi.defer(2000, this, ['Fred']);
974 // this syntax is sometimes useful for deferring
975 // execution of an anonymous function:
980 * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
981 * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
982 * <b>If omitted, defaults to the browser window.</b>
983 * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
984 * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
985 * if a number the args are inserted at the specified position
986 * @return {Number} The timeout id that can be used with clearTimeout
988 defer : function(millis, obj, args, appendArgs){
989 var fn = this.createDelegate(obj, args, appendArgs);
991 return setTimeout(fn, millis);
998 <div id="cls-String"></div>/**
1000 * These functions are available on every String object.
1002 Ext.applyIf(String, {
1003 <div id="method-String-format"></div>/**
1004 * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
1005 * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
1007 var cls = 'my-class', text = 'Some text';
1008 var s = String.format('<div class="{0}">{1}</div>', cls, text);
1009 // s now contains the string: '<div class="my-class">Some text</div>'
1011 * @param {String} string The tokenized string to be formatted
1012 * @param {String} value1 The value to replace token {0}
1013 * @param {String} value2 Etc...
1014 * @return {String} The formatted string
1017 format : function(format){
1018 var args = Ext.toArray(arguments, 1);
1019 return format.replace(/\{(\d+)\}/g, function(m, i){
1025 <div id="cls-Array"></div>/**
1028 Ext.applyIf(Array.prototype, {
1029 <div id="method-Array-indexOf"></div>/**
1030 * Checks whether or not the specified object exists in the array.
1031 * @param {Object} o The object to check for
1032 * @param {Number} from (Optional) The index at which to begin the search
1033 * @return {Number} The index of o in the array (or -1 if it is not found)
1035 indexOf : function(o, from){
1036 var len = this.length;
1038 from += (from < 0) ? len : 0;
1039 for (; from < len; ++from){
1040 if(this[from] === o){
1047 <div id="method-Array-remove"></div>/**
1048 * Removes the specified object from the array. If the object is not found nothing happens.
1049 * @param {Object} o The object to remove
1050 * @return {Array} this array
1052 remove : function(o){
1053 var index = this.indexOf(o);
1055 this.splice(index, 1);