2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.CompositeElement
11
* @extends Ext.CompositeElementLite
12
* Standard composite class. Creates a Ext.Element for every element in the collection.
14
* <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element
15
* actions will be performed on all the elements in this collection.</b>
17
* All methods return <i>this</i> and can be chained.
19
var els = Ext.select("#some-el div.some-class", true);
20
// or select directly from an existing element
21
var el = Ext.get('some-el');
22
el.select('div.some-class', true);
24
els.setWidth(100); // all elements become 100 width
25
els.hide(true); // all elements fade out and hide
27
els.setWidth(100).hide(true);
30
Ext.CompositeElement = function(els, root){
35
Ext.extend(Ext.CompositeElement, Ext.CompositeElementLite, {
36
invoke : function(fn, args){
37
Ext.each(this.elements, function(e) {
38
Ext.Element.prototype[fn].apply(e, args);
44
* Adds elements to this composite.
45
* @param {String/Array} els A string CSS selector, an array of elements or an element
46
* @return {CompositeElement} this
48
add : function(els, root){
50
if(typeof els == "string"){
51
els = Ext.Element.selectorFunction(els, root);
53
var yels = this.elements;
54
Ext.each(els, function(e) {
55
yels.push(Ext.get(e));
61
* Returns the Element object at the specified index
62
* @param {Number} index
63
* @return {Ext.Element}
65
item : function(index){
66
return this.elements[index] || null;
70
indexOf : function(el){
71
return this.elements.indexOf(Ext.get(el));
74
filter : function(selector){
78
Ext.each(me.elements, function(el) {
80
out.push(Ext.get(el));
88
* Calls the passed function passing (el, this, index) for each element in this composite.
89
* @param {Function} fn The function to call
90
* @param {Object} scope (optional) The <i>this</i> object (defaults to the element)
91
* @return {CompositeElement} this
93
each : function(fn, scope){
94
Ext.each(this.elements, function(e,i) {
95
return fn.call(scope || e, e, this, i)
102
* Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
103
* to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
104
* {@link Ext.CompositeElementLite CompositeElementLite} object.
105
* @param {String/Array} selector The CSS selector or an array of elements
106
* @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
107
* @param {HTMLElement/String} root (optional) The root element of the query or id of the root
108
* @return {CompositeElementLite/CompositeElement}
109
* @member Ext.Element
112
Ext.Element.select = function(selector, unique, root){
114
if(typeof selector == "string"){
115
els = Ext.Element.selectorFunction(selector, root);
116
}else if(selector.length !== undefined){
119
throw "Invalid selector";
122
return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
126
* Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
127
* to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
128
* {@link Ext.CompositeElementLite CompositeElementLite} object.
129
* @param {String/Array} selector The CSS selector or an array of elements
130
* @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
131
* @param {HTMLElement/String} root (optional) The root element of the query or id of the root
132
* @return {CompositeElementLite/CompositeElement}
133
* @member Ext.Element
136
Ext.select = Ext.Element.select;
b'\\ No newline at end of file'