OSDN Git Service

Version 0.6.134, add comments for closure compiler.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 04_XBoxModel.js
index 85b0c9c..ed00a00 100644 (file)
@@ -1,30 +1,32 @@
 var X_Node_BoxModel = {\r
-       CONTENT_BOX      : 1,\r
-       PADDING_BOX      : 2,\r
-       BORDER_BOX       : 3,\r
-               \r
-       defaultBoxModel  : 0,\r
-       boxSizingEnabled : false,\r
+               CONTENT_BOX      : 1,\r
+               PADDING_BOX      : 2,\r
+               BORDER_BOX       : 3\r
+       },\r
+       \r
+       X_Node_BoxModel_defaultBoxModel,\r
        \r
+       X_Node_BoxModel_boxSizingEnabled,\r
        // TODO: offsetLeft, offsetTop の基準位置\r
-       absoluteOffset   : 0\r
-};\r
+       X_Node_BoxModel_absoluteOffset;\r
 \r
 \r
 \r
-X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){\r
+\r
+\r
+X_ViewPort[ 'listenOnce' ]( X_EVENT_INIT, function(){\r
        var node = X_Node_systemNode;\r
        \r
-       node.cssText( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' );\r
+       node[ 'cssText' ]( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' );\r
        \r
-       X_Node_BoxModel.defaultBoxModel = node.width() === 10 ?\r
+       X_Node_BoxModel_defaultBoxModel = node[ 'width' ]() === 10 ?\r
                X_Node_BoxModel.BORDER_BOX :\r
                X_Node_BoxModel.CONTENT_BOX;\r
        \r
-       if( X_Node_BoxModel.defaultBoxModel === X_Node_BoxModel.CONTENT_BOX ){\r
-               X_Node_BoxModel.boxSizingEnabled = node.cssText( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' +\r
+       if( X_Node_BoxModel_defaultBoxModel === X_Node_BoxModel.CONTENT_BOX ){\r
+               X_Node_BoxModel_boxSizingEnabled = node[ 'cssText' ]( 'width:10px;padding:1px;border:2px solid #0;margin:4px;' +\r
                        'box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;-ms-box-sizing:border-box;' )\r
-                                                                                       .width() === 10;\r
+                                                                                       [ 'width' ]() === 10;\r
        };\r
        \r
        /*\r
@@ -32,11 +34,11 @@ X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){
         * TODO boxShadow が有効な要素に対して offsetWidth 等の補正(?)\r
         */\r
        if( X_Node_CSS_Support[ 'boxShadow' ] &&\r
-               node.cssText(\r
-                       X_Node_CSS_uncamelize( X_Node_CSS_VENDER_PREFIX[ 'boxShadow' ] ) + ':10px 10px 0 0 #000;width:10px;'\r
-                               ).width() !== 10\r
-        ){\r
-               console.log( node.cssText() + node.width() );\r
+               node[ 'cssText' ](\r
+                               X_Node_CSS_uncamelize( X_Node_CSS_VENDER_PREFIX[ 'boxShadow' ] ) + ':10px 10px 0 0 #000;width:10px;'\r
+                       )[ 'width' ]() !== 10\r
+       ){\r
+               console.log( node[ 'cssText' ]() + node[ 'width' ]() );\r
                X_Node_CSS_Support[ 'boxShadowLayoutBug' ] = true;\r
        };\r
 \r
@@ -45,14 +47,14 @@ X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){
        // margin\r
        // top\r
 \r
-       X_Node_BoxModel.absoluteOffset =\r
-               node.cssText( 'position:absolute;top:0;left:0;margin:1px;border:2px solid #000;padding:4px;' )\r
-                       .append( '<div></div>' )\r
-                       .firstChild().cssText( 'position:absolute;top:8px;left:8px;margin:16px;border:32px solid #666;padding:64px;' )\r
-                       .y();\r
-\r
+       X_Node_BoxModel_absoluteOffset =\r
+               node[ 'cssText' ]( 'position:absolute;top:0;left:0;margin:1px;border:2px solid #000;padding:4px;' )\r
+                       [ 'append' ]( '<div></div>' )\r
+                       [ 'firstChild' ]()\r
+                               [ 'cssText' ]( 'position:absolute;top:8px;left:8px;margin:16px;border:32px solid #666;padding:64px;' )\r
+                               [ 'y' ]();\r
 \r
-       node.cssText( '' ).empty();\r
+       node[ 'cssText' ]( '' )[ 'empty' ]();\r
 });\r
 \r
 /* --------------------------------------\r
@@ -63,128 +65,128 @@ X_ViewPort.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){
  * getBoxObjectFor\r
  * getBoundingClientRect\r
  */\r
-Node.prototype.width = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'width' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
                // TODO width : length + overflow : hidden ならそれを返す? <- block or inline\r
-               return this._rawObject ? this._rawObject.offsetWidth : 0;\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].offsetWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetWidth;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).offsetWidth;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.height = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'height' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'height' );\r
-               return this._rawObject ? this._rawObject.offsetHeight : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'height' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].offsetHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetHeight;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).offsetHeight;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.clientWidth = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'clientWidth' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject ? this._rawObject.clientWidth : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'width' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].clientWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientWidth;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).clientWidth;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.clientHeight = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'clientHeight' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
 \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'height' );\r
-               return this._rawObject ? this._rawObject.clientHeight : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'height' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].clientHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).clientHeight;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).clientHeight;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.scrollWidth = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'scrollWidth' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
 \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject ? this._rawObject.scrollWidth : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'width' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].scrollWidth : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollWidth;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).scrollWidth;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.scrollHeight = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'scrollHeight' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
 \r
        if( X_UA_DOM.W3C ){\r
-               return this._rawObject ? this._rawObject.scrollHeight : 0;\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].scrollHeight : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollHeight;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).scrollHeight;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.scrollLeft = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'scrollLeft' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
 \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject ? this._rawObject.scrollLeft : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'width' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].scrollLeft : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollLeft;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).scrollLeft;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.scrollTop = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'scrollTop' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'width' );\r
-               return this._rawObject ? this._rawObject.scrollTop : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'width' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].scrollTop : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).scrollTop;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).scrollTop;\r
        } else {\r
                \r
        };\r
@@ -198,44 +200,44 @@ Node.prototype.scrollTop = function(){
  * transformX, Y は加える? アニメーション中は?\r
  */\r
 // X_Node_CSS_transform,\r
-Node.prototype.x = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'x' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'left' );\r
-               // this.css( X_Node_CSS_Unit.px, 'translateX' );\r
-               return this._rawObject ? this._rawObject.offsetLeft : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'left' );\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'translateX' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].offsetLeft : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
                // pixelLeft http://www.din.or.jp/~hagi3/JavaScript/JSTips/DHTML/ProbIE5.htm\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetLeft;\r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).offsetLeft;\r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.y = function(){\r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
+Node.prototype[ 'y' ] = function(){\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return 0;\r
        \r
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               // this.css( X_Node_CSS_Unit.px, 'top' );\r
-               // this.css( X_Node_CSS_Unit.px, 'transisitonY' );\r
-               return this._rawObject ? this._rawObject.offsetTop : 0;\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'top' );\r
+               // this[ 'css' ]( X_Node_CSS_Unit.px, 'transisitonY' );\r
+               return this[ '_rawObject' ] ? this[ '_rawObject' ].offsetTop : 0;\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return ( this._rawObject || X_Node__ie4getRawNode( this ) ).offsetTop;          \r
+               return ( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) ).offsetTop;             \r
        } else {\r
                \r
        };\r
 };\r
 \r
-Node.prototype.offset = function( /* xnodeParent */ ){\r
+Node.prototype[ 'offset' ] = function( /* xnodeParent */ ){\r
 \r
-       if( ( this._flags & X_Node_State.IN_TREE ) === 0 || this._flags & X_Node_State.STYLE_IS_DISPLAY_NONE ) return { x : 0, y : 0 };\r
+       if( ( this[ '_flags' ] & X_Node_State.IN_TREE ) === 0 || this[ '_flags' ] & X_Node_State.STYLE_IS_DISPLAY_NONE ) return { x : 0, y : 0 };\r
        \r
        if( X.Doc.body === this || X.Doc.html === this ){\r
                return { x : 0, y : 0 };\r
@@ -244,10 +246,10 @@ Node.prototype.offset = function( /* xnodeParent */ ){
        X_Node_updateTimerID && X_Node_startUpdate();\r
        \r
        if( X_UA_DOM.W3C ){\r
-               return this._rawObject ? X_Node_getPosition( this._rawObject ) : { x : 0, y : 0 };\r
+               return this[ '_rawObject' ] ? X_Node_getPosition( this[ '_rawObject' ] ) : { x : 0, y : 0 };\r
        } else\r
        if( X_UA_DOM.IE4 ){\r
-               return X_Node_getPosition( this._rawObject || X_Node__ie4getRawNode( this ) );\r
+               return X_Node_getPosition( this[ '_rawObject' ] || X_Node__ie4getRawNode( this ) );\r
        } else {\r
                \r
        };\r