X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6:/docs/source/Element.style.html diff --git a/docs/source/Element.style.html b/docs/source/Element.style.html index 0f1eb23c..23dc3b82 100644 --- a/docs/source/Element.style.html +++ b/docs/source/Element.style.html @@ -1,24 +1,31 @@ - - - - The source code - - - - -
/**
+
+
+      
+  The source code
+    
+    
+
+
+    
/*!
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
+ */
+/**
  * @class Ext.Element
  */
 Ext.Element.addMethods(function(){
     // local style camelizing for speed
-    var propCache = {},
+    var supports = Ext.supports,
+        propCache = {},
         camelRe = /(-[a-z])/gi,
-        classReCache = {},
         view = document.defaultView,
-        propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat',
         opacityRe = /alpha\(opacity=(.*)\)/i,
         trimRe = /^\s+|\s+$/g,
         EL = Ext.Element,
+        spacesRe = /\s+/,
+        wordsRe = /\w/g,
         PADDING = "padding",
         MARGIN = "margin",
         BORDER = "border",
@@ -47,14 +54,14 @@ Ext.Element.addMethods(function(){
     }
 
     function chkCache(prop) {
-        return propCache[prop] || (propCache[prop] = prop == 'float' ? propFloat : prop.replace(camelRe, camelFn));
+        return propCache[prop] || (propCache[prop] = prop == 'float' ? (supports.cssFloat ? 'cssFloat' : 'styleFloat') : prop.replace(camelRe, camelFn));
     }
 
     return {
         // private  ==> used by Fx
         adjustWidth : function(width) {
             var me = this;
-            var isNum = Ext.isNumber(width);
+            var isNum = (typeof width == "number");
             if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
                width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
             }
@@ -64,7 +71,7 @@ Ext.Element.addMethods(function(){
         // private   ==> used by Fx
         adjustHeight : function(height) {
             var me = this;
-            var isNum = Ext.isNumber(height);
+            var isNum = (typeof height == "number");
             if(isNum && me.autoBoxAdjust && !me.isBorderBox()){
                height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
             }
@@ -78,14 +85,60 @@ Ext.Element.addMethods(function(){
          * @return {Ext.Element} this
          */
         addClass : function(className){
-            var me = this, i, len, v;
-            className = Ext.isArray(className) ? className : [className];
-            for (i=0, len = className.length; i < len; i++) {
-                v = className[i];
-                if (v) {
-                    me.dom.className += (!me.hasClass(v) && v ? " " + v : "");
-                };
-            };
+            var me = this,
+                i,
+                len,
+                v,
+                cls = [];
+            // Separate case is for speed
+            if (!Ext.isArray(className)) {
+                if (typeof className == 'string' && !this.hasClass(className)) {
+                    me.dom.className += " " + className;
+                }
+            }
+            else {
+                for (i = 0, len = className.length; i < len; i++) {
+                    v = className[i];
+                    if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) {
+                        cls.push(v);
+                    }
+                }
+                if (cls.length) {
+                    me.dom.className += " " + cls.join(" ");
+                }
+            }
+            return me;
+        },
+
+        
/** + * Removes one or more CSS classes from the element. + * @param {String/Array} className The CSS class to remove, or an array of classes + * @return {Ext.Element} this + */ + removeClass : function(className){ + var me = this, + i, + idx, + len, + cls, + elClasses; + if (!Ext.isArray(className)){ + className = [className]; + } + if (me.dom && me.dom.className) { + elClasses = me.dom.className.replace(trimRe, '').split(spacesRe); + for (i = 0, len = className.length; i < len; i++) { + cls = className[i]; + if (typeof cls == 'string') { + cls = cls.replace(trimRe, ''); + idx = elClasses.indexOf(cls); + if (idx != -1) { + elClasses.splice(idx, 1); + } + } + } + me.dom.className = elClasses.join(" "); + } return me; }, @@ -95,38 +148,20 @@ Ext.Element.addMethods(function(){ * @return {Ext.Element} this */ radioClass : function(className){ - var cn = this.dom.parentNode.childNodes, v; + var cn = this.dom.parentNode.childNodes, + v, + i, + len; className = Ext.isArray(className) ? className : [className]; - for (var i=0, len = cn.length; i < len; i++) { + for (i = 0, len = cn.length; i < len; i++) { v = cn[i]; - if(v && v.nodeType == 1) { + if (v && v.nodeType == 1) { Ext.fly(v, '_internal').removeClass(className); } }; return this.addClass(className); }, -
/** - * Removes one or more CSS classes from the element. - * @param {String/Array} className The CSS class to remove, or an array of classes - * @return {Ext.Element} this - */ - removeClass : function(className){ - var me = this, v; - className = Ext.isArray(className) ? className : [className]; - if (me.dom && me.dom.className) { - for (var i=0, len=className.length; i < len; i++) { - v = className[i]; - if(v) { - me.dom.className = me.dom.className.replace( - classReCache[v] = classReCache[v] || new RegExp('(?:^|\\s+)' + v + '(?:\\s+|$)', "g"), " " - ); - } - }; - } - return me; - }, -
/** * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it). * @param {String} className The CSS class to toggle @@ -171,29 +206,26 @@ Ext.Element.addMethods(function(){ v, cs, out, - display, - wk = Ext.isWebKit, display; - + if(el == document){ return null; } prop = chkCache(prop); - // Fix bug caused by this: https://bugs.webkit.org/show_bug.cgi?id=13343 - if(wk && /marginRight/.test(prop)){ - display = this.getStyle('display'); - el.style.display = 'inline-block'; - } out = (v = el.style[prop]) ? v : (cs = view.getComputedStyle(el, "")) ? cs[prop] : null; - - // Webkit returns rgb values for transparent. - if(wk){ - if(out == 'rgba(0, 0, 0, 0)'){ - out = 'transparent'; - }else if(display){ - el.style.display = display; - } + + // Ignore cases when the margin is correctly reported as 0, the bug only shows + // numbers larger. + if(prop == 'marginRight' && out != '0px' && !supports.correctRightMargin){ + display = el.style.display; + el.style.display = 'inline-block'; + out = view.getComputedStyle(el, '').marginRight; + el.style.display = display; + } + + if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.correctTransparentColor){ + out = 'transparent'; } return out; } : @@ -229,10 +261,10 @@ Ext.Element.addMethods(function(){ */ getColor : function(attr, defaultValue, prefix){ var v = this.getStyle(attr), - color = Ext.isDefined(prefix) ? prefix : '#', + color = (typeof prefix != 'undefined') ? prefix : '#', h; - if(!v || /transparent|inherit/.test(v)){ + if(!v || (/transparent|inherit/.test(v))) { return defaultValue; } if(/^r/.test(v)){ @@ -254,10 +286,9 @@ Ext.Element.addMethods(function(){ * @return {Ext.Element} this */ setStyle : function(prop, value){ - var tmp, - style, - camel; - if (!Ext.isObject(prop)) { + var tmp, style; + + if (typeof prop != 'object') { tmp = {}; tmp[prop] = value; prop = tmp; @@ -458,22 +489,26 @@ Ext.fly('elId').setHeight(150, { // private addStyles : function(sides, styles){ - var val = 0, - m = sides.match(/\w/g), - s; - for (var i=0, len=m.length; i - +
+ \ No newline at end of file