Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / core / src / dom / CompositeElementLite.js
similarity index 84%
rename from src/ext-core/src/core/CompositeElementLite.js
rename to src/core/src/dom/CompositeElementLite.js
index a8cd3ff..039a42d 100644 (file)
@@ -1,15 +1,9 @@
-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
 /**
  * @class Ext.CompositeElementLite
  * <p>This class encapsulates a <i>collection</i> of DOM elements, providing methods to filter
  * members, or to perform collective actions upon the whole set.</p>
- * <p>Although they are not listed, this class supports all of the methods of {@link Ext.Element} and
- * {@link Ext.Fx}. The methods from these classes will be performed on all the elements in this collection.</p>
+ * <p>Although they are not listed, this class supports all of the methods of {@link Ext.core.Element} and
+ * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.</p>
  * Example:<pre><code>
 var els = Ext.select("#some-el div.some-class");
 // or select directly from an existing element
@@ -20,7 +14,7 @@ els.setWidth(100); // all elements become 100 width
 els.hide(true); // all elements fade out and hide
 // or
 els.setWidth(100).hide(true);
-</code>
+</code></pre>
  */
 Ext.CompositeElementLite = function(els, root){
     /**
@@ -51,7 +45,7 @@ Ext.override(Ext.CompositeElementLite, {
      */
     this.elements = [];
     this.add(els, root);
-    this.el = new Ext.Element.Flyweight();
+    this.el = new Ext.core.Element.Flyweight();
 };
 
 Ext.CompositeElementLite.prototype = {
@@ -90,7 +84,7 @@ Ext.CompositeElementLite.prototype = {
             return this;
         }
         if(typeof els == "string"){
-            els = Ext.Element.selectorFunction(els, root);
+            els = Ext.core.Element.selectorFunction(els, root);
         }else if(els.isComposite){
             els = els.elements;
         }else if(!Ext.isIterable(els)){
@@ -113,7 +107,7 @@ Ext.CompositeElementLite.prototype = {
         for(i = 0; i < len; i++) {
             e = els[i];
             if(e){
-                Ext.Element.prototype[fn].apply(me.getElement(e), args);
+                Ext.core.Element.prototype[fn].apply(me.getElement(e), args);
             }
         }
         return me;
@@ -121,7 +115,7 @@ Ext.CompositeElementLite.prototype = {
     /**
      * Returns a flyweight Element of the dom element object at the specified index
      * @param {Number} index
-     * @return {Ext.Element}
+     * @return {Ext.core.Element}
      */
     item : function(index){
         var me = this,
@@ -152,7 +146,7 @@ Ext.CompositeElementLite.prototype = {
      * <p>Calls the passed function for each element in this composite.</p>
      * @param {Function} fn The function to call. The function is passed the following parameters:<ul>
      * <li><b>el</b> : Element<div class="sub-desc">The current Element in the iteration.
-     * <b>This is the flyweight (shared) Ext.Element instance, so if you require a
+     * <b>This is the flyweight (shared) Ext.core.Element instance, so if you require a
      * a reference to the dom node, use el.dom.</b></div></li>
      * <li><b>c</b> : Composite<div class="sub-desc">This Composite object.</div></li>
      * <li><b>idx</b> : Number<div class="sub-desc">The zero-based index in the iteration.</div></li>
@@ -194,7 +188,7 @@ Ext.CompositeElementLite.prototype = {
      * Filters this composite to only elements that match the passed selector.
      * @param {String/Function} selector A string CSS selector or a comparison function.
      * The comparison function will be called with the following arguments:<ul>
-     * <li><code>el</code> : Ext.Element<div class="sub-desc">The current DOM element.</div></li>
+     * <li><code>el</code> : Ext.core.Element<div class="sub-desc">The current DOM element.</div></li>
      * <li><code>index</code> : Number<div class="sub-desc">The current index within the collection.</div></li>
      * </ul>
      * @return {CompositeElement} this
@@ -219,11 +213,11 @@ Ext.CompositeElementLite.prototype = {
 
     /**
      * Find the index of the passed element within the composite collection.
-     * @param el {Mixed} The id of an element, or an Ext.Element, or an HtmlElement to find within the composite collection.
-     * @return Number The index of the passed Ext.Element in the composite collection, or -1 if not found.
+     * @param el {Mixed} The id of an element, or an Ext.core.Element, or an HtmlElement to find within the composite collection.
+     * @return Number The index of the passed Ext.core.Element in the composite collection, or -1 if not found.
      */
     indexOf : function(el){
-        return this.elements.indexOf(this.transformElement(el));
+        return Ext.Array.indexOf(this.elements, this.transformElement(el));
     },
 
     /**
@@ -261,13 +255,13 @@ Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addLi
 
 /**
  * @private
- * Copies all of the functions from Ext.Element's prototype onto CompositeElementLite's prototype.
- * This is called twice - once immediately below, and once again after additional Ext.Element
+ * Copies all of the functions from Ext.core.Element's prototype onto CompositeElementLite's prototype.
+ * This is called twice - once immediately below, and once again after additional Ext.core.Element
  * are added in Ext JS
  */
 Ext.CompositeElementLite.importElementMethods = function() {
     var fnName,
-        ElProto = Ext.Element.prototype,
+        ElProto = Ext.core.Element.prototype,
         CelProto = Ext.CompositeElementLite.prototype;
 
     for (fnName in ElProto) {
@@ -285,32 +279,40 @@ Ext.CompositeElementLite.importElementMethods = function() {
 Ext.CompositeElementLite.importElementMethods();
 
 if(Ext.DomQuery){
-    Ext.Element.selectorFunction = Ext.DomQuery.select;
+    Ext.core.Element.selectorFunction = Ext.DomQuery.select;
 }
 
 /**
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
+ * Selects elements based on the passed CSS selector to enable {@link Ext.core.Element Element} methods
  * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  * {@link Ext.CompositeElementLite CompositeElementLite} object.
  * @param {String/Array} selector The CSS selector or an array of elements
  * @param {HTMLElement/String} root (optional) The root element of the query or id of the root
  * @return {CompositeElementLite/CompositeElement}
- * @member Ext.Element
+ * @member Ext.core.Element
  * @method select
  */
-Ext.Element.select = function(selector, root){
+Ext.core.Element.select = function(selector, root){
     var els;
     if(typeof selector == "string"){
-        els = Ext.Element.selectorFunction(selector, root);
+        els = Ext.core.Element.selectorFunction(selector, root);
     }else if(selector.length !== undefined){
         els = selector;
     }else{
-        throw "Invalid selector";
+        //<debug>
+        Ext.Error.raise({
+            sourceClass: "Ext.core.Element",
+            sourceMethod: "select",
+            selector: selector,
+            root: root,
+            msg: "Invalid selector specified: " + selector
+        });
+        //</debug>
     }
     return new Ext.CompositeElementLite(els);
 };
 /**
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
+ * Selects elements based on the passed CSS selector to enable {@link Ext.core.Element Element} methods
  * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  * {@link Ext.CompositeElementLite CompositeElementLite} object.
  * @param {String/Array} selector The CSS selector or an array of elements
@@ -319,4 +321,4 @@ Ext.Element.select = function(selector, root){
  * @member Ext
  * @method select
  */
-Ext.select = Ext.Element.select;
+Ext.select = Ext.core.Element.select;