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