Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / docs / source / Element-more.html
index 38607fa..5b306d2 100644 (file)
@@ -7,12 +7,12 @@
 </head>
 <body  onload="prettyPrint();">
     <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.2.2
+ * Ext JS Library 3.3.0
  * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
-<div id="cls-Ext.Element"></div>/**
+/**
  * @class Ext.Element
  */
 Ext.Element.addMethods({
@@ -22,15 +22,16 @@ Ext.Element.addMethods({
      * @param {Boolean} preventDefault (optional) true to prevent the default action too
      * @return {Ext.Element} this
      */
-    swallowEvent : function(eventName, preventDefault){
+    swallowEvent : function(eventName, preventDefault) {
         var me = this;
-        function fn(e){
+        function fn(e) {
             e.stopPropagation();
-            if(preventDefault){
+            if (preventDefault) {
                 e.preventDefault();
             }
         }
-        if(Ext.isArray(eventName)){
+        
+        if (Ext.isArray(eventName)) {
             Ext.each(eventName, function(e) {
                  me.on(e, fn);
             });
@@ -47,8 +48,8 @@ Ext.Element.addMethods({
      * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
      * for firing the relayed event
      */
-    relayEvent : function(eventName, observable){
-        this.on(eventName, function(e){
+    relayEvent : function(eventName, observable) {
+        this.on(eventName, function(e) {
             observable.fireEvent(eventName, e);
         });
     },
@@ -60,25 +61,26 @@ Ext.Element.addMethods({
      * you can call this over and over. However, if you update the element and
      * need to force a reclean, you can pass true.
      */
-    clean : function(forceReclean){
-        var me = this,
+    clean : function(forceReclean) {
+        var me  = this,
             dom = me.dom,
-            n = dom.firstChild,
-            ni = -1;
+            n   = dom.firstChild,
+            ni  = -1;
 
-        if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
+        if (Ext.Element.data(dom, 'isCleaned') && forceReclean !== true) {
             return me;
         }
 
-        while(n){
+        while (n) {
             var nx = n.nextSibling;
-            if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
+            if (n.nodeType == 3 && !(/\S/.test(n.nodeValue))) {
                 dom.removeChild(n);
-            }else{
+            } else {
                 n.nodeIndex = ++ni;
             }
             n = nx;
         }
+        
         Ext.Element.data(dom, 'isCleaned', true);
         return me;
     },
@@ -88,9 +90,10 @@ Ext.Element.addMethods({
      * parameter as {@link Ext.Updater#update}
      * @return {Ext.Element} this
      */
-    load : function(){
-        var um = this.getUpdater();
-        um.update.apply(um, arguments);
+    load : function() {
+        var updateManager = this.getUpdater();
+        updateManager.update.apply(updateManager, arguments);
+        
         return this;
     },
 
@@ -98,7 +101,7 @@ Ext.Element.addMethods({
     * Gets this element's {@link Ext.Updater Updater}
     * @return {Ext.Updater} The Updater
     */
-    getUpdater : function(){
+    getUpdater : function() {
         return this.updateManager || (this.updateManager = new Ext.Updater(this));
     },
 
@@ -109,30 +112,30 @@ Ext.Element.addMethods({
     * @param {Function} callback (optional) For async script loading you can be notified when the update completes
     * @return {Ext.Element} this
      */
-    update : function(html, loadScripts, callback){
+    update : function(html, loadScripts, callback) {
         if (!this.dom) {
             return this;
         }
         html = html || "";
 
-        if(loadScripts !== true){
+        if (loadScripts !== true) {
             this.dom.innerHTML = html;
-            if(typeof callback == 'function'){
+            if (typeof callback == 'function') {
                 callback();
             }
             return this;
         }
 
-        var id = Ext.id(),
+        var id  = Ext.id(),
             dom = this.dom;
 
         html += '<span id="' + id + '"></span>';
 
-        Ext.lib.Event.onAvailable(id, function(){
-            var DOC = document,
-                hd = DOC.getElementsByTagName("head")[0],
-                re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
-                srcRe = /\ssrc=([\'\"])(.*?)\1/i,
+        Ext.lib.Event.onAvailable(id, function() {
+            var DOC    = document,
+                hd     = DOC.getElementsByTagName("head")[0],
+                re     = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
+                srcRe  = /\ssrc=([\'\"])(.*?)\1/i,
                 typeRe = /\stype=([\'\"])(.*?)\1/i,
                 match,
                 attrs,
@@ -141,28 +144,32 @@ Ext.Element.addMethods({
                 el,
                 s;
 
-            while((match = re.exec(html))){
+            while ((match = re.exec(html))) {
                 attrs = match[1];
                 srcMatch = attrs ? attrs.match(srcRe) : false;
-                if(srcMatch && srcMatch[2]){
+                if (srcMatch && srcMatch[2]) {
                    s = DOC.createElement("script");
                    s.src = srcMatch[2];
                    typeMatch = attrs.match(typeRe);
-                   if(typeMatch && typeMatch[2]){
+                   if (typeMatch && typeMatch[2]) {
                        s.type = typeMatch[2];
                    }
                    hd.appendChild(s);
-                }else if(match[2] && match[2].length > 0){
-                    if(window.execScript) {
+                } else if (match[2] && match[2].length > 0) {
+                    if (window.execScript) {
                        window.execScript(match[2]);
                     } else {
                        window.eval(match[2]);
                     }
                 }
             }
+            
             el = DOC.getElementById(id);
-            if(el){Ext.removeNode(el);}
-            if(typeof callback == 'function'){
+            if (el) {
+                Ext.removeNode(el);
+            }
+            
+            if (typeof callback == 'function') {
                 callback();
             }
         });
@@ -171,7 +178,7 @@ Ext.Element.addMethods({
     },
 
     // inherit docs, overridden so we can add removeAnchor
-    removeAllListeners : function(){
+    removeAllListeners : function() {
         this.removeAnchor();
         Ext.EventManager.removeAll(this.dom);
         return this;
@@ -184,14 +191,14 @@ Ext.Element.addMethods({
      * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
      * @return {Ext.Element} The new proxy element
      */
-    createProxy : function(config, renderTo, matchBox){
+    createProxy : function(config, renderTo, matchBox) {
         config = (typeof config == 'object') ? config : {tag : "div", cls: config};
 
         var me = this,
             proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
                                Ext.DomHelper.insertBefore(me.dom, config, true);
 
-        if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded
+        if (matchBox && me.setBox && me.getBox) { // check to make sure Element.position.js is loaded
            proxy.setBox(me.getBox());
         }
         return proxy;