X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/docs/source/CompositeElementLite.html diff --git a/docs/source/CompositeElementLite.html b/docs/source/CompositeElementLite.html index 1f85cd1f..16a9832b 100644 --- a/docs/source/CompositeElementLite.html +++ b/docs/source/CompositeElementLite.html @@ -1,49 +1,87 @@ - -
-/** + + +The source code + + + + +/*! + * Ext JS Library 3.0.3 + * Copyright(c) 2006-2009 Ext JS, LLC + * licensing@extjs.com + * http://www.extjs.com/license + */ +/** * @class Ext.CompositeElementLite - * Flyweight composite class. Reuses the same Ext.Element for element operations. -- var els = Ext.select("#some-el div.some-class"); - // or select directly from an existing element - var el = Ext.get('some-el'); - el.select('div.some-class'); + *
*/ Ext.CompositeElementLite = function(els, root){ + /** + *This class encapsulates a collection of DOM elements, providing methods to filter + * members, or to perform collective actions upon the whole set.
+ *Although they are not listed, this class supports all of the methods of {@link Ext.Element} and + * {@link Ext.Fx}. The methods from these classes will be performed on all the elements in this collection.
+ * Example:+var els = Ext.select("#some-el div.some-class"); +// or select directly from an existing element +var el = Ext.get('some-el'); +el.select('div.some-class'); - els.setWidth(100); // all elements become 100 width - els.hide(true); // all elements fade out and hide - // or - els.setWidth(100).hide(true); -
- * NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element - * actions will be performed on all the elements in this collection. +els.setWidth(100); // all elements become 100 width +els.hide(true); // all elements fade out and hide +// or +els.setWidth(100).hide(true); +The Array of DOM elements which this CompositeElement encapsulates. Read-only.
+ *This will not usually be accessed in developers' code, but developers wishing + * to augment the capabilities of the CompositeElementLite class may use it when adding + * methods to the class.
+ *For example to add the
nextAll
method to the class to add all + * following siblings of selected elements, the code would be+ * @type Array + * @property elements + */ this.elements = []; this.add(els, root); this.el = new Ext.Element.Flyweight(); }; Ext.CompositeElementLite.prototype = { - isComposite: true, - /** - * Returns the number of elements in this composite + isComposite: true, + /** + * Returns the number of elements in this Composite. * @return Number */ getCount : function(){ return this.elements.length; }, - add : function(els){ + /** + * Adds elements to this Composite object. + * @param {Mixed} els Either an Array of DOM elements to add, or another Composite object who's elements should be added. + * @return {CompositeElement} This Composite object. + */ + add : function(els){ if(els){ if (Ext.isArray(els)) { this.elements = this.elements.concat(els); } else { - var yels = this.elements; - Ext.each(els, function(e) { + var yels = this.elements; + Ext.each(els, function(e) { yels.push(e); }); } @@ -52,10 +90,10 @@ Ext.CompositeElementLite.prototype = { }, invoke : function(fn, args){ var els = this.elements, - el = this.el; - Ext.each(els, function(e) { + el = this.el; + Ext.each(els, function(e) { el.dom = e; - Ext.Element.prototype[fn].apply(el, args); + Ext.Element.prototype[fn].apply(el, args); }); return this; }, @@ -65,7 +103,7 @@ Ext.CompositeElementLite.prototype = { * @return {Ext.Element} */ item : function(index){ - var me = this; + var me = this; if(!me.elements[index]){ return null; } @@ -76,26 +114,67 @@ Ext.CompositeElementLite.prototype = { // fixes scope with flyweight addListener : function(eventName, handler, scope, opt){ Ext.each(this.elements, function(e) { - Ext.EventManager.on(e, eventName, handler, scope || e, opt); + Ext.EventManager.on(e, eventName, handler, scope || e, opt); }); return this; }, /** - * Calls the passed function passing (el, this, index) for each element in this composite. The element - * passed is the flyweight (shared) Ext.Element instance, so if you require a - * a reference to the dom node, use el.dom. - * @param {Function} fn The function to call - * @param {Object} scope (optional) The this object (defaults to the element) - * @return {CompositeElement} this - */ + *
+Ext.override(Ext.CompositeElementLite, { + nextAll: function() { + var els = this.elements, i, l = els.length, n, r = [], ri = -1; + +// Loop through all elements in this Composite, accumulating +// an Array of all siblings. + for (i = 0; i < l; i++) { + for (n = els[i].nextSibling; n; n = n.nextSibling) { + r[++ri] = n; + } + } + +// Add all found siblings to this Composite + return this.add(r); + } +});Calls the passed function for each element in this composite.
+ * @param {Function} fn The function to call. The function is passed the following parameters:
el
: Ext.Elementindex
: Number