{
'handleEvent' : function( e ){
- var href, i, name, active = false;
+ var href, i, name, active = false, xnode;
switch( e.type ){
case 'beforeunload' :
break;
case 'visibilitychange' :
+ console.log( e.type + ':' + document[ 'hidden' ] );
X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'hidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
break;
+ case 'msvisibilitychange' :
+ X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'msHidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
+ break;
case 'mozvisibilitychange' :
X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'mozHidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
break;
case 'webkitvisibilitychange' :
+ console.log( e.type + ':' + document[ 'webkitHidden' ] );
X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'webkitHidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
break;
-
case 'blur' :
case 'focusout' :
- case 'pagehide' :
+ if( X_UA[ 'IE' ] < 9 ){
+ xnode = X_Node_getXNode( document.activeElement );
+ if( xnode ){
+ xnode[ 'listen' ]( [ 'focus', 'blur' ], X_ViewPort_detectFocusForIE );
+ //break;
+ };
+ if( X_ViewPort_activeTimerID ){
+ X_ViewPort_activeTimerID = X_Timer_remove( X_ViewPort_activeTimerID );
+ };
+ X_ViewPort_activeTimerID = X_Timer_once( 16, X_ViewPort_changeFocus );
+ return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
+ };
+ case 'pagehide' :
active = true;
case 'focus' :
- case 'focusin' :
case 'pageshow' :
+ case 'focusin' :
if( X_ViewPort_active === active ){
X_ViewPort_active = !active;
- if( X_ViewPort_activeTimerID ){
- X_ViewPort_activeTimerID = X_Timer_remove( X_ViewPort_activeTimerID );
- } else {
- X_ViewPort_activeTimerID = X_Timer_once( 1, X_ViewPort_changeFocus );
- };
+ console.log( e.type + ':' + X_ViewPort_active );
+ X_ViewPort[ 'dispatch' ]( active ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
};
break;
};
}
);
+function X_ViewPort_detectFocusForIE( e ){
+ console.log( 'iefix! ' + e.type + ':' + this.attr( 'tag' ) + ' isActive?:' + ( this[ '_rawObject' ] === document.activeElement ) );
+
+ X_ViewPort_active = e.type === 'focus';
+
+ if( this[ '_rawObject' ] !== document.activeElement ){
+ this[ 'unlisten' ]( X_ViewPort_active ? 'blur' : 'focus', X_ViewPort_detectFocusForIE );
+ };
+ if( X_ViewPort_activeTimerID ){
+ X_ViewPort_activeTimerID = X_Timer_remove( X_ViewPort_activeTimerID );
+ };
+ X_ViewPort_activeTimerID = X_Timer_once( 16, X_ViewPort_changeFocus );
+
+ return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
+};
+
function X_ViewPort_changeFocus(){
X_ViewPort[ 'dispatch' ]( X_ViewPort_active ? X_EVENT_VIEW_ACTIVATE : X_EVENT_VIEW_DEACTIVATE );
X_ViewPort_activeTimerID = 0;
* @alias X.ViewPort.listen
*/
'listen' : function( type, arg1, arg2, arg3 ){
+ var f;
+
if( type <= X_ViewPort_readyState ){
/*
* X_EVENT_XDOM_READY 以後に listen した場合の対策
*/
X_ViewPort[ 'asyncDispatch' ]( type );
};
- // ie8-では keydown -> documentへ
- type && arg1 && X_ViewPort[ 'listen' ]( type, arg1, arg2, arg3 );
+
+ f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
+ if( !f.kind ){
+ X_ViewPort[ 'listen' ]( type, this, arg1 );
+ } else
+ if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ X_ViewPort[ 'listen' ]( type, this, f.func, f.supplement );
+ } else {
+ X_ViewPort[ 'listen' ]( type, arg1, arg2, arg3 );
+ };
return X[ 'ViewPort' ];
},
* @alias X.ViewPort.listenOnce
*/
'listenOnce' : function( type, arg1, arg2, arg3 ){
+ var f;
+
if( type <= X_ViewPort_readyState ){
/*
* X.Event.XDOM_READY 以後に listen した場合の対策
*/
X_ViewPort[ 'asyncDispatch' ]( type );
};
- type && arg1 && X_ViewPort[ 'listenOnce' ]( type, arg1, arg2, arg3 );
+
+ f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
+ if( !f.kind ){
+ X_ViewPort[ 'listenOnce' ]( type, this, arg1 );
+ } else
+ if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ X_ViewPort[ 'listenOnce' ]( type, this, f.func, f.supplement );
+ } else {
+ X_ViewPort[ 'listenOnce' ]( type, arg1, arg2, arg3 );
+ };
return X[ 'ViewPort' ];
},
* @alias X.ViewPort.unlisten
*/
'unlisten' : function( type, arg1, arg2, arg3 ){
- type && arg1 && X_ViewPort[ 'unlisten' ]( type, arg1, arg2, arg3 );
+ var f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
+
+ if( !f.kind ){
+ X_ViewPort[ 'unlisten' ]( type, this, arg1 );
+ } else
+ if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ X_ViewPort[ 'unlisten' ]( type, this, f.func, f.supplement );
+ } else {
+ X_ViewPort[ 'unlisten' ]( type, arg1, arg2, arg3 );
+ };
return X[ 'ViewPort' ];
},
* @alias X.ViewPort.listening
*/
'listening' : function( type, arg1, arg2, arg3 ){
+ var f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
+
+ if( !f.kind ){
+ return X_ViewPort[ 'listening' ]( type, this, arg1 );
+ } else
+ if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ return X_ViewPort[ 'listening' ]( type, this, f.func, f.supplement );
+ };
return X_ViewPort[ 'listening' ]( type, arg1, arg2, arg3 );
},
//(((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.ScrollLeft == 'number' ? t : document.body).ScrollLeft;
//(((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.ScrollTop == 'number' ? t : document.body).ScrollTop
- /**
- *
+ /*
+ * TODO X.Doc へ
* @alias X.ViewPort.getDocumentSize
*/
'getDocumentSize' : function(){
//ブラウザの戻るボタンで戻ったときに呼ばれるイベントとかキャッシュとかそこらへんのこと
//http://d.hatena.ne.jp/koumiya/20080916/1221580149
+console.log( '------------------->' );
+
+ if( document[ 'webkitHidden' ] !== undefined ){
+ console.log( '--> has webkitvisibilitychange' );
+ X_EventDispatcher_systemListen( X_ViewPort_document, 'webkitvisibilitychange', X_ViewPort );
+ } else
if( document[ 'hidden' ] !== undefined ){// iOS 7+
+ console.log( '--> has visibilitychange' );
X_EventDispatcher_systemListen( X_ViewPort_document, 'visibilitychange', X_ViewPort );
+ document.onvisibilitychange = function(){ console.log( '!!!!!!!!!!!!!!!!' ) };
+ } else
+ if( document[ 'msHidden' ] !== undefined ){
+ X_EventDispatcher_systemListen( X_ViewPort_document, 'msvisibilitychange', X_ViewPort );
} else
if( document[ 'mozHidden' ] !== undefined ){
X_EventDispatcher_systemListen( X_ViewPort_document, 'mozvisibilitychange', X_ViewPort );
- } else
- if( document[ 'webkitHidden' ] !== undefined ){
- X_EventDispatcher_systemListen( X_ViewPort_document, 'webkitvisibilitychange', X_ViewPort );
- } else
- if( X_UA[ 'iOS' ] && window[ 'onpageshow' ] !== undefined ){
+ };
+
+ if( window[ 'onpageshow' ] !== undefined ){
+ console.log( '-------------------> pageshow, pagehide' );
X_EventDispatcher_systemListen( X_ViewPort, [ 'pageshow', 'pagehide' ] );
- } else
+ };
+
if( document[ 'onfocusin' ] !== undefined ){
+ console.log( '-------------------> focusin, focusout' );
// https://github.com/ai/visibilityjs/blob/master/lib/visibility.fallback.js
X_EventDispatcher_systemListen( X_ViewPort_document, [ 'focusin', 'focusout' ], X_ViewPort );
- } else {
- X_EventDispatcher_systemListen( X_ViewPort, [ 'focus', 'blur' ] );
};
+
+ X_EventDispatcher_systemListen( X_ViewPort, [ 'focus', 'blur' ] );
return X_CALLBACK_UN_LISTEN;
};