1 var X_UI_rootData = null,
2 X_UI_eventBusy = false;
4 function X_UI_eventRellay( e ){
5 var font = X.ViewPort.getBaseFontSize(),
8 type = X.UI.Event.NameToID[ e.type ],
12 ret = X.Callback.NONE,
15 // mouseup で alert を出すと mouseleave が発生、ということでイベント中のイベント発火を禁止
16 if( !data || X_UI_eventBusy ) return ret;
17 data._eventBusy = true;
19 if( type !== '' + X.UI.Event._POINTER_MOVE ){
20 //console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y );
25 if( data && ( data = data.monopolyNodeData ) && ( ret = data.dispatch( e ) ) & X.Callback.MONOPOLY ){
26 X_UI_eventBusy = false;
27 return ret | X.Callback.PREVENT_DEFAULT;
30 list = X_UI_rootData.hoverList;
31 ( X_UI_rootData.targetNodeData = X_UI_rootData ).capcher( x, y );
32 data = X_UI_rootData.targetNodeData;
34 //data !== X_UI_rootData && console.log( data.xnode.text() );
37 _ret = data.dispatch( e, sysOnly );
39 if( _ret & X.Callback.MONOPOLY || _ret & X.Callback.STOP_PROPAGATION || _ret & X.Callback.STOP_NOW ) break; // sysOnly = true;
40 data = data.parentData;
43 for( i = list.length; i; ){
44 parent = data = list[ --i ];
45 while( parent.parentData && parent === parent.parentData.hitChildData ){
46 parent = parent.parentData;
48 if( parent !== X_UI_rootData ){
49 data.hoverClassName && data.xnode.removeClass( data.hoverClassName );
50 data._listeners && data._listeners[ X.UI.Event.POINTER_OUT ] && data.dispatch( e, X.UI.Event.POINTER_OUT, false ); // new Event
56 data.hoverClassName && data.xnode.addClassName( data.hoverClassName );
57 data._listeners && data._listeners[ X.UI.Event.POINTER_IN ] && data.dispatch( e, X.UI.Event.POINTER_IN, true ); // new Event
61 X_UI_eventBusy = false;
62 return ret | X.Callback.PREVENT_DEFAULT;
66 * body が存在したら要素を作成、css も指定
67 * 背景画像を読み終える onload で活動開始
70 X.UI._PageRoot = X.UI._Box.inherits(
72 X.Class.FINAL | X.Class.PRIVATE_DATA | X.Class.SUPER_ACCESS,
74 layout : X.UI.Layout.Canvas,
78 targetNodeData : null,
79 monopolyNodeData : null,
81 xnodeInteractiveLayer : null,
85 Constructor : function( layout, args ){
86 this.Super( layout, args );
88 if( X_ViewPort_readyState === X_Event.XDOM_READY ){
89 X.Timer.once( 0, this, this.start );
91 X.ViewPort.listenOnce( X_Event.XDOM_READY, this, this.start );
95 this.eventCounter = {};
101 this.initialize( this.User, this, null, null );
102 X.Timer.once( 0, this, this.addToView );
104 addToView : function(){
105 var counter = this.eventCounter, flg;
107 // this.xnodeInteractiveLayer の前に追加する!
109 this.addToParent( X.Doc.body );
111 this.xnodeInteractiveLayer = X.Doc.body.create( 'div', {
112 'class' : 'mouse-operation-catcher',
116 // hover や rollover rollout のための move イベントの追加
117 this.xnodeInteractiveLayer.listen( X.UI.Event.IdToName[ X.UI.Event._POINTER_MOVE ], X_UI_eventRellay );
118 if( counter[ X.UI.Event._POINTER_MOVE ] ){
119 ++counter[ X.UI.Event._POINTER_MOVE ];
121 counter[ X.UI.Event._POINTER_MOVE ] = 1;
124 X.Timer.once( 0, this, this.afterAddToView );
126 afterAddToView : function(){
127 this.xnode.className( 'PageRoot' );
129 this.creationComplete();
130 X.Timer.once( 0, this, this.doFirstCalc );
133 doFirstCalc : function(){
137 .listen( X_Event.VIEW_RESIZED, this, this.calculate )
138 .listen( X_Event.BASE_FONT_RESIZED, this, this.calculate );
141 reserveCalc : function(){
142 if( this.calcReserved === false ){
143 this.calcReserved = true;
144 X.Timer.once( 0, this, this.calculate );
147 calculate : function( e ){
148 var size = X.ViewPort.getSize(),
149 font = X.ViewPort.getBaseFontSize(),
152 this.layout.calculate( this, false, 0, 0, w / font, h / font );
153 this.calcReserved = false;
156 updateCoursor : function( cursor ){
160 _remove : function(){
161 this.xnodeInteractiveLayer.unlisten();
162 _Box.prototype._remove.call( this );
167 X.UI.PageRoot = X.UI.Box.presets(