Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 jpm 1
/*
2
 * Ext JS Library 2.0.2
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
4
 * licensing@extjs.com
5
 *
6
 * http://extjs.com/license
7
 */
8
 
9
/*
10
 * This is code is also distributed under MIT license for use
11
 * with jQuery and prototype JavaScript libraries.
12
 */
13
/**
14
 * @class Ext.DomQuery
15
Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
16
<p>
17
DomQuery supports most of the <a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors">CSS3 selectors spec</a>, along with some custom selectors and basic XPath.</p>
18
 
19
<p>
20
All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
21
</p>
22
<h4>Element Selectors:</h4>
23
<ul class="list">
24
    <li> <b>*</b> any element</li>
25
    <li> <b>E</b> an element with the tag E</li>
26
    <li> <b>E F</b> All descendent elements of E that have the tag F</li>
27
    <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>
28
    <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>
29
    <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>
30
</ul>
31
<h4>Attribute Selectors:</h4>
32
<p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>
33
<ul class="list">
34
    <li> <b>E[foo]</b> has an attribute "foo"</li>
35
    <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>
36
    <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>
37
    <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>
38
    <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>
39
    <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>
40
    <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>
41
</ul>
42
<h4>Pseudo Classes:</h4>
43
<ul class="list">
44
    <li> <b>E:first-child</b> E is the first child of its parent</li>
45
    <li> <b>E:last-child</b> E is the last child of its parent</li>
46
    <li> <b>E:nth-child(<i>n</i>)</b> E is the <i>n</i>th child of its parent (1 based as per the spec)</li>
47
    <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>
48
    <li> <b>E:nth-child(even)</b> E is an even child of its parent</li>
49
    <li> <b>E:only-child</b> E is the only child of its parent</li>
50
    <li> <b>E:checked</b> E is an element that is has a checked attribute that is true (e.g. a radio or checkbox) </li>
51
    <li> <b>E:first</b> the first E in the resultset</li>
52
    <li> <b>E:last</b> the last E in the resultset</li>
53
    <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>
54
    <li> <b>E:odd</b> shortcut for :nth-child(odd)</li>
55
    <li> <b>E:even</b> shortcut for :nth-child(even)</li>
56
    <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>
57
    <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>
58
    <li> <b>E:not(S)</b> an E element that does not match simple selector S</li>
59
    <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>
60
    <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>
61
    <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>
62
</ul>
63
<h4>CSS Value Selectors:</h4>
64
<ul class="list">
65
    <li> <b>E{display=none}</b> css value "display" that equals "none"</li>
66
    <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>
67
    <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>
68
    <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>
69
    <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>
70
    <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>
71
</ul>
72
 * @singleton
73
 */
74
Ext.DomQuery = function(){
75
    var cache = {}, simpleCache = {}, valueCache = {};
76
    var nonSpace = /\S/;
77
    var trimRe = /^\s+|\s+$/g;
78
    var tplRe = /\{(\d+)\}/g;
79
    var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
80
    var tagTokenRe = /^(#)?([\w-\*]+)/;
81
    var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;
82
 
83
    function child(p, index){
84
        var i = 0;
85
        var n = p.firstChild;
86
        while(n){
87
            if(n.nodeType == 1){
88
               if(++i == index){
89
                   return n;
90
               }
91
            }
92
            n = n.nextSibling;
93
        }
94
        return null;
95
    };
96
 
97
    function next(n){
98
        while((n = n.nextSibling) && n.nodeType != 1);
99
        return n;
100
    };
101
 
102
    function prev(n){
103
        while((n = n.previousSibling) && n.nodeType != 1);
104
        return n;
105
    };
106
 
107
    function children(d){
108
        var n = d.firstChild, ni = -1;
109
 	    while(n){
110
 	        var nx = n.nextSibling;
111
 	        if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
112
 	            d.removeChild(n);
113
 	        }else{
114
 	            n.nodeIndex = ++ni;
115
 	        }
116
 	        n = nx;
117
 	    }
118
 	    return this;
119
 	};
120
 
121
    function byClassName(c, a, v){
122
        if(!v){
123
            return c;
124
        }
125
        var r = [], ri = -1, cn;
126
        for(var i = 0, ci; ci = c[i]; i++){
127
            if((' '+ci.className+' ').indexOf(v) != -1){
128
                r[++ri] = ci;
129
            }
130
        }
131
        return r;
132
    };
133
 
134
    function attrValue(n, attr){
135
        if(!n.tagName && typeof n.length != "undefined"){
136
            n = n[0];
137
        }
138
        if(!n){
139
            return null;
140
        }
141
        if(attr == "for"){
142
            return n.htmlFor;
143
        }
144
        if(attr == "class" || attr == "className"){
145
            return n.className;
146
        }
147
        return n.getAttribute(attr) || n[attr];
148
 
149
    };
150
 
151
    function getNodes(ns, mode, tagName){
152
        var result = [], ri = -1, cs;
153
        if(!ns){
154
            return result;
155
        }
156
        tagName = tagName || "*";
157
        if(typeof ns.getElementsByTagName != "undefined"){
158
            ns = [ns];
159
        }
160
        if(!mode){
161
            for(var i = 0, ni; ni = ns[i]; i++){
162
                cs = ni.getElementsByTagName(tagName);
163
                for(var j = 0, ci; ci = cs[j]; j++){
164
                    result[++ri] = ci;
165
                }
166
            }
167
        }else if(mode == "/" || mode == ">"){
168
            var utag = tagName.toUpperCase();
169
            for(var i = 0, ni, cn; ni = ns[i]; i++){
170
                cn = ni.children || ni.childNodes;
171
                for(var j = 0, cj; cj = cn[j]; j++){
172
                    if(cj.nodeName == utag || cj.nodeName == tagName  || tagName == '*'){
173
                        result[++ri] = cj;
174
                    }
175
                }
176
            }
177
        }else if(mode == "+"){
178
            var utag = tagName.toUpperCase();
179
            for(var i = 0, n; n = ns[i]; i++){
180
                while((n = n.nextSibling) && n.nodeType != 1);
181
                if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
182
                    result[++ri] = n;
183
                }
184
            }
185
        }else if(mode == "~"){
186
            for(var i = 0, n; n = ns[i]; i++){
187
                while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));
188
                if(n){
189
                    result[++ri] = n;
190
                }
191
            }
192
        }
193
        return result;
194
    };
195
 
196
    function concat(a, b){
197
        if(b.slice){
198
            return a.concat(b);
199
        }
200
        for(var i = 0, l = b.length; i < l; i++){
201
            a[a.length] = b[i];
202
        }
203
        return a;
204
    }
205
 
206
    function byTag(cs, tagName){
207
        if(cs.tagName || cs == document){
208
            cs = [cs];
209
        }
210
        if(!tagName){
211
            return cs;
212
        }
213
        var r = [], ri = -1;
214
        tagName = tagName.toLowerCase();
215
        for(var i = 0, ci; ci = cs[i]; i++){
216
            if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
217
                r[++ri] = ci;
218
            }
219
        }
220
        return r;
221
    };
222
 
223
    function byId(cs, attr, id){
224
        if(cs.tagName || cs == document){
225
            cs = [cs];
226
        }
227
        if(!id){
228
            return cs;
229
        }
230
        var r = [], ri = -1;
231
        for(var i = 0,ci; ci = cs[i]; i++){
232
            if(ci && ci.id == id){
233
                r[++ri] = ci;
234
                return r;
235
            }
236
        }
237
        return r;
238
    };
239
 
240
    function byAttribute(cs, attr, value, op, custom){
241
        var r = [], ri = -1, st = custom=="{";
242
        var f = Ext.DomQuery.operators[op];
243
        for(var i = 0, ci; ci = cs[i]; i++){
244
            var a;
245
            if(st){
246
                a = Ext.DomQuery.getStyle(ci, attr);
247
            }
248
            else if(attr == "class" || attr == "className"){
249
                a = ci.className;
250
            }else if(attr == "for"){
251
                a = ci.htmlFor;
252
            }else if(attr == "href"){
253
                a = ci.getAttribute("href", 2);
254
            }else{
255
                a = ci.getAttribute(attr);
256
            }
257
            if((f && f(a, value)) || (!f && a)){
258
                r[++ri] = ci;
259
            }
260
        }
261
        return r;
262
    };
263
 
264
    function byPseudo(cs, name, value){
265
        return Ext.DomQuery.pseudos[name](cs, value);
266
    };
267
 
268
    // This is for IE MSXML which does not support expandos.
269
    // IE runs the same speed using setAttribute, however FF slows way down
270
    // and Safari completely fails so they need to continue to use expandos.
271
    var isIE = window.ActiveXObject ? true : false;
272
 
273
    // this eval is stop the compressor from
274
    // renaming the variable to something shorter
275
    eval("var batch = 30803;");
276
 
277
    var key = 30803;
278
 
279
    function nodupIEXml(cs){
280
        var d = ++key;
281
        cs[0].setAttribute("_nodup", d);
282
        var r = [cs[0]];
283
        for(var i = 1, len = cs.length; i < len; i++){
284
            var c = cs[i];
285
            if(!c.getAttribute("_nodup") != d){
286
                c.setAttribute("_nodup", d);
287
                r[r.length] = c;
288
            }
289
        }
290
        for(var i = 0, len = cs.length; i < len; i++){
291
            cs[i].removeAttribute("_nodup");
292
        }
293
        return r;
294
    }
295
 
296
    function nodup(cs){
297
        if(!cs){
298
            return [];
299
        }
300
        var len = cs.length, c, i, r = cs, cj, ri = -1;
301
        if(!len || typeof cs.nodeType != "undefined" || len == 1){
302
            return cs;
303
        }
304
        if(isIE && typeof cs[0].selectSingleNode != "undefined"){
305
            return nodupIEXml(cs);
306
        }
307
        var d = ++key;
308
        cs[0]._nodup = d;
309
        for(i = 1; c = cs[i]; i++){
310
            if(c._nodup != d){
311
                c._nodup = d;
312
            }else{
313
                r = [];
314
                for(var j = 0; j < i; j++){
315
                    r[++ri] = cs[j];
316
                }
317
                for(j = i+1; cj = cs[j]; j++){
318
                    if(cj._nodup != d){
319
                        cj._nodup = d;
320
                        r[++ri] = cj;
321
                    }
322
                }
323
                return r;
324
            }
325
        }
326
        return r;
327
    }
328
 
329
    function quickDiffIEXml(c1, c2){
330
        var d = ++key;
331
        for(var i = 0, len = c1.length; i < len; i++){
332
            c1[i].setAttribute("_qdiff", d);
333
        }
334
        var r = [];
335
        for(var i = 0, len = c2.length; i < len; i++){
336
            if(c2[i].getAttribute("_qdiff") != d){
337
                r[r.length] = c2[i];
338
            }
339
        }
340
        for(var i = 0, len = c1.length; i < len; i++){
341
           c1[i].removeAttribute("_qdiff");
342
        }
343
        return r;
344
    }
345
 
346
    function quickDiff(c1, c2){
347
        var len1 = c1.length;
348
        if(!len1){
349
            return c2;
350
        }
351
        if(isIE && c1[0].selectSingleNode){
352
            return quickDiffIEXml(c1, c2);
353
        }
354
        var d = ++key;
355
        for(var i = 0; i < len1; i++){
356
            c1[i]._qdiff = d;
357
        }
358
        var r = [];
359
        for(var i = 0, len = c2.length; i < len; i++){
360
            if(c2[i]._qdiff != d){
361
                r[r.length] = c2[i];
362
            }
363
        }
364
        return r;
365
    }
366
 
367
    function quickId(ns, mode, root, id){
368
        if(ns == root){
369
           var d = root.ownerDocument || root;
370
           return d.getElementById(id);
371
        }
372
        ns = getNodes(ns, mode, "*");
373
        return byId(ns, null, id);
374
    }
375
 
376
    return {
377
        getStyle : function(el, name){
378
            return Ext.fly(el).getStyle(name);
379
        },
380
        /**
381
         * Compiles a selector/xpath query into a reusable function. The returned function
382
         * takes one parameter "root" (optional), which is the context node from where the query should start.
383
         * @param {String} selector The selector/xpath query
384
         * @param {String} type (optional) Either "select" (the default) or "simple" for a simple selector match
385
         * @return {Function}
386
         */
387
        compile : function(path, type){
388
            type = type || "select";
389
 
390
            var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
391
            var q = path, mode, lq;
392
            var tk = Ext.DomQuery.matchers;
393
            var tklen = tk.length;
394
            var mm;
395
 
396
            // accept leading mode switch
397
            var lmode = q.match(modeRe);
398
            if(lmode && lmode[1]){
399
                fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
400
                q = q.replace(lmode[1], "");
401
            }
402
            // strip leading slashes
403
            while(path.substr(0, 1)=="/"){
404
                path = path.substr(1);
405
            }
406
 
407
            while(q && lq != q){
408
                lq = q;
409
                var tm = q.match(tagTokenRe);
410
                if(type == "select"){
411
                    if(tm){
412
                        if(tm[1] == "#"){
413
                            fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
414
                        }else{
415
                            fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
416
                        }
417
                        q = q.replace(tm[0], "");
418
                    }else if(q.substr(0, 1) != '@'){
419
                        fn[fn.length] = 'n = getNodes(n, mode, "*");';
420
                    }
421
                }else{
422
                    if(tm){
423
                        if(tm[1] == "#"){
424
                            fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
425
                        }else{
426
                            fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
427
                        }
428
                        q = q.replace(tm[0], "");
429
                    }
430
                }
431
                while(!(mm = q.match(modeRe))){
432
                    var matched = false;
433
                    for(var j = 0; j < tklen; j++){
434
                        var t = tk[j];
435
                        var m = q.match(t.re);
436
                        if(m){
437
                            fn[fn.length] = t.select.replace(tplRe, function(x, i){
438
                                                    return m[i];
439
                                                });
440
                            q = q.replace(m[0], "");
441
                            matched = true;
442
                            break;
443
                        }
444
                    }
445
                    // prevent infinite loop on bad selector
446
                    if(!matched){
447
                        throw 'Error parsing selector, parsing failed at "' + q + '"';
448
                    }
449
                }
450
                if(mm[1]){
451
                    fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
452
                    q = q.replace(mm[1], "");
453
                }
454
            }
455
            fn[fn.length] = "return nodup(n);\n}";
456
            eval(fn.join(""));
457
            return f;
458
        },
459
 
460
        /**
461
         * Selects a group of elements.
462
         * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
463
         * @param {Node} root (optional) The start of the query (defaults to document).
464
         * @return {Array}
465
         */
466
        select : function(path, root, type){
467
            if(!root || root == document){
468
                root = document;
469
            }
470
            if(typeof root == "string"){
471
                root = document.getElementById(root);
472
            }
473
            var paths = path.split(",");
474
            var results = [];
475
            for(var i = 0, len = paths.length; i < len; i++){
476
                var p = paths[i].replace(trimRe, "");
477
                if(!cache[p]){
478
                    cache[p] = Ext.DomQuery.compile(p);
479
                    if(!cache[p]){
480
                        throw p + " is not a valid selector";
481
                    }
482
                }
483
                var result = cache[p](root);
484
                if(result && result != document){
485
                    results = results.concat(result);
486
                }
487
            }
488
            if(paths.length > 1){
489
                return nodup(results);
490
            }
491
            return results;
492
        },
493
 
494
        /**
495
         * Selects a single element.
496
         * @param {String} selector The selector/xpath query
497
         * @param {Node} root (optional) The start of the query (defaults to document).
498
         * @return {Element}
499
         */
500
        selectNode : function(path, root){
501
            return Ext.DomQuery.select(path, root)[0];
502
        },
503
 
504
        /**
505
         * Selects the value of a node, optionally replacing null with the defaultValue.
506
         * @param {String} selector The selector/xpath query
507
         * @param {Node} root (optional) The start of the query (defaults to document).
508
         * @param {String} defaultValue
509
         */
510
        selectValue : function(path, root, defaultValue){
511
            path = path.replace(trimRe, "");
512
            if(!valueCache[path]){
513
                valueCache[path] = Ext.DomQuery.compile(path, "select");
514
            }
515
            var n = valueCache[path](root);
516
            n = n[0] ? n[0] : n;
517
            var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
518
            return ((v === null||v === undefined||v==='') ? defaultValue : v);
519
        },
520
 
521
        /**
522
         * Selects the value of a node, parsing integers and floats.
523
         * @param {String} selector The selector/xpath query
524
         * @param {Node} root (optional) The start of the query (defaults to document).
525
         * @param {Number} defaultValue
526
         * @return {Number}
527
         */
528
        selectNumber : function(path, root, defaultValue){
529
            var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
530
            return parseFloat(v);
531
        },
532
 
533
        /**
534
         * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
535
         * @param {String/HTMLElement/Array} el An element id, element or array of elements
536
         * @param {String} selector The simple selector to test
537
         * @return {Boolean}
538
         */
539
        is : function(el, ss){
540
            if(typeof el == "string"){
541
                el = document.getElementById(el);
542
            }
543
            var isArray = Ext.isArray(el);
544
            var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
545
            return isArray ? (result.length == el.length) : (result.length > 0);
546
        },
547
 
548
        /**
549
         * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
550
         * @param {Array} el An array of elements to filter
551
         * @param {String} selector The simple selector to test
552
         * @param {Boolean} nonMatches If true, it returns the elements that DON'T match
553
         * the selector instead of the ones that match
554
         * @return {Array}
555
         */
556
        filter : function(els, ss, nonMatches){
557
            ss = ss.replace(trimRe, "");
558
            if(!simpleCache[ss]){
559
                simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
560
            }
561
            var result = simpleCache[ss](els);
562
            return nonMatches ? quickDiff(result, els) : result;
563
        },
564
 
565
        /**
566
         * Collection of matching regular expressions and code snippets.
567
         */
568
        matchers : [{
569
                re: /^\.([\w-]+)/,
570
                select: 'n = byClassName(n, null, " {1} ");'
571
            }, {
572
                re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
573
                select: 'n = byPseudo(n, "{1}", "{2}");'
574
            },{
575
                re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
576
                select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
577
            }, {
578
                re: /^#([\w-]+)/,
579
                select: 'n = byId(n, null, "{1}");'
580
            },{
581
                re: /^@([\w-]+)/,
582
                select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
583
            }
584
        ],
585
 
586
        /**
587
         * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
588
         * New operators can be added as long as the match the format <i>c</i>= where <i>c</i> is any character other than space, &gt; &lt;.
589
         */
590
        operators : {
591
            "=" : function(a, v){
592
                return a == v;
593
            },
594
            "!=" : function(a, v){
595
                return a != v;
596
            },
597
            "^=" : function(a, v){
598
                return a && a.substr(0, v.length) == v;
599
            },
600
            "$=" : function(a, v){
601
                return a && a.substr(a.length-v.length) == v;
602
            },
603
            "*=" : function(a, v){
604
                return a && a.indexOf(v) !== -1;
605
            },
606
            "%=" : function(a, v){
607
                return (a % v) == 0;
608
            },
609
            "|=" : function(a, v){
610
                return a && (a == v || a.substr(0, v.length+1) == v+'-');
611
            },
612
            "~=" : function(a, v){
613
                return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
614
            }
615
        },
616
 
617
        /**
618
         * Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
619
         * and the argument (if any) supplied in the selector.
620
         */
621
        pseudos : {
622
            "first-child" : function(c){
623
                var r = [], ri = -1, n;
624
                for(var i = 0, ci; ci = n = c[i]; i++){
625
                    while((n = n.previousSibling) && n.nodeType != 1);
626
                    if(!n){
627
                        r[++ri] = ci;
628
                    }
629
                }
630
                return r;
631
            },
632
 
633
            "last-child" : function(c){
634
                var r = [], ri = -1, n;
635
                for(var i = 0, ci; ci = n = c[i]; i++){
636
                    while((n = n.nextSibling) && n.nodeType != 1);
637
                    if(!n){
638
                        r[++ri] = ci;
639
                    }
640
                }
641
                return r;
642
            },
643
 
644
            "nth-child" : function(c, a) {
645
                var r = [], ri = -1;
646
                var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
647
                var f = (m[1] || 1) - 0, l = m[2] - 0;
648
                for(var i = 0, n; n = c[i]; i++){
649
                    var pn = n.parentNode;
650
                    if (batch != pn._batch) {
651
                        var j = 0;
652
                        for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
653
                            if(cn.nodeType == 1){
654
                               cn.nodeIndex = ++j;
655
                            }
656
                        }
657
                        pn._batch = batch;
658
                    }
659
                    if (f == 1) {
660
                        if (l == 0 || n.nodeIndex == l){
661
                            r[++ri] = n;
662
                        }
663
                    } else if ((n.nodeIndex + l) % f == 0){
664
                        r[++ri] = n;
665
                    }
666
                }
667
 
668
                return r;
669
            },
670
 
671
            "only-child" : function(c){
672
                var r = [], ri = -1;;
673
                for(var i = 0, ci; ci = c[i]; i++){
674
                    if(!prev(ci) && !next(ci)){
675
                        r[++ri] = ci;
676
                    }
677
                }
678
                return r;
679
            },
680
 
681
            "empty" : function(c){
682
                var r = [], ri = -1;
683
                for(var i = 0, ci; ci = c[i]; i++){
684
                    var cns = ci.childNodes, j = 0, cn, empty = true;
685
                    while(cn = cns[j]){
686
                        ++j;
687
                        if(cn.nodeType == 1 || cn.nodeType == 3){
688
                            empty = false;
689
                            break;
690
                        }
691
                    }
692
                    if(empty){
693
                        r[++ri] = ci;
694
                    }
695
                }
696
                return r;
697
            },
698
 
699
            "contains" : function(c, v){
700
                var r = [], ri = -1;
701
                for(var i = 0, ci; ci = c[i]; i++){
702
                    if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
703
                        r[++ri] = ci;
704
                    }
705
                }
706
                return r;
707
            },
708
 
709
            "nodeValue" : function(c, v){
710
                var r = [], ri = -1;
711
                for(var i = 0, ci; ci = c[i]; i++){
712
                    if(ci.firstChild && ci.firstChild.nodeValue == v){
713
                        r[++ri] = ci;
714
                    }
715
                }
716
                return r;
717
            },
718
 
719
            "checked" : function(c){
720
                var r = [], ri = -1;
721
                for(var i = 0, ci; ci = c[i]; i++){
722
                    if(ci.checked == true){
723
                        r[++ri] = ci;
724
                    }
725
                }
726
                return r;
727
            },
728
 
729
            "not" : function(c, ss){
730
                return Ext.DomQuery.filter(c, ss, true);
731
            },
732
 
733
            "any" : function(c, selectors){
734
                var ss = selectors.split('|');
735
                var r = [], ri = -1, s;
736
                for(var i = 0, ci; ci = c[i]; i++){
737
                    for(var j = 0; s = ss[j]; j++){
738
                        if(Ext.DomQuery.is(ci, s)){
739
                            r[++ri] = ci;
740
                            break;
741
                        }
742
                    }
743
                }
744
                return r;
745
            },
746
 
747
            "odd" : function(c){
748
                return this["nth-child"](c, "odd");
749
            },
750
 
751
            "even" : function(c){
752
                return this["nth-child"](c, "even");
753
            },
754
 
755
            "nth" : function(c, a){
756
                return c[a-1] || [];
757
            },
758
 
759
            "first" : function(c){
760
                return c[0] || [];
761
            },
762
 
763
            "last" : function(c){
764
                return c[c.length-1] || [];
765
            },
766
 
767
            "has" : function(c, ss){
768
                var s = Ext.DomQuery.select;
769
                var r = [], ri = -1;
770
                for(var i = 0, ci; ci = c[i]; i++){
771
                    if(s(ss, ci).length > 0){
772
                        r[++ri] = ci;
773
                    }
774
                }
775
                return r;
776
            },
777
 
778
            "next" : function(c, ss){
779
                var is = Ext.DomQuery.is;
780
                var r = [], ri = -1;
781
                for(var i = 0, ci; ci = c[i]; i++){
782
                    var n = next(ci);
783
                    if(n && is(n, ss)){
784
                        r[++ri] = ci;
785
                    }
786
                }
787
                return r;
788
            },
789
 
790
            "prev" : function(c, ss){
791
                var is = Ext.DomQuery.is;
792
                var r = [], ri = -1;
793
                for(var i = 0, ci; ci = c[i]; i++){
794
                    var n = prev(ci);
795
                    if(n && is(n, ss)){
796
                        r[++ri] = ci;
797
                    }
798
                }
799
                return r;
800
            }
801
        }
802
    };
803
}();
804
 
805
/**
806
 * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
807
 * @param {String} path The selector/xpath query
808
 * @param {Node} root (optional) The start of the query (defaults to document).
809
 * @return {Array}
810
 * @member Ext
811
 * @method query
812
 */
813
Ext.query = Ext.DomQuery.select;