4 * style 値の変更は、enterFrame 後にまとめて適用
5 * width(), height(), x(), y() 1em の取得時にも適用
6 * css3 の ie用 fix は X.UI レベルで行う
30 AUTO : Number.POSITIVE_INFINITY,
31 FULL : X.Dom // something unigue value; 100%
51 /* font-size -> fontSize */
52 _DICTIONARY_CAMELIZE : {},
54 camelize : function( cssProp ){
56 parts, l, i, camelized;
58 if( camelized = me._DICTIONARY_CAMELIZE[ cssProp ] ) return camelized;
59 parts = cssProp.split( ' ' ).join( '' ).split( '-' );
61 if( l === 1 ) return parts[ 0 ];
63 camelized = cssProp.charAt(0) === '-'
64 ? parts[ 0 ].charAt( 0 ).toUpperCase() + parts[ 0 ].substring( 1 )
67 for( i = 1; i < l; ++i ){
68 camelized += parts[ i ].charAt( 0 ).toUpperCase() + parts[ i ].substring( 1 );
70 return me._DICTIONARY_CAMELIZE[ cssProp ] = camelized;
73 /* fontSize -> font-size */
76 uncamelize: function( str ){
77 return str.split( ' ' ).join( '' ).replace( X.Dom.Style.REG_LARGE, '-$&' ).toLowerCase();
80 CHAR_CODE_A : 'A'.charCodeAt( 0 ),
82 _DICTIONARY_UNCAMELIZE : {},
84 uncamelize : function( str ){
88 uncamelized, l, chr, code;
89 str = str.split( ' ' ).join( '' );
90 if( uncamelized = me._DICTIONARY_UNCAMELIZE[ str ] ) return uncamelized;
92 for( i = 0, l = str.length; i < l; ++i ){
93 chr = str.charAt( i );
94 code = chr.charCodeAt( 0 );
95 uncamelized += ( A <= code && code <= Z ) ? '-' + chr : chr;
97 return me._DICTIONARY_UNCAMELIZE[ str ] = uncamelized.toLowerCase();
101 * CSS における display, position, float プロパティの相互関係
102 * http://d.hatena.ne.jp/elm200/20080201/1201874740
104 * CSS21:9.7 Relationships between ’display’, ’position’, and ’float’
105 * http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo
107 * display:none? -yes-> 非表示
109 * position:absolute? -yes-> float:none,display:block;
111 * float:none? -no-> display:block;
116 display position float
117 block static|relative none
118 block static|relative right|left
120 inline static|relative none
127 objToCssText : function( obj ){
130 uncamelize = me.uncamelize,
131 VENDER_PREFIX = me.VENDER_PREFIX,
132 FIX_PROP = me.SPECIAL_FIX_PROP,
133 SPECIAL_FIX = me.SPECIAL_FIX,
137 name = uncamelize( p );
138 if( FIX_PROP[ name ] ){
141 css[ ++n ] = [ VENDER_PREFIX[ name ] || name, obj[ p ] ].join( ':' );
144 sp && ( css[ ++n ] = 'filter:' + SPECIAL_FIX( obj ) );
145 return css.join( ';' );
149 X.UA.IE && X.UA.IE < 9 ?
154 9 <= X.UA.IE && X.UA.IE < 10 ? // == 9
159 _FONT_SIZE_RATIO : null,
161 // https://developer.mozilla.org/en-US/docs/Web/CSS/transform
162 // Firefox 3.5, ie9, Opera 10.5, Safari 3.1, Chrome
163 // 3D support Firefox 10, ie10, Safari 4.0, Chrome 12.0
164 // transform : void 0,
166 // https://developer.mozilla.org/ja/docs/Web/Guide/CSS/Using_CSS_transitions
167 // Chrome 1.0, Firefox 4.0, ie10, Opera 10.5, Safari 3.2
168 // Android 2.1, Firefox Android 4.0, Opera Mobile 10, Safari Mobile 3.2
169 // transition : void 0
171 // ブラウザ毎の getComputedStyle の戻り値 http://d.hatena.ne.jp/uupaa/20080928/1222543331
193 SLATEGRAY : 0x708090,
195 GAINSBORO : 0xDCDCDC,
196 MIDNIGHTBLUE : 0x191970,
197 SLATEBLUE : 0x6A5ACD,
198 MEDIUMBLUE : 0x0000CD,
199 ROYALBLUE : 0x4169E1,
200 DODGERBLUE : 0x1E90FF,
202 STEELBLUE : 0x4682B4,
203 LIGHTBLUE : 0xADD8E6,
204 PALETURQUOISE : 0xAFEEEE,
205 TURQUOISE : 0x40E0D0,
206 LIGHTCYAN : 0xE0FFFF,
207 AQUAMARINE : 0x7FFFD4,
208 DARKGREEN : 0x006400,
210 LIGHTGREEN : 0x90EE90,
211 CHARTREUSE : 0x7FFF00,
212 GREENYELLOW : 0xADFF2F,
213 LIMEGREEN : 0x32CD32,
214 YELLOWGREEN : 0x9ACD32,
215 OLIVEDRAB : 0x6B8E23,
216 DARKKHAKI : 0xBCB76B,
217 PALEGOLDENROD : 0xEEE8AA,
218 LIGHTYELLOW : 0xFFFFE0,
220 GOLDENROD : 0xDAA520,
221 DARKGOLDENROD : 0xB8860B,
222 ROSYBROWN : 0xBC8F8F,
223 INDIANRED : 0xCD5C5C,
224 SADDLEBROWN : 0x8B4513,
227 BURLYWOOD : 0xDEB887,
230 SANDYBROWN : 0xF4A460,
232 CHOCOLATE : 0xD2691E,
233 FIREBRICK : 0xB22222,
242 PALEVIOLETRED : 0xDB7093,
246 DARKVIOLET : 0x9400D3,
247 BLUEVIOLET : 0x8A2BE2,
248 MEDIUMPURPLE : 0x9370DB,
251 MISTYROSE : 0xFFE4E1,
253 LEMONCHIFFON : 0xFFFACD
256 parseColor : function( x ){
259 if( X.Type.isNumber( x ) ){
260 return ( 0x0 <= x && x <= 0xFFFFFF ) ? x : undefined;
262 if( !X.Type.isString( x ) ) return;
264 if( X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) && 0x0 <= rgb && rgb <= 0xFFFFFF ){
267 if( x.charAt( 0 ) === '#' ){
270 r = parseInt( x.substr( 1, 2 ), 16 );
271 g = parseInt( x.substr( 3, 2 ), 16 );
272 b = parseInt( x.substr( 5, 2 ), 16 );
275 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
276 g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
277 b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
280 r = g = b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
286 if( x.indexOf( 'rgb(' ) === 0 ){
287 rgb = x.substr( 4 ).split( ',' );
288 r = parseFloat( rgb[ 0 ] );
289 g = parseFloat( rgb[ 1 ] );
290 b = parseFloat( rgb[ 2 ] );
291 if( x.indexOf( '%' ) !== -1 ){
297 if( x.indexOf( 'rgba(' ) === 0 ){
298 rgb = x.substr( 5 ).split( ',' );
299 r = parseFloat( rgb[ 0 ] );
300 g = parseFloat( rgb[ 1 ] );
301 b = parseFloat( rgb[ 2 ] );
302 //a = parseFloat( rgb[ 3 ] );
303 if( x.indexOf( '%' ) !== -1 ){
311 return isFinite( r + b + g ) ? ( r << 16 ) + ( g << 8 ) + b : undefined;
314 PARAMS : ( function(){
316 register( ret.percent = {},
317 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom,paddingLeft,paddingRight,paddingTop,fontSize,textIndent'
319 register( ret.offset = {},
320 'height,width,bottom,left,right,top'
322 register( ret.size = {},
323 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth,letterSpacing,wordSpacing'
325 register( ret.color = {},
326 'backgroundColor,borderBottomColor,borderLeftColor,borderRightColor,borderTopColor,color'
328 register( ret.region = {},
329 'margin,padding,borderWidth,borderColor'
331 register( ret.special = {},
332 'clip,backgroundPosition,backgroundPositionX,backgroundPositionY,opacity,lineHeight,zIndex'
334 register( ret.unit = {}, 'px,cm,mm,in,pt,pc,em,%' );
336 register( ret.margin = {}, 'marginBottom,marginLeft,marginRight,marginTop,paddingBottom' );
337 register( ret.padding = {}, 'paddingBottom,paddingLeft,paddingRight,paddingTop' );
338 register( ret.borderWidth = {}, 'borderBottomWidth,borderLeftWidth,borderRightWidth,borderTopWidth' );
339 register( ret.borderColor = {}, 'borderBottomColor,borderLeftColor,borderRightColor,borderTopColor' );
341 function register( obj, params ){
342 params = params.split( ',' );
343 for( var i = params.length; i; ) obj[ params[ --i ] ] = true;
348 _CLIP_SEPARATOR : X.UA.IE && X.UA.IE < 8 ? ' ' : ',',
353 Property : X.Class.create(
357 Constructor : function( name, value, unit, xnode ){
367 equal : function( prop ){
368 if( this.unit === prop.unit ){
369 return this.value === prop.value;
371 return Math.abs( this.toPx() - prop.toPx() ) < 1;
373 convert: function( prop ){
374 var u = prop.unit, v;
375 if( this.unit === u ) return;
376 this.value = v = this.toPx();
379 // bgpX, bgpY の場合 X.Dom.Image.getActualDimension( backgroundImage url を使用 )
383 v / this.xnode._getCharSize() :
384 v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
387 setValue: function( v ){
390 getValue: function(){
393 getOffset: function( prop ){
394 return prop.value - this.value;
399 getValueText: function(){
400 return this.value === 0 ? '0' : this.value + this.unit;
403 var v = this.value, u = this.unit;
407 ( u === 'em' || ( u === '' && this.name === 'lineHeight' ) ) ?
408 v * this.xnode._getCharSize() :
410 v / ( X.Dom.Style._UNIT_RATIO[ u ] || 1 );
413 var p = X.Dom.Style.PARAMS,
417 z = u !== '' ? true : v === 0;
418 if( p.percent[ n ] === true ) return z;
419 if( p.offset[ n ] === true ) return z;
420 if( p.size[ n ] === true ) return z && u !== '%';
421 if( p.special[ n ] === true ){
422 if( n === 'lineHeight' ) return true;
423 if( n === 'opacity' ) return 0 <= v && v <= 1 && u === '';
424 if( n === 'zIndex' ) return u === '';
432 * backgroundPosition, clip
434 PropertyGroup : X.Class.create(
438 Constructor : function( name ){
441 for( var i = 1, l = arguments.length; i<l; ++i ){
442 this.props[ this.props.length ] = arguments[ i ];
446 equal : function( prop ){
447 var ps = this.props, i = ps.length;
450 if( ps[ i ].equal( prop[ i ] ) === false ) return false;
454 convert : function( prop ){
455 var ps = this.props, i = ps.length;
458 ps[ i ].convert( prop[ i ] );
461 setValue : function( ary ){
462 var ps = this.props, i = 0, l = ps.length;
464 ps[ i ].setValue( ary[ i ] );
467 getValue : function(){
468 var ret = [], ps = this.props, i = 0, l = ps.length;
470 ret[ ret.length ] = ps[ i ].getValue();
474 getOffset : function( prop ){
481 ret[ ret.length ] = ps[ i ].getOffset( _ps[ i ] );
485 getUnit : function(){
486 var ret = [], ps = this.props, i = 0, l = ps.length;
488 ret[ ret.length ] = ps[ i ].getUnit();
492 getValueText : function(){
493 var ret = [], ps = this.props, i = 0, l = ps.length;
495 ret[ ret.length ] = ps[ i ].getValueText();
497 if( this.name === 'clip' ){
498 return 'rect(' + ret.join( X.Dom.Style._CLIP_SEPARATOR ) + ')';
500 return ret.join( ' ' );
503 var ps = this.props, i = ps.length;
508 isValid : function( t ){
510 var ps = t.props, i = ps.length;
512 if( ps[ --i ].isValid() === false ) return false;
520 * http://css-eblog.com/ie-css-problems/rgba-pe.html
521 * ie67 では rgb() は background-color で反応しない、、、
524 ColorProperty : X.Class.create(
526 X.Class.POOL_OBJECT, {
527 Constructor : function( name, x ){
534 if( X.Type.isNumber( rgb = x ) || X.Type.isNumber( rgb = X.Dom.Style.COLOR[ x.toUpperCase() ] ) ){
535 r = ( rgb & 0xff0000 ) >> 16;
536 g = ( rgb & 0xff00 ) >> 8;
539 if( x.charAt( 0 ) === '#' ){
540 if( x.length === 7 ){
541 r = parseInt( x.charAt( 1 ) + x.charAt( 2 ), 16 );
542 g = parseInt( x.charAt( 3 ) + x.charAt( 4 ), 16 );
543 b = parseInt( x.charAt( 5 ) + x.charAt( 6 ), 16 );
545 if( x.length === 4 ){
546 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
547 g = parseInt( x.charAt( 2 ) + x.charAt( 2 ), 16 );
548 b = parseInt( x.charAt( 3 ) + x.charAt( 3 ), 16 );
550 if( x.length === 2 ){
551 r = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
552 g = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
553 b = parseInt( x.charAt( 1 ) + x.charAt( 1 ), 16 );
556 if( x.indexOf( 'rgb(' ) === 0 ){
557 rgb = x.substr( 4 ).split( ',' );
558 r = parseFloat( rgb[ 0 ] );
559 g = parseFloat( rgb[ 1 ] );
560 b = parseFloat( rgb[ 2 ] );
561 if( x.indexOf( '%' ) !== -1 ) pct = true;
563 if( x.indexOf( 'rgba(' ) === 0 ){
564 rgb = x.substr( 5 ).split( ',' );
565 r = parseFloat( rgb[ 0 ] );
566 g = parseFloat( rgb[ 1 ] );
567 b = parseFloat( rgb[ 2 ] );
568 a = parseFloat( rgb[ 3 ] );
569 if( x.indexOf( '%' ) !== -1 ) pct = true;
589 equal : function( prop ){
590 if( this.pct === prop.pct ){
591 return this.r === prop.r && this.g === prop.g && this.b === prop.b;
593 var rgb = this._toPct(),
594 _rgb = prop._toPct(),
598 if( Math.abs( rgb[ i ] - _rgb[ i ] ) > 1 ) return false;
602 convert : function( prop ){
604 if( this.pct === u ) return;
605 x = u === true ? 100 / 255 : 2.55;
611 setValue : function( rgb ){
616 getValue : function(){
617 return [ this.r, this.g, this.b ];
619 getOffset : function( prop ){
620 return [ prop.r - this.r, prop.g - this.g, prop.b - this.b ];
622 getUnit : function(){
623 return this.pct === true ? '%' : '';
625 getValueText : function(){
626 if( this.pct === true ){
627 return [ 'rgb(', this.r, '%,', this.g, '%,', this.b, '%)' ].join( '' );
629 var round = Math.round;
631 var rgb = '00000' + ( ( round( this.r ) << 16 ) + ( round( this.g ) << 8 ) + round( this.b ) ).toString( 16 );
632 return '#' + rgb.substr( rgb.length - 6 );
635 if( this.pct === true ) return [ this.r, this.g, this.b ];
636 return [ this.r / 2.55, this.g / 2.55, this.b / 2.55 ];
638 isValid : function( t ){
639 var isFinite = window.isFinite;
640 if( !isFinite( this.r ) || !isFinite( this.g ) || !isFinite( this.b ) ) return false;
641 if( 0 > this.r || 0 > this.g || 0 > this.b ) return false;
642 if( this.pct === true ) return this.r <= 100 && this.g <= 100 && this.b <= 100;
643 return this.r <= 255 && this.g <= 255 && this.b <= 255;
648 _getProperty : function( xnode, css, unit, p ){
650 var XDomStyle = X.Dom.Style,
651 me = XDomStyle._getProperty,
652 PARAMS = XDomStyle.PARAMS,
653 PropertyGroup = XDomStyle.PropertyGroup,
654 Property = XDomStyle.Property,
655 ColorProperty = XDomStyle.ColorProperty,
658 if( PARAMS.special[ p ] === true || PARAMS.region[ p ] === true ){
661 // rect(...) クリップします。<top>, <bottom> は上端からの、 <right>, <left> は左端からのオフセットで指定します。Internet Explorer 4~7 では、カンマの代わりにスペースで区切る必要があります。
662 // position:absolute または position:fixed を適用した要素に対してのみ有効です。
663 var top = me( p + 'Top' ),
664 right = me( p + 'Right' ),
665 bottom = me( p + 'Bottom' ),
666 left = me( p + 'Left' ),
667 ret = new PropertyGroup( p, top, right, bottom, left ),
669 if( ret.isValid() === true ) return ret;
671 all = css[ p ].split( '(' )[ 1 ].split( ')' )[ 0 ].split( XDomStyle._CLIP_SEPARATOR );
675 new Property( p + 'Top', all[ 0 ], 'px', xnode ),
676 new Property( p + 'Right', all[ 1 ], 'px', xnode ),
677 new Property( p + 'Bottom', all[ 2 ], 'px', xnode ),
678 new Property( p + 'Left', all[ 3 ], 'px', xnode )
686 var props = '$1Top$2,$1Right$2,$1Bottom$2,$1Left$2'.split( '$1' ).join( name || 'border' ).split( '$2' ).join( width || 'Width' ).split( ',' ),
687 top = me( props[ 0 ] ),
688 right = me( props[ 1 ] ),
689 bottom = me( props[ 2 ] ),
690 left = me( props[ 3 ] ),
691 ret = new PropertyGroup( p, top, right, bottom, left ),
692 all, _0, _1, _2, _3, vu, v, u;
693 if( ret.isValid() === true ) return ret;
695 all = css[ p ].split( ' ' );
700 vu = XDomStyle._splitValueAndUnit( _0 );
703 switch( all.length ){
705 top = new Property( props[ 0 ], v, u, xnode );
706 right = new Property( props[ 1 ], v, u, xnode );
707 bottom = new Property( props[ 2 ], v, u, xnode );
708 left = new Property( props[ 3 ], v, u, xnode );
711 top = new Property( props[ 0 ], v, u, xnode );
712 bottom = new Property( props[ 2 ], v, u, xnode );
713 vu = XDomStyle._splitValueAndUnit( _1 );
716 right = new Property( props[ 1 ], v, u, xnode );
717 left = new Property( props[ 3 ], v, u, xnode );
720 top = new Property( props[ 0 ], v, u, xnode );
721 vu = XDomStyle._splitValueAndUnit( _1 );
724 right = new Property( props[ 1 ], v, u, xnode );
725 left = new Property( props[ 3 ], v, u, xnode );
726 vu = XDomStyle._splitValueAndUnit( _2 );
729 bottom = new Property( props[ 2 ], v, u, xnode );
732 top = new Property( props[ 0 ], v, u, xnode );
733 vu = XDomStyle._splitValueAndUnit( _1 );
736 right = new Property( props[ 1 ], v, u, xnode );
737 vu = XDomStyle._splitValueAndUnit( _2 );
740 bottom = new Property( props[ 2 ], v,u, xnode );
741 vu = XDomStyle._splitValueAndUnit( _3 );
744 left = new Property( props[ 3 ], v, u, xnode );
747 return new PropertyGroup( p, top, right, bottom, left );
750 var props = 'borderTopColor,borderRightColor,borderBottomColor,borderLeftColor'.split( ',' ),
751 top = me( props[ 0 ] ),
752 right = me( props[ 1 ] ),
753 bottom = me( props[ 2 ] ),
754 left = me( props[ 3 ] ),
755 ret = new PropertyGroup( p, top, right, bottom, left ),
757 if( ret.isValid() === true ) return ret;
759 all = css[ p ].split( ' ' );
762 switch( all.length ){
764 top = new ColorProperty( props[ 0 ], _0 );
765 right = new ColorProperty( props[ 1 ], _0 );
766 bottom = new ColorProperty( props[ 2 ], _0 );
767 left = new ColorProperty( props[ 3 ], _0 );
770 top = new ColorProperty( props[ 0 ], _0 );
771 right = new ColorProperty( props[ 1 ], _1 );
772 bottom = new ColorProperty( props[ 2 ], _0 );
773 left = new ColorProperty( props[ 3 ], _1 );
776 top = new ColorProperty( props[ 0 ], _0 );
777 right = new ColorProperty( props[ 1 ], _1 );
778 bottom = new ColorProperty( props[ 2 ], all[ 2 ] );
779 left = new ColorProperty( props[ 3 ], _1 );
782 top = new ColorProperty( props[ 0 ], _0 );
783 right = new ColorProperty( props[ 1 ], _1 );
784 bottom = new ColorProperty( props[ 2 ], all[ 2 ] );
785 left = new ColorProperty( props[ 3 ], all[ 3 ] );
788 return new PropertyGroup( p, top, right, bottom, left );
790 case 'backgroundPosition' :
791 var x = me( p + 'X' ),
793 ret = new PropertyGroup( p, x, y ),
795 if( ret.isValid() === true ) return ret;
797 xy = css[ p ].split( ' ' );
798 x = XDomStyle._splitValueAndUnit( xy[ 0 ] );
799 y = XDomStyle._splitValueAndUnit( xy[ 1 ] );
803 new Property( p + 'X', x[ 0 ], x[ 1 ], xnode ),
804 new Property( p + 'Y', y[ 0 ], y[ 1 ], xnode )
807 // opacity, zindex, lineHeight
808 vu = XDomStyle._splitValueAndUnit( css[ p ] );
809 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
811 var x = css[ p ], e, v, u;
813 if( PARAMS.offset[ p ] === true ){
814 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
817 if( p === 'width' ) v = e.offsetWidth;
818 if( p === 'height' ) v = e.offsetHeight;
819 if( p === 'top' ) v = e.offsetTop;
820 if( p === 'bottom' ) v = e.offsetBottom;
821 if( p === 'left' ) v = e.offsetLeft;
822 if( p === 'right' ) v = e.offsetRight;
823 u = _getUnit( x, p );
824 // alert( p + XDomStyle._Util.pxTo( v, u ) + u )
825 return new Property( p, XDomStyle._Util.pxTo( v, u ), u, xnode );
827 if( p === 'fontSize' && ( v = XDomStyle._FONT_SIZE_RATIO[ x ] ) ){ // xx-small 等
828 return new Property( p, v, 'px', xnode );
830 if( PARAMS.offset[ p ] || PARAMS.percent[ p ] || PARAMS.size[ p ] ){
831 vu = XDomStyle._splitValueAndUnit( x );
832 return new Property( p, vu[ 0 ], vu[ 1 ], xnode );
835 if( PARAMS.color[ p ] ) return new ColorProperty( p, x );
838 _splitValueAndUnit : function( v ){
840 if( X.Type.isNumber( v ) ) return [ v || 0, '' ];
841 if( isNaN( num = parseFloat( v ) ) ) return [ 0, '' ];
843 if( _num.indexOf( '0.' ) === 0 ) _num = _num.slice( 1 );
844 u = v.substr( v.indexOf( _num ) + _num.length );
845 return [ num, X.Dom.Style.UNIT[ u ] ? u : 'px' ];
849 X.Dom.Style._GET_VALUE_WITH_UNIT = {
850 borderWidth : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
851 //borderStyle : X.Dom.Style.Type.QUARTET,
852 borderRadius : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH,
853 margin : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
854 padding : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
855 clip : X.Dom.Style.Type.QUARTET | X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
857 backgroundColor : X.Dom.Style.Type.COLOR,
858 backgroundPosition : X.Dom.Style.Type.COMBI,
862 fontSize : X.Dom.Style.Type.LENGTH,
863 lineHeight : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT | X.Dom.Style.Type.NUMERICAL,
864 textIndent : X.Dom.Style.Type.LENGTH,
865 letterSpacing : X.Dom.Style.Type.LENGTH,
866 wordSpacing : X.Dom.Style.Type.LENGTH,
868 textShadowColor : X.Dom.Style.Type.COLOR,
869 textShadowOffsetX : X.Dom.Style.Type.LENGTH,
870 textShadowOffsetY : X.Dom.Style.Type.LENGTH,
871 textShadowBlur : X.Dom.Style.Type.LENGTH, */
873 width : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
874 height : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
876 left : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
877 top : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
878 bottom : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
879 right : X.Dom.Style.Type.LENGTH | X.Dom.Style.Type.PERCENT,
882 borderSpacing : X.Dom.Style.Type.LENGTH
886 X.Dom.Style.SPECIAL_FIX =
888 X.UA.IE && X.UA.IE < 9 ?
890 var test = X.Dom.Style.SPECIAL_FIX_PROP,
895 if( !( id = test[ p ] ) ) continue;
898 case 1 : //'filter' :
901 case 2 : //'opacity' :
902 filters[ ++n ] = 'alpha(opacity=' + v * 100 +')';
904 case 3 : //'boxShadow' :
905 // box-shadow: 10px 10px 10px 10px rgba(0,0,0,0.4) inset;
906 // スペース区切りで、水平方向の距離 垂直方向の距離 ぼかし距離 広がり距離 影の色 insetキーワードを指定する。 ぼかし距離 広がり距離 影の色 insetキーワードは省略可
907 // shadow(color=#cccccc, strength=10, direction=135);
908 v = X.Dom.Style._getProperty( this, css, 'px', 'boxShadow' );
909 dir = Math.atan2( v[ 1 ], v[ 0 ] ) * 180 / Math.PI + 90;
910 dir += dir < 0 ? 360 : 0;
911 filters[ ++n ] = 'shadow(color=' + v[ 4 ] + ',strength=' + v[ 3 ] + ',direction=' + dir + ')';
913 case 4 : //'textShadow' :
914 //text-shadow: 5px 5px 2px blue; 水平方向の距離 垂直方向の距離 影のぼかし半径 影の色 none
915 //glow(Color=yellow,Strength=10);
916 //どうやらCSSのbackgroundプロパティと同時に使えないようです。
920 case 5 : //'backgroundImage' :
924 return filters.join( ' ' );
926 // IE9 textShadow に filter を使用
927 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
929 var test = X.Dom.Style.SPECIAL_FIX_PROP,
930 filters = [], p, id, v;
932 if( !( id = test[ p ] ) ) continue;
935 case 1 : //'filter' :
936 filters[ filters.length ] = v;
940 if( filters ) return filters.join( ' ' );
943 var test = X.Dom.Style.SPECIAL_FIX_PROP,
946 if( !( id = test[ p ] ) ) continue;
949 case 1 : //'backgroundPositionX' :
952 case 2 : //'backgroundPositionY' :
955 case 3 : //'backgroundPositionX' :
958 case 4 : //'backgroundPositionX' :
961 case 5 : //'backgroundPositionX' :
964 case 6 : //'backgroundPositionX' :
969 if( bgpX || bgpY ) ret[ ret.length ] = 'background-position:';
970 if( clipT || clipB || clipL || clipR ){
971 ret[ ret.length ] = 'clip:rect(';
973 return ret.join( ';' );
981 // unitID, name 単位指定のプロパティ取得 geter
983 // name, value setter
985 X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ){
986 var XDomStyle = X.Dom.Style,
989 p, name, v, camelize, unit, ieFix;
990 if( this._xnodeType !== 1 ) return this;
992 if( X.Type.isObject( nameOrObj ) ){
993 if( !css ) css = this._css = {};
994 camelize = XDomStyle.camelize;
995 ieFix = X.Dom.Style.IE_FILTER_FIX;
996 for( p in nameOrObj ){
998 this._dirty |= X.Dom.Dirty.IE_FILTER;
1001 v || v === 0 ? css[ camelize( p ) ] = v : delete css[ camelize( p ) ];
1002 if( p === 'display' ){
1003 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
1004 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
1007 this._dirty |= X.Dom.Dirty.CSS;
1008 this.parent && this._reserveUpdate();
1009 delete this._cssText;
1012 if( 1 < args.length ){
1013 if( !XDomStyle.UNIT[ nameOrObj ] ){
1014 // setter name, value
1015 if( !css ) css = this._css = {};
1016 name = XDomStyle.camelize( nameOrObj );
1018 if( css[ name ] === v ) return this;
1019 if( X.Dom.Style.IE_FILTER_FIX[ name ] ){
1020 this._dirty |= X.Dom.Dirty.IE_FILTER;
1022 if( !v && v !== 0 ){
1027 delete this._cssText;
1028 this._dirty |= X.Dom.Dirty.CSS;
1029 if( name === 'display' ){
1030 v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX );
1031 v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE );
1033 // parent でなく this._root! でなくて this._state & in tree
1034 this.parent && this._reserveUpdate();
1038 // unit 付の値取得は fontSize と 画像サイズが確定していないと正確に取れない。内部のみにする?
1040 if( !XDomStyle._GET_VALUE_WITH_UNIT[ name = XDomStyle.camelize( args[ 1 ] ) ] ) return null;
1041 p = XDomStyle._getProperty( this, css, nameOrObj, name );
1042 v = p.pxTo( nameOrObj );
1048 // 集計 border, padding, margin, backgroundPosition, clip
1049 // border で正確なデータを返せない時は、null を返す
1050 return css[ XDomStyle.camelize( nameOrObj ) ];
1053 X.Dom.Node.prototype.cssText = function( v ){
1054 var obj, i, l, attr, name;
1057 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1058 this._dirty |= X.Dom.Dirty.CSS;
1059 this.parent && this._reserveUpdate();
1060 delete this._cssText;
1063 if( X.Type.isString( v ) ){
1065 this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX;
1068 for( i = 0, l = v.length; i < l; ++i ){
1069 attr = v[ i ].split( ':' );
1070 ( name = attr[ 0 ] ) && ( obj[ name ] = attr[ 1 ] || true );
1072 return this.css( obj );
1075 if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){
1076 delete this._cssText;
1078 return this._cssText;
1082 * ここでは HTMLElement のチャックは行わない!
1085 X.Dom.Node.prototype._getCharSize =
1086 window.getComputedStyle ?
1088 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1089 Node.root._updateTimerID && Node.root._startUpdate();
1090 if( this._fontSize ) return this._fontSize;
1091 return this._fontSize = parseFloat( getComputedStyle( this._rawNode, null ).fontSize );
1093 document.defaultView && document.defaultView.getComputedStyle ?
1095 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1096 Node.root._updateTimerID && Node.root._startUpdate();
1097 if( this._fontSize ) return this._fontSize;
1098 return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawNode, null ).fontSize );
1100 X.UA.IE && 5.5 <= X.UA.IE ?
1102 var font, vu, v, u, _v;
1103 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1104 Node.root._updateTimerID && Node.root._startUpdate();
1105 if( this._fontSize ) return this._fontSize;
1107 font = this._rawNode.currentStyle.fontSize;
1108 //font = this._css && this._css.fontSize || '1em';
1109 vu = X.Dom.Style._splitValueAndUnit( font );
1114 if( v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = v;
1116 if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1120 return this._fontSize = v;
1122 // body まで辿ってしまった場合は?
1123 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1126 // body まで辿ってしまった場合は?
1127 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1131 document.getElementById ?
1134 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1135 Node.root._updateTimerID && Node.root._startUpdate();
1136 if( this._fontSize ) return this._fontSize;
1138 this._rawNode.appendChild( elm = document.createElement( 'span' ) );
1139 elm.style.cssText = 'display:block;position:absolute;top:0;left:0;visivility:hidden;line-height:1;height:1em;';
1140 elm.innerHTML = 'X';
1141 v = elm.offsetHeight;
1142 this._rawNode.removeChild( elm );
1143 return this._fontSize = v;
1147 var font, vu, v, u, _v;
1148 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1149 Node.root._updateTimerID && Node.root._startUpdate();
1150 if( this._fontSize ) return this._fontSize;
1152 if( this._css && ( font = this._css.fontSize ) ){
1153 vu = X.Dom.Style._splitValueAndUnit( font );
1158 if( _v = X.Dom.Style._FONT_SIZE_RATIO[ font ] ) return this._fontSize = _v;
1160 if( _v = X.Dom.Style._UNIT_RATIO[ u ] ) return this._fontSize = v / _v;
1169 return this._fontSize = v;
1171 // body まで辿ってしまった場合は?
1172 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v;
1175 // body まで辿ってしまった場合は?
1176 if( this.parent ) return this._fontSize = this.parent._getCharSize() * v / 100;
1182 if( this === Node.root && X.Dom.baseFontSize ) return X.Dom.baseFontSize;
1183 Node.root._updateTimerID && Node.root._startUpdate();
1184 if( this._fontSize ) return this._fontSize;
1186 elm = this._rawNode || this._ie4getRawNode();
1187 elm.insertAdjacentHTML( 'BeforeEnd', '<span style="visivility:hidden;line-height:1;">X</span>' );
1188 elm = elm.children[ elm.children.length - 1 ];
1189 v = elm.offsetHeight;
1191 return this._fontSize = v * 0.75;
1195 X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){
1196 var testStyle = X.Dom._root.style;
1198 X.Dom.Style.VENDER_PREFIX = (function(){
1200 vendors = 'webkit,Webkit,Moz,moz,ms,Ms,O,o,khtml,Khtml'.split( ',' ),
1202 'opacity,boxSizing,' +
1203 'transform,transformOrigin,perspective,' +
1204 'transisiton,transitionDelay,transitionProperty,transitionDuration,transitionTimingFunction,' +
1205 'userSelect,touchAction,touchCallout,contentZooming,userDrag,tapHighlightColor'.split( ',' ),
1206 vendor, i, search, prop;
1208 vendors.unshift( '' );
1210 function findVenderPrefix( prop ){
1211 var v, i = vendors.length;
1215 if( testStyle[ v + prop ] !== undefined ){
1222 for( i = searches.length; i; ){
1223 search = searches[ --i ];
1224 prop = findVenderPrefix( search );
1225 if( search === 'transform' ) ret.transVender = vendor;
1226 if( prop ) ret[ search ] = prop;
1231 X.Dom.Style.SPECIAL_FIX_PROP =
1233 X.UA.IE && X.UA.IE < 9 ?
1236 opacity : 2//, uinode ChromeNode で行う
1239 //backgroundImage : 5
1242 X.UA.IE && 9 <= X.UA.IE && X.UA.IE < 10 ?
1248 backgroundPositionX : testStyle.backgroundPositionX === undefined ? 3 : 0,
1249 backgroundPosiitonY : testStyle.backgroundPositionX === undefined ? 3 : 0,
1250 clipTop : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 3 : 0,
1251 clipBottom : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 4 : 0,
1252 clipLeft : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 5 : 0,
1253 clipRight : testStyle.clipTop === undefined && testStyle[ 'clip-top' ] === undefined ? 6 : 0
1257 X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
1258 var xnode = Node._systemNode,
1259 output = X.Dom.Style._UNIT_RATIO = {},
1260 list = 'cm,mm,in,pt,pc'.split( ',' ),
1263 for( i = list.length; i; ){
1265 output[ unit ] = xnode.css( 'width', 100 + unit ).width() / 100;
1268 output = X.Dom.Style._FONT_SIZE_RATIO = {},
1269 list = 'xx-large,x-large,large,larger,medium,small,smaller,x-small,xx-small'.split( ',' );
1270 xnode.css( { lineHeight : '100%', height : '1em' } ).text( 'X' );
1272 for( i = list.length; i; ){
1274 output[ size ] = xnode.css( 'fontSize', size ).height();// / base;
1277 // 以下解決、scroll 中に timer が無視される iOS の問題が原因(dom追加で起こったスクロール?)
1278 // ipod touch 1st で必要なんですけど、、、
1279 //xnode._rawNode.style.cssText = '';
1280 xnode.cssText( '' ).empty(); //._startUpdate();