OSDN Git Service

Version 0.6.156, add X.UI.Repeater.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 06_XNodeCSS.js
index 9a9d85b..9711a5e 100644 (file)
@@ -251,7 +251,7 @@ function X_Node_CSS_objToCssText( that, skipFilter ){
                n     = -1,
                p, v, specialFix, filterFix;
        
-       that[ '_flags' ] &= ~X_Node_State.OLD_CSSTEXT;
+       that[ '_flags' ] &= ~X_NodeFlags_OLD_CSSTEXT;
        
        if( !obj ){ // Opera7.5 未満?
                delete that[ '_cssText' ];
@@ -416,8 +416,8 @@ function X_Node_CSS_objToIEFilterText( that, opt_css ){
 };
 
 function X_Node_CSS_onAfterUpdateForIEFilterFix(){
-       if( this[ '_flags' ] & X_Node_State.IN_TREE ){ // 要素があり、要素がツリーに属している
-               this[ '_flags' ] |= X_Node_State.DIRTY_IE_FILTER;
+       if( this[ '_flags' ] & X_NodeFlags_IN_TREE ){ // 要素があり、要素がツリーに属している
+               this[ '_flags' ] |= X_NodeFlags_DIRTY_IE_FILTER;
                X_Node_reserveUpdate();
        };
 };
@@ -517,7 +517,7 @@ function X_Node_CSS__splitValueAndUnit( v ){
  * // setter - 2
  * node.css( 'color', 0x666666 );
  */
-Node.prototype[ 'css' ] = function( nameOrObj /* value */ ){
+function X_Node_css( nameOrObj /* value */ ){
        var args = arguments,
                css  = this[ '_css' ],
                p, name, v, plain, camelize, flags;
@@ -536,9 +536,9 @@ Node.prototype[ 'css' ] = function( nameOrObj /* value */ ){
                        if( css[ name ] === v ) continue;
                        flags = X_Node_CSS_setStyle( css, flags, name, v );
                };
-               flags |= X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT;
+               flags |= X_NodeFlags_DIRTY_CSS | X_NodeFlags_OLD_CSSTEXT;
                this[ '_flags' ] = flags;
-               flags & X_Node_State.IN_TREE && X_Node_reserveUpdate();
+               flags & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
                delete this[ '_cssText' ];
                return this;
        } else
@@ -548,8 +548,8 @@ Node.prototype[ 'css' ] = function( nameOrObj /* value */ ){
                name = X_Node_CSS_camelize( nameOrObj );
                v    = args[ 1 ];
                if( css[ name ] === v ) return this;
-               this[ '_flags' ] = X_Node_CSS_setStyle( css, this[ '_flags' ], name, v ) | X_Node_State.DIRTY_CSS | X_Node_State.OLD_CSSTEXT;
-               this[ '_flags' ] & X_Node_State.IN_TREE && X_Node_reserveUpdate();
+               this[ '_flags' ] = X_Node_CSS_setStyle( css, this[ '_flags' ], name, v ) | X_NodeFlags_DIRTY_CSS | X_NodeFlags_OLD_CSSTEXT;
+               this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
                delete this[ '_cssText' ];
                return this;
        };
@@ -563,7 +563,7 @@ Node.prototype[ 'css' ] = function( nameOrObj /* value */ ){
 function X_Node_CSS_setStyle( css, flags, name, newValue ){
 
        if( X_Node_CSS_FILTER_FIX_PROPS && X_Node_CSS_FILTER_FIX_PROPS[ name ] ){
-               flags |= X_Node_State.DIRTY_IE_FILTER;
+               flags |= X_NodeFlags_DIRTY_IE_FILTER;
        };
        if( !newValue && newValue !== 0 ){
                delete css[ name ];
@@ -574,49 +574,49 @@ function X_Node_CSS_setStyle( css, flags, name, newValue ){
        switch( name ){
                case 'display' :
                        console.log( newValue );
-                       newValue === 'none' ? ( flags |= X_Node_State.STYLE_IS_DISPLAY_NONE ) : ( flags &= ~X_Node_State.STYLE_IS_DISPLAY_NONE );
+                       newValue === 'none' ? ( flags |= X_NodeFlags_STYLE_IS_DISPLAY_NONE ) : ( flags &= ~X_NodeFlags_STYLE_IS_DISPLAY_NONE );
                        return flags;
                        
                case 'visibility' :
                        // すでに opacity:0 で invisible
-                       if( flags & X_Node_State.STYLE_IS_INVISIBLE && css[ 'opacity' ] == 0 ) return flags;
-                       newValue === 'hidden' ? ( flags |= X_Node_State.STYLE_IS_INVISIBLE ) : ( flags &= ~X_Node_State.STYLE_IS_INVISIBLE );
+                       if( flags & X_NodeFlags_STYLE_IS_INVISIBLE && css[ 'opacity' ] == 0 ) return flags;
+                       newValue === 'hidden' ? ( flags |= X_NodeFlags_STYLE_IS_INVISIBLE ) : ( flags &= ~X_NodeFlags_STYLE_IS_INVISIBLE );
                        return flags;
                        
                case 'opacity' :
                        // すでに visibility:hidden で invisible
-                       if( flags & X_Node_State.STYLE_IS_INVISIBLE && css[ 'visibility' ] === 'hidden' ) return flags;
+                       if( flags & X_NodeFlags_STYLE_IS_INVISIBLE && css[ 'visibility' ] === 'hidden' ) return flags;
                        newValue == 0 ? // 0 or "0"
-                               ( flags |= X_Node_State.STYLE_IS_INVISIBLE ) : ( flags &= ~X_Node_State.STYLE_IS_INVISIBLE );
+                               ( flags |= X_NodeFlags_STYLE_IS_INVISIBLE ) : ( flags &= ~X_NodeFlags_STYLE_IS_INVISIBLE );
                        return flags;
                        
                case 'overflow' :
-                       newValue === 'hidden' ? ( flags |= X_Node_State.STYLE_IS_NO_OVERFLOW ) : ( flags &= ~X_Node_State.STYLE_IS_NO_OVERFLOW );
+                       newValue === 'hidden' ? ( flags |= X_NodeFlags_STYLE_IS_NO_OVERFLOW ) : ( flags &= ~X_NodeFlags_STYLE_IS_NO_OVERFLOW );
                        return flags;
                        
                case 'position' :
-                       newValue === 'absolute' ? ( flags |= X_Node_State.STYLE_IS_POS_ABSOLUTE ) : ( flags &= ~X_Node_State.STYLE_IS_POS_ABSOLUTE );
+                       newValue === 'absolute' ? ( flags |= X_NodeFlags_STYLE_IS_POS_ABSOLUTE ) : ( flags &= ~X_NodeFlags_STYLE_IS_POS_ABSOLUTE );
                        return flags;
                        
                case 'width'    :
                        newValue = X_Node_CSS__splitValueAndUnit( newValue );
                        if( newValue[ 1 ] !== '%' ){
-                               flags |= X_Node_State.STYLE_IS_WIDTH_LENGTH;
-                               flags &= ~X_Node_State.STYLE_IS_WIDTH_PCT;
+                               flags |= X_NodeFlags_STYLE_IS_WIDTH_LENGTH;
+                               flags &= ~X_NodeFlags_STYLE_IS_WIDTH_PCT;
                        } else {
-                               flags &= ~X_Node_State.STYLE_IS_WIDTH_LENGTH;
-                               flags |= X_Node_State.STYLE_IS_WIDTH_PCT;
+                               flags &= ~X_NodeFlags_STYLE_IS_WIDTH_LENGTH;
+                               flags |= X_NodeFlags_STYLE_IS_WIDTH_PCT;
                        };
                        return flags;
                        
                case 'height'   :
                        newValue = X_Node_CSS__splitValueAndUnit( newValue );
                        if( newValue[ 1 ] !== '%' ){
-                               flags |= X_Node_State.STYLE_IS_HEIGHT_LENGTH;
-                               flags &= ~X_Node_State.STYLE_IS_HEIGHT_PCT;
+                               flags |= X_NodeFlags_STYLE_IS_HEIGHT_LENGTH;
+                               flags &= ~X_NodeFlags_STYLE_IS_HEIGHT_PCT;
                        } else {
-                               flags &= ~X_Node_State.STYLE_IS_HEIGHT_LENGTH;
-                               flags |= X_Node_State.STYLE_IS_HEIGHT_PCT;
+                               flags &= ~X_NodeFlags_STYLE_IS_HEIGHT_LENGTH;
+                               flags |= X_NodeFlags_STYLE_IS_HEIGHT_PCT;
                        };
                        return flags;
                        
@@ -626,19 +626,29 @@ function X_Node_CSS_setStyle( css, flags, name, newValue ){
        return flags;
 };
 
-Node.prototype[ 'cssText' ] = function( v ){
+/**
+ * cssText の getter と setter。setter の場合 css と異なり全ての style が書き変わる。
+ * @alias Node.prototype.cssText
+ * @param {string=} v cssText 文字列名
+ * @return {Node|string} getter の場合は cssText 文字列を、setter の場合は自身を返す。(メソッドチェーン)
+ * @example // getter
+ * node.cssText();
+ * // setter
+ * node.cssText('color:red;width:20px');
+ */
+function X_Node_cssText( v ){
        var obj, i, l, attr, name;
        
-       if( v === this[ '_cssText' ] && ( this[ '_flags' ] & X_Node_State.OLD_CSSTEXT ) === 0 ){
+       if( v === this[ '_cssText' ] && ( this[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT ) === 0 ){
                return this;
        };      
        
        if( v === '' ){
                delete this[ '_css' ];
                delete this[ '_cssText' ];
-               this[ '_flags' ] |= X_Node_State.DIRTY_CSS | X_Node_State.DIRTY_IE_FILTER;
-               this[ '_flags' ] &= ~X_Node_State.OLD_CSSTEXT;
-               this[ '_flags' ] & X_Node_State.IN_TREE && X_Node_reserveUpdate();
+               this[ '_flags' ] |= X_NodeFlags_DIRTY_CSS | X_NodeFlags_DIRTY_IE_FILTER;
+               this[ '_flags' ] &= ~X_NodeFlags_OLD_CSSTEXT;
+               this[ '_flags' ] & X_NodeFlags_IN_TREE && X_Node_reserveUpdate();
                return this;
        } else
        if( X_Type_isString( v ) ){
@@ -652,7 +662,7 @@ Node.prototype[ 'cssText' ] = function( v ){
                return this[ 'css' ]( obj );
        };
        // getter
-       this[ '_flags' ] & X_Node_State.OLD_CSSTEXT && X_Node_CSS_objToCssText( this );
+       this[ '_flags' ] & X_NodeFlags_OLD_CSSTEXT && X_Node_CSS_objToCssText( this );
        return this[ '_cssText' ];
 };