PropNo : {},
UNIT : {
- 'px' : 0,
- 'em' : 1,
- 'cm' : 2,
- 'mm' : 3,
- 'in' : 4,
- '%' : 5,
- 'pct' : 5,
- 'ms' : 6,
- 's' : 7,
- '#' : 8,
- 'rgb' : 9,
+ 'px' : 0,
+ 'em' : 1,
+ 'cm' : 2,
+ 'mm' : 3,
+ 'in' : 4,
+ '%' : 5,
+ 'pct' : 5,
+ 'ms' : 6,
+ 's' : 7,
+ '#' : 8,
+ 'rgb' : 9,
'rgba' : 10
},
return css.join( ';' );
},
- _FONT_SIZE_RATIO : {},
+ _UNIT_RATIO : null,
+ _FONT_SIZE_RATIO : null,
absoluteFontSizeToPx : function( fontsize ){
return X.Dom.Style._FONT_SIZE_RATIO[ fontsize ] || 0;
args = arguments,
css = this._css,
p, valOrUnit, name, v, node, camelize;
- if( this._nodeType !== 1 ) return this;
+ if( this._xnodeType !== 1 ) return this;
// setter
if( X.Type.isObject( nameOrObj ) ){
if( !css ) css = this._css = {};
if( node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode ){
if( this._cssText ){
node.style.cssText = this._cssText;
+ this._styleText = ' style="' + this._cssText + '"';
} else {
node.removeAttribute( 'style' );
+ delete this._cssText;
+ delete this._styleText;
};
};
return this;
if( !css ) css = this._css = {};
name = XDomStyle.camelize( nameOrObj );
v = args[ 1 ];
+ node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
if( css[ name ] === v ) return this;
- if( node = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode ){
+ if( !v && v !== 0 ){
+ delete css[ name ];
+ if( node ){
+ node.style[ name ] = ''; // val
+ };
+ this._cssText = XDomStyle.objToCssText( css );
+ if( !this._cssText ){
+ delete this._cssText;
+ delete this._styleText;
+ node && node.removeAttribute( 'style' );
+ };
+ return this;
+ };
+ if( node ){
node.style[ name ] = v; // val
};
if( !css[ name ] ){
css[ name ] = v;
} else {
css[ name ] = v;
- // build _cssText
this._cssText = XDomStyle.objToCssText( css );
};
- node && !this._cssText && node.removeAttribute( 'style' );
+ this._styleText = ' style="' + this._cssText + '"';
return this;
};
// getter
});
-X.Dom.listenOnce( X.Dom.Event.DOM_PREINIT, function(){
-
+X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){
var testStyle = X.Dom._view;
X.Dom.Style.VENDER_PREFIX = (function(){
} );
X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
- var xnode = Node._systemNode;
-
- var ret = X.Dom.Style._UNIT_RATIO = {},
- unit,
- units = 'em,cm,mm,in,pt,pc'.split( ',' ),
- i = units.length;
+ var xnode = Node._systemNode,
+ output = X.Dom.Style._UNIT_RATIO = {},
+ list = 'em,cm,mm,in,pt,pc'.split( ',' ),
+ unit,size, base, i;
- for( ; i; ){
- unit = units[ --i ];
- xnode.css( 'width', 100 + unit );
- ret[ unit ] = xnode.width() / 100;
- console.log( unit + ':' + ret[ unit ] );
+ for( i = list.length; i; ){
+ unit = list[ --i ];
+ output[ unit ] = xnode.css( 'width', 100 + unit ).width() / 100;
};
- xnode.css( 'width', '' );
- var ret = X.Dom.Style._FONT_SIZE_RATIO = {},
- size, base,
- list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' ),
- i = list.length;
+ output = X.Dom.Style._FONT_SIZE_RATIO = {},
+ list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' );
+ base = xnode.css( 'lineHeight', 1 ).text( 'X' ).height();
- base = xnode.css( 'lineHeight', 1 ).text( 'X' ).height();
- for( ; i; ){
+ for( i = list.length; i; ){
size = list[ --i ];
- ret[ size ] = xnode.css( 'fontSize', size ).height() / base;
- console.log( size + ':' + ( ret[ size ] * 100 | 0 ) + '%' );
+ output[ size ] = xnode.css( 'fontSize', size ).height() / base;
};
xnode.empty().cssText( '' );