Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/ext/src/ext-core/src/core/Ext.js @ 76

Revision 76, 38.8 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

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