Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / CompositeElementLite-more.html
1 <html>\r
2 <head>\r
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
4   <title>The source code</title>\r
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
7 </head>\r
8 <body  onload="prettyPrint();">\r
9     <pre class="prettyprint lang-js">/**\r
10  * @class Ext.CompositeElementLite\r
11  */\r
12 Ext.apply(Ext.CompositeElementLite.prototype, { \r
13         addElements : function(els, root){\r
14         if(!els){\r
15             return this;\r
16         }\r
17         if(typeof els == "string"){\r
18             els = Ext.Element.selectorFunction(els, root);\r
19         }\r
20         var yels = this.elements;        \r
21             Ext.each(els, function(e) {\r
22                 yels.push(Ext.get(e));\r
23         });\r
24         return this;\r
25     },\r
26     \r
27     <div id="method-Ext.CompositeElementLite-first"></div>/**\r
28      * Returns the first Element\r
29      * @return {Ext.Element}\r
30      */\r
31     first : function(){\r
32         return this.item(0);\r
33     },   \r
34     \r
35     <div id="method-Ext.CompositeElementLite-last"></div>/**\r
36      * Returns the last Element\r
37      * @return {Ext.Element}\r
38      */\r
39     last : function(){\r
40         return this.item(this.getCount()-1);\r
41     },\r
42     \r
43     <div id="method-Ext.CompositeElementLite-contains"></div>/**\r
44      * Returns true if this composite contains the passed element\r
45      * @param el {Mixed} The id of an element, or an Ext.Element, or an HtmlElement to find within the composite collection.\r
46      * @return Boolean\r
47      */\r
48     contains : function(el){\r
49         return this.indexOf(el) != -1;\r
50     },
51     
52     <div id="method-Ext.CompositeElementLite-removeElement"></div>/**\r
53     * Removes the specified element(s).\r
54     * @param {Mixed} el The id of an element, the Element itself, the index of the element in this composite\r
55     * or an array of any of those.\r
56     * @param {Boolean} removeDom (optional) True to also remove the element from the document\r
57     * @return {CompositeElement} this\r
58     */\r
59     removeElement : function(keys, removeDom){\r
60         var me = this,\r
61                 els = this.elements,        \r
62                 el;             \r
63             Ext.each(keys, function(val){\r
64                     if ((el = (els[val] || els[val = me.indexOf(val)]))) {\r
65                         if(removeDom){\r
66                     if(el.dom){\r
67                         el.remove();\r
68                     }else{\r
69                         Ext.removeNode(el);\r
70                     }\r
71                 }\r
72                         els.splice(val, 1);                     \r
73                         }\r
74             });\r
75         return this;\r
76     }    \r
77 });
78 </pre>    \r
79 </body>\r
80 </html>