OSDN Git Service

Version 0.6.142, fix X.UI.ScrollBox.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 20_PageRoot.js
index ec3524c..a73c3e6 100644 (file)
@@ -127,15 +127,7 @@ var XUI_PageRoot = XUI_Box.inherits(
                        this.xnode[ 'className' ]( 'PageRoot' );
                        
                        this.creationComplete();
-                       X_Timer_once( 0, this, this.doFirstCalc );
-               },
-               
-               doFirstCalc : function(){
-                       this.calculate();
-                       this.phase = 4;
-                       X.ViewPort
-                               [ 'listen' ]( X_EVENT_VIEW_RESIZED, this, this.calculate )
-                               [ 'listen' ]( X_EVENT_BASE_FONT_RESIZED, this, this.calculate );
+                       X_Timer_once( 0, this, XUI_PageRoot_do1stCalculate );
                },
                
                reserveCalc : function(){
@@ -145,9 +137,12 @@ var XUI_PageRoot = XUI_Box.inherits(
                        };
                },
                calculate : function( e ){
-                       var size, font, w, h;
+                       var cancelable = !e || ( e.type !== X_EVENT_VIEW_RESIZED && e.type !== X_EVENT_BASE_FONT_RESIZED ),
+                               size, font, w, h;
                        
-                       this[ 'dispatch' ]( XUI_Event.LAYOUT_BEFORE );
+                       if( this[ 'dispatch' ]( { type : XUI_Event.LAYOUT_BEFORE, 'cancelable' : cancelable } ) & X_Callback_PREVENT_DEFAULT && cancelable ){
+                               return X_Callback_NONE;
+                       };
                        
                        size = X[ 'ViewPort' ][ 'getSize' ]();
                        font = X[ 'ViewPort' ][ 'getBaseFontSize' ]();
@@ -157,6 +152,8 @@ var XUI_PageRoot = XUI_Box.inherits(
                        this.calcReserved = false;
                        
                        X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, XUI_PageRoot_onViewUpdate );
+                       
+                       return X_Callback_NONE;
                },
                
                updateCoursor : function( cursor ){
@@ -170,6 +167,14 @@ var XUI_PageRoot = XUI_Box.inherits(
        }
 );
 
+function XUI_PageRoot_do1stCalculate(){
+       this.calculate();
+       this.phase = 4;
+       X.ViewPort
+               [ 'listen' ]( X_EVENT_VIEW_RESIZED, this, this.calculate )
+               [ 'listen' ]( X_EVENT_BASE_FONT_RESIZED, this, this.calculate );
+};
+
 function XUI_PageRoot_onViewUpdate( e ){
        this[ 'dispatch' ]( XUI_Event.LAYOUT_COMPLETE );
 };