-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.CompositeElementLite"></div>/**\r
+<html>
+<head>
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/**\r
* @class Ext.CompositeElementLite\r
- * Flyweight composite class. Reuses the same Ext.Element for element operations.\r
- <pre><code>\r
- var els = Ext.select("#some-el div.some-class");\r
- // or select directly from an existing element\r
- var el = Ext.get('some-el');\r
- el.select('div.some-class');\r
+ * <p>This class encapsulates a <i>collection</i> of DOM elements, providing methods to filter\r
+ * members, or to perform collective actions upon the whole set.</p>\r
+ * <p>Although they are not listed, this class supports all of the methods of {@link Ext.Element} and\r
+ * {@link Ext.Fx}. The methods from these classes will be performed on all the elements in this collection.</p>\r
+ * Example:<pre><code>\r
+var els = Ext.select("#some-el div.some-class");\r
+// or select directly from an existing element\r
+var el = Ext.get('some-el');\r
+el.select('div.some-class');\r
\r
- els.setWidth(100); // all elements become 100 width\r
- els.hide(true); // all elements fade out and hide\r
- // or\r
- els.setWidth(100).hide(true);\r
- </code></pre><br><br>\r
- * <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element\r
- * actions will be performed on all the elements in this collection.</b>\r
+els.setWidth(100); // all elements become 100 width\r
+els.hide(true); // all elements fade out and hide\r
+// or\r
+els.setWidth(100).hide(true);\r
+</code>\r
*/\r
Ext.CompositeElementLite = function(els, root){\r
+ <div id="prop-Ext.CompositeElementLite-elements"></div>/**\r
+ * <p>The Array of DOM elements which this CompositeElement encapsulates. Read-only.</p>\r
+ * <p>This will not <i>usually</i> be accessed in developers' code, but developers wishing\r
+ * to augment the capabilities of the CompositeElementLite class may use it when adding\r
+ * methods to the class.</p>\r
+ * <p>For example to add the <code>nextAll</code> method to the class to <b>add</b> all\r
+ * following siblings of selected elements, the code would be</p><code><pre>\r
+Ext.override(Ext.CompositeElementLite, {\r
+ nextAll: function() {\r
+ var els = this.elements, i, l = els.length, n, r = [], ri = -1;\r
+\r
+// Loop through all elements in this Composite, accumulating\r
+// an Array of all siblings.\r
+ for (i = 0; i < l; i++) {\r
+ for (n = els[i].nextSibling; n; n = n.nextSibling) {\r
+ r[++ri] = n;\r
+ }\r
+ }\r
+\r
+// Add all found siblings to this Composite\r
+ return this.add(r);\r
+ }\r
+});</pre></code>\r
+ * @type Array\r
+ * @property elements\r
+ */\r
this.elements = [];\r
this.add(els, root);\r
this.el = new Ext.Element.Flyweight();\r
};\r
\r
Ext.CompositeElementLite.prototype = {\r
- isComposite: true, \r
- <div id="method-Ext.CompositeElementLite-getCount"></div>/**\r
- * Returns the number of elements in this composite\r
+ isComposite: true, \r
+ <div id="method-Ext.CompositeElementLite-getCount"></div>/**\r
+ * Returns the number of elements in this Composite.\r
* @return Number\r
*/\r
getCount : function(){\r
return this.elements.length;\r
}, \r
- add : function(els){\r
+ <div id="method-Ext.CompositeElementLite-add"></div>/**\r
+ * Adds elements to this Composite object.\r
+ * @param {Mixed} els Either an Array of DOM elements to add, or another Composite object who's elements should be added.\r
+ * @return {CompositeElement} This Composite object.\r
+ */\r
+ add : function(els){\r
if(els){\r
if (Ext.isArray(els)) {\r
this.elements = this.elements.concat(els);\r
} else {\r
- var yels = this.elements; \r
- Ext.each(els, function(e) {\r
+ var yels = this.elements; \r
+ Ext.each(els, function(e) {\r
yels.push(e);\r
});\r
}\r
},\r
invoke : function(fn, args){\r
var els = this.elements,\r
- el = this.el; \r
- Ext.each(els, function(e) { \r
+ el = this.el; \r
+ Ext.each(els, function(e) { \r
el.dom = e;\r
- Ext.Element.prototype[fn].apply(el, args);\r
+ Ext.Element.prototype[fn].apply(el, args);\r
});\r
return this;\r
},\r
* @return {Ext.Element}\r
*/\r
item : function(index){\r
- var me = this;\r
+ var me = this;\r
if(!me.elements[index]){\r
return null;\r
}\r
// fixes scope with flyweight\r
addListener : function(eventName, handler, scope, opt){\r
Ext.each(this.elements, function(e) {\r
- Ext.EventManager.on(e, eventName, handler, scope || e, opt);\r
+ Ext.EventManager.on(e, eventName, handler, scope || e, opt);\r
});\r
return this;\r
},\r
<div id="method-Ext.CompositeElementLite-each"></div>/**\r
- * Calls the passed function passing (el, this, index) for each element in this composite. <b>The element\r
- * passed is the flyweight (shared) Ext.Element instance, so if you require a\r
- * a reference to the dom node, use el.dom.</b>\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The <i>this</i> object (defaults to the element)\r
- * @return {CompositeElement} this\r
- */\r
+ * <p>Calls the passed function for each element in this composite.</p>\r
+ * @param {Function} fn The function to call. The function is passed the following parameters:<ul>\r
+ * <li><b>el</b> : Element<div class="sub-desc">The current Element in the iteration.\r
+ * <b>This is the flyweight (shared) Ext.Element instance, so if you require a\r
+ * a reference to the dom node, use el.dom.</b></div></li>\r
+ * <li><b>c</b> : Composite<div class="sub-desc">This Composite object.</div></li>\r
+ * <li><b>idx</b> : Number<div class="sub-desc">The zero-based index in the iteration.</div></li>\r
+ * </ul>\r
+ * @param {Object} scope (optional) The scope (<i>this</i> reference) in which the function is executed. (defaults to the Element)\r
+ * @return {CompositeElement} this\r
+ */\r
each : function(fn, scope){ \r
var me = this,\r
- el = me.el;\r
+ el = me.el;\r
\r
- Ext.each(me.elements, function(e,i) { \r
+ Ext.each(me.elements, function(e,i) { \r
el.dom = e;\r
- return fn.call(scope || el, el, me, i);\r
+ return fn.call(scope || el, el, me, i);\r
+ });\r
+ return me;\r
+ },\r
+ \r
+ <div id="method-Ext.CompositeElementLite-fill"></div>/**\r
+ * Clears this Composite and adds the elements passed.\r
+ * @param {Mixed} els Either an array of DOM elements, or another Composite from which to fill this Composite.\r
+ * @return {CompositeElement} this\r
+ */\r
+ fill : function(els){\r
+ var me = this;\r
+ me.elements = [];\r
+ me.add(els);\r
+ return me;\r
+ },\r
+ \r
+ <div id="method-Ext.CompositeElementLite-filter"></div>/**\r
+ * Filters this composite to only elements that match the passed selector.\r
+ * @param {String/Function} selector A string CSS selector or a comparison function.\r
+ * The comparison function will be called with the following arguments:<ul>\r
+ * <li><code>el</code> : Ext.Element<div class="sub-desc">The current DOM element.</div></li>\r
+ * <li><code>index</code> : Number<div class="sub-desc">The current index within the collection.</div></li>\r
+ * </ul>\r
+ * @return {CompositeElement} this\r
+ */\r
+ filter : function(selector){\r
+ var els = [],\r
+ me = this,\r
+ fn = Ext.isFunction(selector) ? selector\r
+ : function(el){\r
+ return el.is(selector);\r
+ }\r
+ me.each(function(el, self, i){\r
+ if(fn(el, i) !== false){\r
+ els[els.length] = el.dom;\r
+ }\r
});\r
+ me.fill(els);\r
return me;\r
},\r
\r
*/ \r
replaceElement : function(el, replacement, domReplace){\r
var index = !isNaN(el) ? el : this.indexOf(el),\r
- d;\r
+ d;\r
if(index > -1){\r
replacement = Ext.getDom(replacement);\r
if(domReplace){\r
\r
(function(){\r
var fnName,\r
- ElProto = Ext.Element.prototype,\r
- CelProto = Ext.CompositeElementLite.prototype;\r
- \r
+ ElProto = Ext.Element.prototype,\r
+ CelProto = Ext.CompositeElementLite.prototype;\r
+ \r
for(fnName in ElProto){\r
if(Ext.isFunction(ElProto[fnName])){\r
- (function(fnName){ \r
- CelProto[fnName] = CelProto[fnName] || function(){\r
- return this.invoke(fnName, arguments);\r
- };\r
- }).call(CelProto, fnName);\r
+ (function(fnName){ \r
+ CelProto[fnName] = CelProto[fnName] || function(){\r
+ return this.invoke(fnName, arguments);\r
+ };\r
+ }).call(CelProto, fnName);\r
\r
}\r
}\r
* @member Ext\r
* @method select\r
*/\r
-Ext.select = Ext.Element.select;</pre> \r
-</body>\r
+Ext.select = Ext.Element.select;</pre>
+</body>
</html>
\ No newline at end of file