var X_ViewPort_readyState,
- X_ViewPort_active = !!window.parent || !!document.activeElement, // parent は frameに読み込まれた場合のieのerror回避
+ X_ViewPort_active = ( window.parent === window ) || !window.parent, // parent は frameに読み込まれた場合のieのerror回避
X_ViewPort_activeTimerID,
X_ViewPort_rootElement,
X_ViewPort_lock,
case 'visibilitychange' :
console.log( e.type + ':' + document[ 'hidden' ] );
- X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'hidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
+ X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = !document[ 'hidden' ] ) ? X_EVENT_VIEW_ACTIVATE : X_EVENT_VIEW_DEACTIVATE );
break;
case 'msvisibilitychange' :
- X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'msHidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
+ console.log( e.type + ':' + document[ 'msHidden' ] );
+ X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = !document[ 'msHidden' ] ) ? X_EVENT_VIEW_ACTIVATE : X_EVENT_VIEW_DEACTIVATE );
break;
case 'mozvisibilitychange' :
- X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = document[ 'mozHidden' ] ) ? X_EVENT_VIEW_DEACTIVATE : X_EVENT_VIEW_ACTIVATE );
+ console.log( e.type + ':' + document[ 'mozHidden' ] );
+ X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = !document[ 'mozHidden' ] ) ? X_EVENT_VIEW_ACTIVATE : X_EVENT_VIEW_DEACTIVATE );
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 );
+ X_ViewPort[ 'dispatch' ]( ( X_ViewPort_active = !document[ 'webkitHidden' ] ) ? X_EVENT_VIEW_ACTIVATE : X_EVENT_VIEW_DEACTIVATE );
break;
case 'blur' :
case 'focusout' :
- if( X_UA[ 'IE' ] < 9 ){
+ if( 5 < X_UA[ 'IE' ] && X_UA[ 'IE' ] < 9 ){
xnode = X_Node_getXNode( document.activeElement );
if( xnode ){
- xnode[ 'listen' ]( [ 'focus', 'blur' ], X_ViewPort_detectFocusForIE );
+ xnode[ 'listenOnce' ]( [ 'focus', 'blur' ], X_ViewPort_detectFocusForIE );
//break;
};
if( X_ViewPort_activeTimerID ){
X_ViewPort_activeTimerID = X_Timer_once( 16, X_ViewPort_changeFocus );
return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
};
+ // 他の要素のfocusout がバブルアップしてきたもの
+ if( e.target !== X_ViewPort_document ) break;
case 'pagehide' :
active = true;
case 'focus' :
);
function X_ViewPort_detectFocusForIE( e ){
- console.log( 'iefix! ' + e.type + ':' + this.attr( 'tag' ) + ' isActive?:' + ( this[ '_rawObject' ] === document.activeElement ) );
-
+ //console.log( 'iefix! ' + e.type + ':' + this.attr( 'tag' ) + ' isActive?:' + ( this[ '_rawObject' ] === document.activeElement ) );
+ var elmActive = X_Script_try( X_Object_find, [ document, 'activeElement' ] );
X_ViewPort_active = e.type === 'focus';
- if( this[ '_rawObject' ] !== document.activeElement ){
+
+ if( elmActive && this[ '_rawObject' ] !== elmActive ){
this[ 'unlisten' ]( X_ViewPort_active ? 'blur' : 'focus', X_ViewPort_detectFocusForIE );
+ console.log( '>>>>>> activeElement 取得 不一致 ' + this._tag );
+ } else
+ if( !elmActive ){
+ console.log( '******** activeElement 取得のエラー' );
+ } else if( elmActive ){
+ console.log( '>>>>>> activeElement 取得' );
};
+
if( X_ViewPort_activeTimerID ){
- X_ViewPort_activeTimerID = X_Timer_remove( X_ViewPort_activeTimerID );
+ X_Timer_remove( X_ViewPort_activeTimerID );
};
X_ViewPort_activeTimerID = X_Timer_once( 16, X_ViewPort_changeFocus );
};
f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
- if( !f.kind ){
+ if( !f.cbKind ){
X_ViewPort[ 'listen' ]( type, this, arg1 );
} else
- if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ if( f.cbKind === X_CLOSURE_FUNC_ONLY ){
X_ViewPort[ 'listen' ]( type, this, f.func, f.supplement );
} else {
X_ViewPort[ 'listen' ]( type, arg1, arg2, arg3 );
};
f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
- if( !f.kind ){
+ if( !f.cbKind ){
X_ViewPort[ 'listenOnce' ]( type, this, arg1 );
} else
- if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ if( f.cbKind === X_CLOSURE_FUNC_ONLY ){
X_ViewPort[ 'listenOnce' ]( type, this, f.func, f.supplement );
} else {
X_ViewPort[ 'listenOnce' ]( type, arg1, arg2, arg3 );
'unlisten' : function( type, arg1, arg2, arg3 ){
var f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
- if( !f.kind ){
+ if( !f.cbKind ){
X_ViewPort[ 'unlisten' ]( type, this, arg1 );
} else
- if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ if( f.cbKind === X_CLOSURE_FUNC_ONLY ){
X_ViewPort[ 'unlisten' ]( type, this, f.func, f.supplement );
} else {
X_ViewPort[ 'unlisten' ]( type, arg1, arg2, arg3 );
'listening' : function( type, arg1, arg2, arg3 ){
var f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 );
- if( !f.kind ){
+ if( !f.cbKind ){
return X_ViewPort[ 'listening' ]( type, this, arg1 );
} else
- if( f.kind === X_CLOSURE_FUNC_ONLY ){
+ if( f.cbKind === 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 へ
+ // TODO X.Doc へ
+ /**
* @alias X.ViewPort.getDocumentSize
*/
'getDocumentSize' : function(){
return X_ViewPort_baseFontSize = X_Node_fontSizeNode[ '_rawObject' ].offsetHeight;
};
return X_ViewPort_baseFontSize;
+ },
+
+ /**
+ * キーボードイベントを受け付ける
+ * @alias X.ViewPort.isActive
+ */
+ 'isActive' : function(){
+ return X_ViewPort_active;
+ },
+
+ /**
+ * 可視である。iframe 内のhtmlも
+ * @alias X.ViewPort.isVisible
+ */
+ 'isVisible' : function(){
+ return X_ViewPort_active;
}
};
if( X_UA_EVENT.W3C ){
X_ViewPort_document[ 'listenOnce' ]( 'DOMContentLoaded', X_TEMP.onDomContentLoaded );
} else
-if( 6 <= X_UA[ 'IE' ] && X[ 'inHead' ] ){
+if( 6 <= X_UA[ 'IE' ] && X[ 'inHead' ] && !X_UA[ 'ieExeComError' ] ){ // standalone の除外 -> && !X_UA[ 'ieExeComError' ]
// if this script in Head
- //document.write( '<script id="__ie_onload" defer src="javascript:void(0)"></script>' );
- //X_TEMP._script = document.getElementById( '__ie_onload' );
+ //document.write( '<script id=__ieonload defer src=javascript:void(0)></script>' );
+ //X_TEMP._script = document.getElementById( '__ieonload' );
// 上のコードはスタンドアローン版ie6でエラー
- X_TEMP._script = document.createElement( '<script id="__ie_onload" defer src="javascript:void(0)"></script>' ) ;
- document.getElementsByTagName("head")[ 0 ].appendChild( X_TEMP._script );
+ X_TEMP._script = document.createElement( '<script id=__ieonload defer src=javascript:void(0)></script>' ) ;
+ document.getElementsByTagName( 'head' )[ 0 ].appendChild( X_TEMP._script );
X_TEMP._script.onreadystatechange = function(){
var s = X_TEMP._script;
if( s && s.readyState === 'complete' ){
s.onreadystatechange = X_emptyFunction;
s.onreadystatechange = null;
- s.parentNode.removeChild( s );
+ s.removeNode( true );
delete X_TEMP._script;
X_TEMP.onDomContentLoaded && X_TEMP.onDomContentLoaded();
};