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