Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / DomHelper-more.html
index d8c3453..8dea4d2 100644 (file)
-<html>\r
-<head>\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">/**\r
- * @class Ext.DomHelper\r
- */\r
-Ext.apply(Ext.DomHelper,\r
-function(){\r
-       var pub,\r
-               afterbegin = 'afterbegin',\r
-       afterend = 'afterend',\r
-       beforebegin = 'beforebegin',\r
-       beforeend = 'beforeend';\r
-\r
-       // private\r
-    function doInsert(el, o, returnElement, pos, sibling, append){\r
-        el = Ext.getDom(el);\r
-        var newNode;\r
-        if (pub.useDom) {\r
-            newNode = createDom(o, null);\r
-            if (append) {\r
-                   el.appendChild(newNode);\r
-            } else {\r
-                       (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);\r
-            }\r
-        } else {\r
-            newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));\r
-        }\r
-        return returnElement ? Ext.get(newNode, true) : newNode;\r
-    }\r
-\r
-       // build as dom\r
-    /** @ignore */\r
-    function createDom(o, parentNode){\r
-        var el,\r
-               doc = document,\r
-               useSet,\r
-               attr,\r
-               val,\r
-               cn;\r
-\r
-        if (Ext.isArray(o)) {                       // Allow Arrays of siblings to be inserted\r
-            el = doc.createDocumentFragment(); // in one shot using a DocumentFragment\r
-               Ext.each(o, function(v) {\r
-                createDom(v, el);\r
-            });\r
-        } else if (Ext.isString(o)) {         // Allow a string as a child spec.\r
-            el = doc.createTextNode(o);\r
-        } else {\r
-            el = doc.createElement( o.tag || 'div' );\r
-            useSet = !!el.setAttribute; // In IE some elements don't have setAttribute\r
-            Ext.iterate(o, function(attr, val){\r
-                if(!/tag|children|cn|html|style/.test(attr)){\r
-                       if(attr == 'cls'){\r
-                           el.className = val;\r
-                       }else{\r
-                        if(useSet){\r
-                            el.setAttribute(attr, val);\r
-                        }else{\r
-                            el[attr] = val;\r
-                        }\r
-                       }\r
-                }\r
-            });\r
-            pub.applyStyles(el, o.style);\r
-\r
-            if ((cn = o.children || o.cn)) {\r
-                createDom(cn, el);\r
-            } else if (o.html) {\r
-                el.innerHTML = o.html;\r
-            }\r
-        }\r
-        if(parentNode){\r
-           parentNode.appendChild(el);\r
-        }\r
-        return el;\r
-    }\r
-\r
-       pub = {\r
-               <div id="method-Ext.DomHelper-createTemplate"></div>/**\r
-            * Creates a new Ext.Template from the DOM object spec.\r
-            * @param {Object} o The DOM object spec (and children)\r
-            * @return {Ext.Template} The new template\r
-            */\r
-           createTemplate : function(o){\r
-               var html = Ext.DomHelper.createHtml(o);\r
-               return new Ext.Template(html);\r
-           },\r
-\r
-               <div id="prop-Ext.DomHelper-useDom"></div>/** True to force the use of DOM instead of html fragments @type Boolean */\r
-           useDom : false,\r
-\r
-           <div id="method-Ext.DomHelper-applyStyles"></div>/**\r
-            * Applies a style specification to an element.\r
-            * @param {String/HTMLElement} el The element to apply styles to\r
-            * @param {String/Object/Function} styles A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or\r
-            * a function which returns such a specification.\r
-            */\r
-           applyStyles : function(el, styles){\r
-                   if(styles){\r
-                               var i = 0,\r
-                               len,\r
-                               style;\r
-\r
-                       el = Ext.fly(el);\r
-                               if(Ext.isFunction(styles)){\r
-                                       styles = styles.call();\r
-                               }\r
-                               if(Ext.isString(styles)){\r
-                                       styles = styles.trim().split(/\s*(?::|;)\s*/);\r
-                                       for(len = styles.length; i < len;){\r
-                                               el.setStyle(styles[i++], styles[i++]);\r
-                                       }\r
-                               }else if (Ext.isObject(styles)){\r
-                                       el.setStyle(styles);\r
-                               }\r
-                       }\r
-           },\r
-\r
-           <div id="method-Ext.DomHelper-insertBefore"></div>/**\r
-            * Creates new DOM element(s) and inserts them before el.\r
-            * @param {Mixed} el The context element\r
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\r
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element\r
-            * @return {HTMLElement/Ext.Element} The new node\r
-         * @hide (repeat)\r
-            */\r
-           insertBefore : function(el, o, returnElement){\r
-               return doInsert(el, o, returnElement, beforebegin);\r
-           },\r
-\r
-           <div id="method-Ext.DomHelper-insertAfter"></div>/**\r
-            * Creates new DOM element(s) and inserts them after el.\r
-            * @param {Mixed} el The context element\r
-            * @param {Object} o The DOM object spec (and children)\r
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element\r
-            * @return {HTMLElement/Ext.Element} The new node\r
-         * @hide (repeat)\r
-            */\r
-           insertAfter : function(el, o, returnElement){\r
-               return doInsert(el, o, returnElement, afterend, 'nextSibling');\r
-           },\r
-\r
-           <div id="method-Ext.DomHelper-insertFirst"></div>/**\r
-            * Creates new DOM element(s) and inserts them as the first child of el.\r
-            * @param {Mixed} el The context element\r
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\r
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element\r
-            * @return {HTMLElement/Ext.Element} The new node\r
-         * @hide (repeat)\r
-            */\r
-           insertFirst : function(el, o, returnElement){\r
-               return doInsert(el, o, returnElement, afterbegin, 'firstChild');\r
-           },\r
-\r
-           <div id="method-Ext.DomHelper-append"></div>/**\r
-            * Creates new DOM element(s) and appends them to el.\r
-            * @param {Mixed} el The context element\r
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\r
-            * @param {Boolean} returnElement (optional) true to return a Ext.Element\r
-            * @return {HTMLElement/Ext.Element} The new node\r
-         * @hide (repeat)\r
-            */\r
-           append: function(el, o, returnElement){\r
-            return doInsert(el, o, returnElement, beforeend, '', true);\r
-        },\r
-\r
-           <div id="method-Ext.DomHelper-createDom"></div>/**\r
-            * Creates new DOM element(s) without inserting them to the document.\r
-            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\r
-            * @return {HTMLElement} The new uninserted node\r
-            */\r
-        createDom: createDom\r
-       };\r
-       return pub;\r
-}());</pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <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.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/**
+ * @class Ext.DomHelper
+ */
+Ext.apply(Ext.DomHelper,
+function(){
+       var pub,
+               afterbegin = 'afterbegin',
+       afterend = 'afterend',
+       beforebegin = 'beforebegin',
+       beforeend = 'beforeend';
+
+       // private
+    function doInsert(el, o, returnElement, pos, sibling, append){
+        el = Ext.getDom(el);
+        var newNode;
+        if (pub.useDom) {
+            newNode = createDom(o, null);
+            if (append) {
+                   el.appendChild(newNode);
+            } else {
+                       (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
+            }
+        } else {
+            newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
+        }
+        return returnElement ? Ext.get(newNode, true) : newNode;
+    }
+
+       // build as dom
+    /** @ignore */
+    function createDom(o, parentNode){
+        var el,
+               doc = document,
+               useSet,
+               attr,
+               val,
+               cn;
+
+        if (Ext.isArray(o)) {                       // Allow Arrays of siblings to be inserted
+            el = doc.createDocumentFragment(); // in one shot using a DocumentFragment
+               Ext.each(o, function(v) {
+                createDom(v, el);
+            });
+        } else if (Ext.isString(o)) {         // Allow a string as a child spec.
+            el = doc.createTextNode(o);
+        } else {
+            el = doc.createElement( o.tag || 'div' );
+            useSet = !!el.setAttribute; // In IE some elements don't have setAttribute
+            Ext.iterate(o, function(attr, val){
+                if(!/tag|children|cn|html|style/.test(attr)){
+                       if(attr == 'cls'){
+                           el.className = val;
+                       }else{
+                        if(useSet){
+                            el.setAttribute(attr, val);
+                        }else{
+                            el[attr] = val;
+                        }
+                       }
+                }
+            });
+            Ext.DomHelper.applyStyles(el, o.style);
+
+            if ((cn = o.children || o.cn)) {
+                createDom(cn, el);
+            } else if (o.html) {
+                el.innerHTML = o.html;
+            }
+        }
+        if(parentNode){
+           parentNode.appendChild(el);
+        }
+        return el;
+    }
+
+       pub = {
+               <div id="method-Ext.DomHelper-createTemplate"></div>/**
+            * Creates a new Ext.Template from the DOM object spec.
+            * @param {Object} o The DOM object spec (and children)
+            * @return {Ext.Template} The new template
+            */
+           createTemplate : function(o){
+               var html = Ext.DomHelper.createHtml(o);
+               return new Ext.Template(html);
+           },
+
+               <div id="prop-Ext.DomHelper-useDom"></div>/** True to force the use of DOM instead of html fragments @type Boolean */
+           useDom : false,
+
+           <div id="method-Ext.DomHelper-insertBefore"></div>/**
+            * Creates new DOM element(s) and inserts them before el.
+            * @param {Mixed} el The context element
+            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+            * @param {Boolean} returnElement (optional) true to return a Ext.Element
+            * @return {HTMLElement/Ext.Element} The new node
+         * @hide (repeat)
+            */
+           insertBefore : function(el, o, returnElement){
+               return doInsert(el, o, returnElement, beforebegin);
+           },
+
+           <div id="method-Ext.DomHelper-insertAfter"></div>/**
+            * Creates new DOM element(s) and inserts them after el.
+            * @param {Mixed} el The context element
+            * @param {Object} o The DOM object spec (and children)
+            * @param {Boolean} returnElement (optional) true to return a Ext.Element
+            * @return {HTMLElement/Ext.Element} The new node
+         * @hide (repeat)
+            */
+           insertAfter : function(el, o, returnElement){
+               return doInsert(el, o, returnElement, afterend, 'nextSibling');
+           },
+
+           <div id="method-Ext.DomHelper-insertFirst"></div>/**
+            * Creates new DOM element(s) and inserts them as the first child of el.
+            * @param {Mixed} el The context element
+            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+            * @param {Boolean} returnElement (optional) true to return a Ext.Element
+            * @return {HTMLElement/Ext.Element} The new node
+         * @hide (repeat)
+            */
+           insertFirst : function(el, o, returnElement){
+               return doInsert(el, o, returnElement, afterbegin, 'firstChild');
+           },
+
+           <div id="method-Ext.DomHelper-append"></div>/**
+            * Creates new DOM element(s) and appends them to el.
+            * @param {Mixed} el The context element
+            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+            * @param {Boolean} returnElement (optional) true to return a Ext.Element
+            * @return {HTMLElement/Ext.Element} The new node
+         * @hide (repeat)
+            */
+           append: function(el, o, returnElement){
+            return doInsert(el, o, returnElement, beforeend, '', true);
+        },
+
+           <div id="method-Ext.DomHelper-createDom"></div>/**
+            * Creates new DOM element(s) without inserting them to the document.
+            * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
+            * @return {HTMLElement} The new uninserted node
+            */
+        createDom: createDom
+       };
+       return pub;
+}());</pre>    
+</body>
 </html>
\ No newline at end of file