1 var X_UI_rootData = null,
2 X_UI_eventBusy = false;
4 function X_UI_eventRellay( e ){
5 var font = X_ViewPort_baseFontSize,
6 x = e.pageX / font, // clientX は iOS4- で通らない?
8 type = XUI_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 !== '' + XUI_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_CAPTURE_POINTER ){
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_CAPTURE_POINTER || _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' ][ XUI_Event.POINTER_OUT ] && data[ 'dispatch' ]( e, XUI_Event.POINTER_OUT, false ); // new Event
56 data.hoverClassName && data.xnode.addClassName( data.hoverClassName );
57 data[ '_listeners' ] && data[ '_listeners' ][ XUI_Event.POINTER_IN ] && data[ 'dispatch' ]( e, XUI_Event.POINTER_IN, true ); // new Event
61 X_UI_eventBusy = false;
62 return ret | X_Callback_PREVENT_DEFAULT;
66 * body が存在したら要素を作成、css も指定
67 * 背景画像を読み終える onload で活動開始
70 var XUI_PageRoot = XUI_Box.inherits(
74 layout : XUI_Layout_Canvas,
78 targetNodeData : null,
79 monopolyNodeData : null,
81 xnodeInteractiveLayer : null,
85 Constructor : function( user, layout, args ){
86 this[ 'Super' ]( user, 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 ( X_UA[ 'IE' ] < 9 ? X_ViewPort_document : X_UA[ 'Opera' ] < 8 ? X_Node_body : X_ViewPort )[ 'listen' ]( 'pointermove', X_UI_eventRellay );
118 if( counter[ XUI_Event._POINTER_MOVE ] ){
119 ++counter[ XUI_Event._POINTER_MOVE ];
121 counter[ XUI_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, XUI_PageRoot_do1stCalculate );
133 reserveCalc : function(){
134 if( this.calcReserved === false ){
135 this.calcReserved = true;
136 X_Timer_once( 0, this, this.calculate );
139 calculate : function( e ){
140 var cancelable = !e || ( e.type !== X_EVENT_VIEW_RESIZED && e.type !== X_EVENT_BASE_FONT_RESIZED ),
143 if( this[ 'dispatch' ]( { type : XUI_Event.LAYOUT_BEFORE, 'cancelable' : cancelable } ) & X_Callback_PREVENT_DEFAULT && cancelable ){
144 return X_Callback_NONE;
147 size = X[ 'ViewPort' ][ 'getSize' ]();
148 font = X[ 'ViewPort' ][ 'getBaseFontSize' ]();
149 this.layout.calculate( this, false, 0, 0, size[ 0 ] / font, size[ 1 ] / font );
152 this.calcReserved = false;
154 X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, XUI_PageRoot_onViewUpdate );
156 return X_Callback_NONE;
159 updateCoursor : function( cursor ){
163 _remove : function(){
164 X_EventDispatcher_unlistenAll( this.xnodeInteractiveLayer );
165 _Box.prototype._remove.call( this );
170 function XUI_PageRoot_do1stCalculate(){
174 [ 'listen' ]( X_EVENT_VIEW_RESIZED, this, this.calculate )
175 [ 'listen' ]( X_EVENT_BASE_FONT_RESIZED, this, this.calculate );
178 function XUI_PageRoot_onViewUpdate( e ){
179 this[ 'dispatch' ]( XUI_Event.LAYOUT_COMPLETE );
184 X.UI.PageRoot = X.UI.Box.inherits(
188 Constructor : function(){
191 //if( !XUI_PageRoot ){
192 supports = XUI_Attr_createAttrDef( XUI_Box.prototype.usableAttrs, XUI_Layout_Canvas.overrideAttrsForSelf );
194 XUI_PageRoot.prototype.layout = XUI_Layout_Canvas;
195 XUI_PageRoot.prototype.usableAttrs = supports;
196 XUI_PageRoot.prototype.attrClass = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, {
201 X_Pair_create( this, XUI_PageRoot( this, XUI_Layout_Canvas, arguments ) );
205 X.UI.PageRoot = X.UI.Box.presets(