-<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
+<html>\r
+<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \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">/**\r
* @class Ext.CompositeElementLite\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
\r
Ext.CompositeElementLite.prototype = {\r
isComposite: true, \r
+ \r
+ // private\r
+ getElement : function(el){\r
+ // Set the shared flyweight dom property to the current element\r
+ var e = this.el;\r
+ e.dom = el;\r
+ e.id = el.id;\r
+ return e;\r
+ },\r
+ \r
+ // private\r
+ transformElement : function(el){\r
+ return Ext.getDom(el);\r
+ },\r
+ \r
<div id="method-Ext.CompositeElementLite-getCount"></div>/**\r
* Returns the number of elements in this Composite.\r
* @return Number\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
- yels.push(e);\r
- });\r
- }\r
+ add : function(els, root){\r
+ var me = this,\r
+ elements = me.elements;\r
+ if(!els){\r
+ return this;\r
}\r
- return this;\r
+ if(Ext.isString(els)){\r
+ els = Ext.Element.selectorFunction(els, root);\r
+ }else if(els.isComposite){\r
+ els = els.elements;\r
+ }else if(!Ext.isIterable(els)){\r
+ els = [els];\r
+ }\r
+ \r
+ for(var i = 0, len = els.length; i < len; ++i){\r
+ elements.push(me.transformElement(els[i]));\r
+ }\r
+ return me;\r
},\r
+ \r
invoke : function(fn, args){\r
- var els = this.elements,\r
- el = this.el; \r
- Ext.each(els, function(e) { \r
- el.dom = e;\r
- Ext.Element.prototype[fn].apply(el, args);\r
- });\r
- return this;\r
+ var me = this,\r
+ els = me.elements,\r
+ len = els.length, \r
+ e;\r
+ \r
+ for(i = 0; i<len; i++) {\r
+ e = els[i];\r
+ if(e){\r
+ Ext.Element.prototype[fn].apply(me.getElement(e), args);\r
+ }\r
+ }\r
+ return me;\r
},\r
<div id="method-Ext.CompositeElementLite-item"></div>/**\r
* Returns a flyweight Element of the dom element object at the specified index\r
* @return {Ext.Element}\r
*/\r
item : function(index){\r
- var me = this;\r
- if(!me.elements[index]){\r
- return null;\r
+ var me = this,\r
+ el = me.elements[index],\r
+ out = null;\r
+\r
+ if(el){\r
+ out = me.getElement(el);\r
}\r
- me.el.dom = me.elements[index];\r
- return me.el;\r
+ return out;\r
},\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
- });\r
+ var els = this.elements,\r
+ len = els.length,\r
+ i, e;\r
+ \r
+ for(i = 0; i<len; i++) {\r
+ e = els[i];\r
+ if(e) {\r
+ Ext.EventManager.on(e, eventName, handler, scope || e, opt);\r
+ }\r
+ }\r
return this;\r
},\r
<div id="method-Ext.CompositeElementLite-each"></div>/**\r
*/\r
each : function(fn, scope){ \r
var me = this,\r
- el = me.el;\r
- \r
- Ext.each(me.elements, function(e,i) { \r
- el.dom = e;\r
- return fn.call(scope || el, el, me, i);\r
- });\r
+ els = me.elements,\r
+ len = els.length,\r
+ i, e;\r
+ \r
+ for(i = 0; i<len; i++) {\r
+ e = els[i];\r
+ if(e){\r
+ e = this.getElement(e);\r
+ if(fn.call(scope || e, e, me, i)){\r
+ break;\r
+ }\r
+ }\r
+ }\r
return me;\r
},\r
\r
filter : function(selector){\r
var els = [],\r
me = this,\r
+ elements = me.elements,\r
fn = Ext.isFunction(selector) ? selector\r
: function(el){\r
return el.is(selector);\r
- }\r
+ };\r
+ \r
+ \r
me.each(function(el, self, i){\r
if(fn(el, i) !== false){\r
- els[els.length] = el.dom;\r
+ els[els.length] = me.transformElement(el);\r
}\r
});\r
- me.fill(els);\r
+ me.elements = els;\r
return me;\r
},\r
\r
* @return Number The index of the passed Ext.Element in the composite collection, or -1 if not found.\r
*/\r
indexOf : function(el){\r
- return this.elements.indexOf(Ext.getDom(el));\r
+ return this.elements.indexOf(this.transformElement(el));\r
},\r
\r
<div id="method-Ext.CompositeElementLite-replaceElement"></div>/**\r
* to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
* {@link Ext.CompositeElementLite CompositeElementLite} object.\r
* @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object) <b>Not supported in core</b>\r
* @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
* @return {CompositeElementLite/CompositeElement}\r
* @member Ext.Element\r
* @method select\r
*/\r
-Ext.Element.select = function(selector, unique, root){\r
+Ext.Element.select = function(selector, root){\r
var els;\r
if(typeof selector == "string"){\r
els = Ext.Element.selectorFunction(selector, root);\r
* to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
* {@link Ext.CompositeElementLite CompositeElementLite} object.\r
* @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)\r
* @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
* @return {CompositeElementLite/CompositeElement}\r
* @member Ext\r
* @method select\r
*/\r
-Ext.select = Ext.Element.select;</pre>
-</body>
+Ext.select = Ext.Element.select;</pre> \r
+</body>\r
</html>
\ No newline at end of file