var X_ViewPort_readyState,
- X_ViewPort_active = ( window.parent === window ) || !window.parent, // 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,
{
'handleEvent' : function( e ){
- var href, i, name, active = false, xnode;
+ var href, i, name, active = false, elm, xnode;
switch( e.type ){
case 'beforeunload' :
- // ie では a href='javascript' な要素でも beforeunload が起こる
+ // ie では a href='javascript' な要素でも beforeunload が起こる
href = e.target && e.target[ 'attr' ] && e.target[ 'attr' ]( 'href' );
if( X_Type_isString( href ) && !href.toLowerCase().indexOf( 'javascript:' ) ) return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
case 'blur' :
case 'focusout' :
- if( ( 5.5 < X_UA[ 'IE' ] && X_UA[ 'IE' ] < 9 )
- ||
- // TODO ie5... activeElement に障るとエラーになるため VBS 経由で activeElement に触り安全確認する(未確認)
- ( 5 <= X_UA[ 'IE' ] && X_UA[ 'IE' ] < 5.5 && !window[ 'vbs_testAE' ]() )
- ){
- xnode = X_Node_getXNode( document.activeElement );
+ if( X_UA[ 'IE' ] < 9 && ( elm = FocusUtility_getFocusedElement() ) ){
+ xnode = X_Node_getXNode( elm );
if( xnode ){
xnode[ 'listenOnce' ]( [ 'focus', 'blur' ], X_ViewPort_detectFocusForIE );
//break;
function X_ViewPort_detectFocusForIE( e ){
//console.log( 'iefix! ' + e.type + ':' + this.attr( 'tag' ) + ' isActive?:' + ( this[ '_rawObject' ] === document.activeElement ) );
- var elmActive = X_Script_try( X_Object_find, [ document, 'activeElement' ] );
+ var elmActive = FocusUtility_getFocusedElement();
X_ViewPort_active = e.type === 'focus';
if( elmActive && this[ '_rawObject' ] !== elmActive ){
this[ 'unlisten' ]( X_ViewPort_active ? 'blur' : 'focus', X_ViewPort_detectFocusForIE );
- console.log( '>>>>>> activeElement 取得 不一致 ' + this._tag );
+ console.log( '>>>>>> activeElement 取得 不一致 ' + this._tag );
} else
if( !elmActive ){
- console.log( '******** activeElement 取得のエラー' );
+ //console.log( '******** activeElement 取得のエラー' );
} else if( elmActive ){
- console.log( '>>>>>> activeElement 取得' );
+ //console.log( '>>>>>> activeElement 取得' );
};
if( X_ViewPort_activeTimerID ){
* http://sssslide.com/www.slideshare.net/hiroakiwakamatsu/ss-12718639
*
*
- * getBoundingClientRect で fontsize の調査
+ * getBoundingClientRect で fontsize の調査
*/
var X_ViewPort_resize =
// iOS もループで回す,,,iOS3.1.3, iOS6 で確認
X_ViewPort_vScrollbarSize = w;
X_ViewPort_hScrollbarSize = h;
- if( h <= 0 ){ // ie6, ie11, firefox で 負の値が返る
+ if( h <= 0 ){ // ie6, ie11, firefox で 負の値が返る
console.log( 'invalid hScrollbarSize: ' + h );
X_ViewPort_hScrollbarSize = w;
};
//ブラウザの戻るボタンで戻ったときに呼ばれるイベントとかキャッシュとかそこらへんのこと
//http://d.hatena.ne.jp/koumiya/20080916/1221580149
- if( document[ 'webkitHidden' ] !== undefined ){
- X_ViewPort_document[ 'listen' ]( 'webkitvisibilitychange', X_ViewPort );
- } else
if( document[ 'hidden' ] !== undefined ){// iOS 7+
X_ViewPort_document[ 'listen' ]( 'visibilitychange', X_ViewPort );
} else
+ if( document[ 'webkitHidden' ] !== undefined ){
+ X_ViewPort_document[ 'listen' ]( 'webkitvisibilitychange', X_ViewPort );
+ } else
if( document[ 'msHidden' ] !== undefined ){
X_ViewPort_document[ 'listen' ]( 'msvisibilitychange', X_ViewPort );
} else
if( document[ 'mozHidden' ] !== undefined ){
+ // TODO Firefox + Android2 でブラウザにフォーカスが戻ったことが判らない...
X_ViewPort_document[ 'listen' ]( 'mozvisibilitychange', X_ViewPort );
};
X_ViewPort_document[ 'listen' ]( [ 'focusin', 'focusout' ], X_ViewPort );
};
+ // TODO activeElement が無い対策
+ if( !FocusUtility_docActiveElmSupport ){
+ X_ViewPort[ 'listen' ]( 'focus', X_ViewPort_fixActiveElm );
+ };
+
X_ViewPort[ 'listen' ]( [ 'focus', 'blur' ] );
return X_CALLBACK_UN_LISTEN;
};
+ function X_ViewPort_fixActiveElm( e ){
+ // textNode を修正して elm にする処理は EventDisptcher に入っている
+ FocusUtility_fixActiveElm = e.target[ '_rawObject' ];
+ };
+
function X_ViewPort_getWindowSize(){
return X_UA[ 'IE' ] ? // Opera10.1 では ズーム時に表示領域のサイズが取れない!
[ X_ViewPort_rootElement.clientWidth, X_ViewPort_rootElement.clientHeight ] :