OSDN Git Service

Version 0.6.141, fix X.UI.ScrollBox.
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 16_XViewPort.js
index bcc341a..8207644 100644 (file)
@@ -9,19 +9,20 @@ var X_ViewPort_readyState,
        X_ViewPort_vScrollbarSize,
        X_ViewPort_hScrollbarSize,
        
-       X_Dom_detectFontSize = !( X_UA[ 'IE' ] < 9 || X_UA[ 'iOS' ] ) && function(){
+       X_ViewPort_useDetectionLoop = X_UA[ 'IE' ] < 9 || X_UA[ 'iOS' ],
+       X_ViewPort_detectFontSize = !X_ViewPort_useDetectionLoop && function(){
                        var size = X_Node_fontSizeNode[ '_rawObject' ].offsetHeight;
                        if( X_ViewPort_baseFontSize !== size ){
-                               X_ViewPort_baseFontSize && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_BASE_FONT_RESIZED );
                                X_ViewPort_baseFontSize = size;
+                               X_ViewPort_baseFontSize && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_BASE_FONT_RESIZED );
                        };
        },
 
        X_ViewPort_orientationFlag,     
-       X_Dom_orientationchange = window[ 'orientation' ] !== undefined && function( e ){
+       X_ViewPort_orientationchange = window[ 'orientation' ] !== undefined && function( e ){
                X_ViewPort_orientationFlag = true;
                !X_UA[ 'Android' ] && X_ViewPort_resize();
-               //console.log( '-- orientationchange : ' + X[ 'ViewPort' ].getSize[ 0 ] + ' ' + X[ 'ViewPort' ].getSize[ 1 ] );
+               //console.log( '-- orientationchange : ' + X[ 'ViewPort' ][ 'getSize' ][ 0 ] + ' ' + X[ 'ViewPort' ][ 'getSize' ][ 1 ] );
        },
        
        X_ViewPort_document = X_EventDispatcher( document ),
@@ -224,7 +225,7 @@ X[ 'ViewPort' ] = {
  */
                var X_ViewPort_resize =
                        // iOS もループで回す,,,iOS3.1.3, iOS6 で確認
-                       X_UA[ 'IE' ] < 9 || X_UA[ 'iOS' ] ?
+                       X_ViewPort_useDetectionLoop ?
                                (function(){
                                        var size;
                                        if( !X_ViewPort_lock ){
@@ -232,7 +233,7 @@ X[ 'ViewPort' ] = {
                                                if( X_ViewPort_width !== size[ 0 ] || X_ViewPort_height !== size[ 1 ] ){
                                                        X_ViewPort_width = size[ 0 ];
                                                        X_ViewPort_height = size[ 1 ];
-                                                       X_Timer_once( 100, X_Dom_detectFinishResizing );
+                                                       X_Timer_once( 100, X_ViewPort_detectFinishResizing );
                                                        X_ViewPort_lock = true;
                                                };
                                        };
@@ -247,16 +248,16 @@ X[ 'ViewPort' ] = {
                                (function( e ){
                                        console.log( '-- resize : ' + X_Timer_now() );
                                        
-                                       !X_ViewPort_lock && ( X_ViewPort_lock = true ) && X_Timer_once( 100, X_Dom_detectFinishResizing );
+                                       !X_ViewPort_lock && ( X_ViewPort_lock = true ) && X_Timer_once( 100, X_ViewPort_detectFinishResizing );
                                        return X_Callback_PREVENT_DEFAULT | X_Callback_STOP_PROPAGATION;
                                });
                
-               function X_Dom_detectFinishResizing(){
+               function X_ViewPort_detectFinishResizing(){
                        var size = X_ViewPort_getWindowSize();
                        if( X_ViewPort_width !== size[ 0 ] || X_ViewPort_height !== size[ 1 ] ){
                                X_ViewPort_width  = size[ 0 ];
                                X_ViewPort_height = size[ 1 ];
-                               X_Timer_once( 100, X_Dom_detectFinishResizing );
+                               X_Timer_once( 100, X_ViewPort_detectFinishResizing );
                        } else {
                                console.log( '-- detectFinishResizing : ' + X_Timer_now() );
                                
@@ -264,7 +265,7 @@ X[ 'ViewPort' ] = {
                                X_ViewPort_lock = false;
                                if( X_ViewPort_orientationFlag ){
                                        X_ViewPort_orientationFlag = false;
-                                       X_ViewPort[ 'asyncDispatch' ]( 100, { type : X_EVENT_VIEW_TURNED, orientation : window.orientation } );
+                                       X_ViewPort[ 'asyncDispatch' ]( 100, { type : X_EVENT_VIEW_TURNED, 'orientation' : window.orientation } );
                                };
                        };
                };
@@ -293,7 +294,7 @@ X[ 'ViewPort' ] = {
 
                        X_ViewPort_rootElement = document.compatMode !== 'CSS1Compat' ? elmBody : elmHtml || elmBody;
 
-                       html = X[ 'Doc' ][ 'html' ] = X_Node_html = elmHtml && new Node( elmHtml );
+                       html = X[ 'Doc' ][ 'html' ] = X_Node_html = elmHtml && new Node( elmHtml ).removeClass( 'js-disabled' ).addClass( X_UA_classNameForHTML );
                        html[ '_flags' ] |= X_Node_State.IN_TREE;
                        
                        head = X[ 'Doc' ][ 'head' ] = X_Node_head = elmHead && new Node( elmHead );
@@ -303,12 +304,12 @@ X[ 'ViewPort' ] = {
                        body[ 'parent ' ] = head[ 'parent' ] = html;
                        html[ '_xnodes' ] = [ head, body ];
                        
-                       html[ 'appendTo' ] = html[ 'before' ] = html[ 'after' ] = html[ 'clone' ] = html[ 'remove' ] = html[ 'destroy' ] = html[ 'prev' ] = html[ 'next' ] =
+                       html[ 'appendTo' ] = html[ 'prev' ] = html[ 'next' ] = html[ 'clone' ] = html[ 'remove' ] = html[ 'destroy' ] =
                        html[ 'create' ] = html[ 'createText' ] = html[ 'createAt' ] = html[ 'createTextAt' ] = html[ 'append' ] = html[ 'appendAt' ] = html[ 'empty' ] = html[ 'html' ] = html[ 'text' ] =
                        html[ 'css' ] = html[ 'cssText' ] =
-                       head[ 'appendTo' ] = head[ 'before' ] = head[ 'after' ] = head[ 'clone' ] = head[ 'remove' ] = head[ 'destroy' ] =
+                       head[ 'appendTo' ] = head[ 'prev' ] = head[ 'next' ] = head[ 'clone' ] = head[ 'remove' ] = head[ 'destroy' ] =
                        head[ 'createText' ] = head[ 'createTextAt' ] = head[ 'empty' ] = head[ 'html' ] = head[ 'text' ] = head[ 'css' ] = head[ 'cssText' ] =
-                       body[ 'appendTo' ] = body[ 'before' ] = body[ 'after' ] = body[ 'clone' ] = body[ 'remove' ] = body[ 'destroy' ] = new Function( 'return this' );
+                       body[ 'appendTo' ] = body[ 'prev' ] = body[ 'next' ] = body[ 'clone' ] = body[ 'remove' ] = body[ 'destroy' ] = new Function( 'return this' );
 
                        X_ViewPort[ 'listenOnce' ]( X_EVENT_PRE_INIT, function(){
                                X_ViewPort_readyState = X_EVENT_XTREE_READY;
@@ -336,6 +337,9 @@ X[ 'ViewPort' ] = {
                                        defaultOverflow = document.body.style.overflow,
                                        w, h;
                        
+                               X_ViewPort_width  = size[ 0 ];
+                               X_ViewPort_height = size[ 1 ];
+                       
                                body.style.overflow = 'hidden';
                                w = body.clientWidth;
                                h = body.clientHeight;
@@ -356,21 +360,20 @@ X[ 'ViewPort' ] = {
                                };
                                
                                //
-                               if( X_Dom_orientationchange ){
-                                       X_EventDispatcher_systemListen( X_ViewPort, 'orientationchange', X_Dom_orientationchange );
+                               if( X_ViewPort_orientationchange ){
+                                       X_EventDispatcher_systemListen( X_ViewPort, 'orientationchange', X_ViewPort_orientationchange );
                                };
                                
-                               if( X_Dom_detectFontSize ){
+                               if( X_ViewPort_detectFontSize ){
                                        X_EventDispatcher_systemListen( X_ViewPort, 'resize', X_ViewPort_resize );
-                                       X_Timer_add( 333, X_Dom_detectFontSize );
+                                       X_Timer_add( 333, X_ViewPort_detectFontSize );
                                } else {
                                        X_Timer_add( 333, X_ViewPort_resize );
                                };
                                
                                X_ViewPort_baseFontSize = X_Node_fontSizeNode[ '_rawObject' ].offsetHeight;
-                               
-                               X_ViewPort_readyState = X_EVENT_XDOM_READY;
-                               X_ViewPort[ 'asyncDispatch' ]( { type : X_EVENT_XDOM_READY, w : X_ViewPort_width = size[ 0 ], h : X_ViewPort_height = size[ 1 ] } );
+
+                               X_ViewPort[ 'asyncDispatch' ]( X_ViewPort_readyState = X_EVENT_XDOM_READY );
                        } );
 
                        X_ViewPort[ 'asyncDispatch' ]( X_EVENT_PRE_INIT );      
@@ -400,8 +403,10 @@ X[ 'ViewPort' ] = {
                };
 
                function X_ViewPort_getWindowSize(){
-                       return X_UA[ 'IE' ] ?
+                       return X_UA[ 'IE' ] ? // Opera10.1 では ズーム時に表示領域のサイズが取れない!
                                [ X_ViewPort_rootElement.clientWidth, X_ViewPort_rootElement.clientHeight ] :
+                               X_UA[ 'Opera' ] < 12 ? // Opera10.1 では ズーム + resize 時に表示領域のサイズが取れない!
+                               [ X_ViewPort_rootElement.offsetWidth, X_ViewPort_rootElement.offsetHeight ] :
                                [ window.innerWidth, window.innerHeight ];
                };