Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / Element.insertion-more.html
index d2d87aa..2c2f2b5 100644 (file)
@@ -1,17 +1,12 @@
-<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"><div id="cls-Ext.Element"></div>/**\r
  * @class Ext.Element\r
  */\r
 Ext.apply(Ext.Element.prototype, function() {\r
@@ -25,37 +20,42 @@ Ext.apply(Ext.Element.prototype, function() {
             * @param {Mixed/Object/Array} el The id, element to insert or a DomHelper config to create and insert *or* an array of any of those.\r
             * @param {String} where (optional) 'before' or 'after' defaults to before\r
             * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element\r
-            * @return {Ext.Element} the inserted Element\r
+            * @return {Ext.Element} The inserted Element. If an array is passed, the last inserted element is returned.\r
             */\r
            insertSibling: function(el, where, returnDom){\r
                var me = this,\r
-                       rt;\r
+                       rt,\r
+                isAfter = (where || 'before').toLowerCase() == 'after',\r
+                insertEl;\r
                        \r
-               if(Ext.isArray(el)){            \r
+               if(Ext.isArray(el)){\r
+                insertEl = me;\r
                    Ext.each(el, function(e) {\r
-                           rt = me.insertSibling(e, where, returnDom);\r
+                           rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);\r
+                    if(isAfter){\r
+                        insertEl = rt;\r
+                    }\r
                    });\r
                    return rt;\r
                }\r
                        \r
-               where = (where || 'before').toLowerCase();\r
                el = el || {};\r
                \r
             if(el.nodeType || el.dom){\r
-                rt = me.dom.parentNode.insertBefore(GETDOM(el), where == 'before' ? me.dom : me.dom.nextSibling);\r
+                rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);\r
                 if (!returnDom) {\r
                     rt = GET(rt);\r
                 }\r
             }else{\r
-                if (where == 'after' && !me.dom.nextSibling) {\r
+                if (isAfter && !me.dom.nextSibling) {\r
                     rt = DH.append(me.dom.parentNode, el, !returnDom);\r
                 } else {                    \r
-                    rt = DH[where == 'after' ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);\r
+                    rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);\r
                 }\r
             }\r
                return rt;\r
            }\r
     };\r
-}());</pre>
-</body>
+}());</pre>    \r
+</body>\r
 </html>
\ No newline at end of file