X-Git-Url: http://git.osdn.jp/view?p=pettanr%2FclientJs.git;a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F21_XViewPort.js;fp=0.6.x%2Fjs%2F01_core%2F21_XViewPort.js;h=5c469020eb9bc48b1fb4dacb8ea3c06ab30614c0;hp=54a07fe0d8efe24d2245bdc7714fddbc25051e06;hb=604668ba9efa027d4bc77fd8020d6b6be55d03e1;hpb=ef25747bebf1799d49f9bd0d64e339da9ea61d13 diff --git a/0.6.x/js/01_core/21_XViewPort.js b/0.6.x/js/01_core/21_XViewPort.js index 54a07fe..5c46902 100644 --- a/0.6.x/js/01_core/21_XViewPort.js +++ b/0.6.x/js/01_core/21_XViewPort.js @@ -1,6 +1,6 @@ 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, @@ -35,11 +35,11 @@ X_ViewPort = X_Class_override( { '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; @@ -74,12 +74,8 @@ X_ViewPort = X_Class_override( 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; @@ -111,18 +107,18 @@ X_ViewPort = X_Class_override( 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 ){ @@ -370,7 +366,7 @@ X[ 'ViewPort' ] = { * http://sssslide.com/www.slideshare.net/hiroakiwakamatsu/ss-12718639 * * - * getBoundingClientRect で fontsize の調査 + * getBoundingClientRect で fontsize の調査 */ var X_ViewPort_resize = // iOS もループで回す,,,iOS3.1.3, iOS6 で確認 @@ -508,7 +504,7 @@ X[ 'ViewPort' ] = { 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; }; @@ -538,16 +534,17 @@ X[ 'ViewPort' ] = { //ブラウザの戻るボタンで戻ったときに呼ばれるイベントとかキャッシュとかそこらへんのこと //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 ); }; @@ -560,11 +557,21 @@ 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 ] :