2 X.UI._eventRellay = function( e ){
3 var x = e.clientX / X.Dom.baseFontSize,
4 y = e.clientY / X.Dom.baseFontSize,
5 type = X.UI.Event.NameToID[ e.type ],
7 data = X.UI.currentRootData,
12 // mouseup で alert を出すと mouseleave が発生、ということでイベント中のイベント発火を禁止
13 if( !data || data._eventBusy ) return ret;
14 data._eventBusy = true;
16 if( type !== '' + X.UI.Event._POINTER_MOVE && type !== '' + X.UI.Event._TOUCH_MOVE && type !== '' + X.UI.Event._MOUSE_MOVE ){
17 // console.log( e.type + ' ' + type + ' x:' + x + ', y:' + y );
22 if( data && ( data = data.monopolyNodeData ) && ( ret = data.dispatch( e ) ) & X.Callback.MONOPOLY ){
23 delete X.UI.currentRootData._eventBusy;
27 list = X.UI.currentRootData.hoverList;
28 ( X.UI.currentRootData.targetNodeData = X.UI.currentRootData ).capcher( x, y );
29 data = X.UI.currentRootData.targetNodeData;
31 //data !== X.UI.currentRootData && console.log( data.xnode.text() );
34 _ret = data.dispatch( e, sysOnly );
36 if( _ret & X.Callback.MONOPOLY || _ret & X.Callback.STOP_PROPAGATION || _ret & X.Callback.STOP_NOW ) break; // sysOnly = true;
37 data = data.parentData;
40 for( i = list.length; i; ){
41 parent = data = list[ --i ];
42 while( parent.parentData && parent === parent.parentData.hitChildData ){
43 parent = parent.parentData;
45 if( parent !== X.UI.currentRootData ){
46 data.hoverClassName && data.xnode.removeClass( data.hoverClassName );
47 data._listeners && data._listeners[ X.UI.Event.POINTER_OUT ] && data.dispatch( e, X.UI.Event.POINTER_OUT, false ); // new Event
53 data.hoverClassName && data.xnode.addClassName( data.hoverClassName );
54 data._listeners && data._listeners[ X.UI.Event.POINTER_IN ] && data.dispatch( e, X.UI.Event.POINTER_IN, true ); // new Event
58 delete X.UI.currentRootData._eventBusy;
63 * body が存在したら要素を作成、css も指定
64 * 背景画像を読み終える onload で活動開始
67 X.UI._PageRoot = X.UI._Box.inherits(
69 X.Class.FINAL | X.Class.PRIVATE_DATA | X.Class.SUPER_ACCESS,
71 layout : X.UI.Layout.Canvas,
75 targetNodeData : null,
76 monopolyNodeData : null,
78 xnodeInteractiveLayer : null,
84 Constructor : function( layout, args ){
85 this.SuperConstructor( layout, args );
87 if( X.Dom.readyState === X.Dom.Event.XDOM_READY ){
88 X.Timer.once( 0, this, this.start );
90 X.Dom.listenOnce( X.Dom.Event.XDOM_READY, this, this.start );
94 this.eventCounter = {};
96 X.UI.currentRootData = this;
100 this.initialize( this.User, this, null, null );
101 X.Timer.once( 0, this, this.addToView );
103 addToView : function(){
104 var counter = this.eventCounter, flg;
106 // this.xnodeInteractiveLayer の前に追加する!
108 this.addToParent( X.Dom.Node._body );
110 this.xnodeInteractiveLayer = X.Dom.Node._body.create( 'div', {
111 'class' : 'mouse-operation-catcher',
115 // hover や rollover rollout のための move イベントの追加
116 // X.Dom.Event.activate, X.Dom.Event.deactivate ?
117 // mouseout, mouseover
118 if( X.Dom.EVENT_POINTER ){
119 this.xnodeInteractiveLayer.listen( X.UI.Event.IdToName[ X.UI.Event._POINTER_MOVE ], X.UI._eventRellay );
120 if( counter[ X.UI.Event._POINTER_MOVE ] ){
121 ++counter[ X.UI.Event._POINTER_MOVE ];
123 counter[ X.UI.Event._POINTER_MOVE ] = 1;
126 this.xnodeInteractiveLayer.listen( X.UI.Event.IdToName[ X.UI.Event._MOUSE_MOVE ], X.UI._eventRellay );
127 if( counter[ X.UI.Event._MOUSE_MOVE ] ){
128 ++counter[ X.UI.Event._MOUSE_MOVE ];
130 counter[ X.UI.Event._MOUSE_MOVE ] = 1;
133 X.Timer.once( 0, this, this.afterAddToView );
135 afterAddToView : function(){
136 this.xnode.className( 'PageRoot' );
138 this.creationComplete();
139 X.Timer.once( 0, this, this.doFirstCalc );
142 doFirstCalc : function(){
146 .listen( X.Dom.Event.VIEW_RESIZED, this, this.calculate )
147 .listen( X.Dom.Event.BASE_FONT_RESIZED, this, this.calculate );
150 reserveCalc : function(){
151 if( this.calcReserved === false ){
152 this.calcReserved = true;
153 X.Timer.once( 0, this, this.calculate );
156 calculate : function( e ){
157 var font = X.Dom.baseFontSize,
160 size = X.Dom.getSize();
167 this.layout.calculate( this, false, 0, 0, w / font, h / font );
168 this.calcReserved = false;
171 updateCoursor : function( cursor ){
175 _remove : function(){
176 this.xnodeInteractiveLayer.unlisten();
177 _Box.prototype._remove.call( this );
182 X.UI.PageRoot = X.UI.Box.presets(