X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F21_XViewPort.js;h=5c469020eb9bc48b1fb4dacb8ea3c06ab30614c0;hb=HEAD;hp=1dc98e944f7a02985b3ec90b88d77a862b378b76;hpb=bafa8683f87b2f909d1301fca80684bf9ff221ed;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_core/21_XViewPort.js b/0.6.x/js/01_core/21_XViewPort.js index 1dc98e9..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; @@ -49,10 +49,9 @@ X_ViewPort = X_Class_override( //https://developer.mozilla.org/ja/docs/Web/JavaScript/A_re-introduction_to_JavaScript //Firefox 1.5 の bfcache が無効になりますので、他に理由がない限り Firefox では unload リスナを登録するべきではないことに注意してください。 X_ViewPort[ 'dispatch' ]( X_EVENT_UNLOAD ); - //alert('unload'); + //alert('unload'); X_ViewPort_document[ 'kill' ](); X_ViewPort[ 'kill' ](); - //X_System[ 'dispatch' ]( X_EVENT_SHUT_DOWN ); break; @@ -75,9 +74,8 @@ X_ViewPort = X_Class_override( case 'blur' : case 'focusout' : - // TODO ie5... - if( 5.5 < X_UA[ 'IE' ] && X_UA[ 'IE' ] < 9 ){ - 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; @@ -109,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 ){ @@ -368,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 で確認 @@ -438,7 +436,7 @@ X[ 'ViewPort' ] = { * @alias X.Doc.html * @type {Node} */ - X[ 'Doc' ][ 'html' ] = html = X_Node_html = X_elmHtml && Node( X_elmHtml )[ 'removeClass' ]( 'js-disabled' )[ 'addClass' ]( X_UA_classNameForHTML ); + X[ 'Doc' ][ 'html' ] = html = X_Node_html = X_elmHtml && Node( X_elmHtml )[ 'removeClass' ]( 'js-disabled' )[ 'addClass' ]( X_UA_classNameForHTML.split( '.' ).join( '_' ) ); html[ '_flags' ] |= X_NodeFlags_IN_TREE; /** @@ -506,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; }; @@ -536,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 ); }; @@ -558,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 ] :