X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F21_XViewPort.js;h=54a07fe0d8efe24d2245bdc7714fddbc25051e06;hb=ef25747bebf1799d49f9bd0d64e339da9ea61d13;hp=7c29e7d60ef85b247492820d107c6c795c026d6a;hpb=1ed2190f012cf923f7e48d3c0d122aa56c56c5f3;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 7c29e7d..54a07fe 100644
--- a/0.6.x/js/01_core/21_XViewPort.js
+++ b/0.6.x/js/01_core/21_XViewPort.js
@@ -41,7 +41,7 @@ X_ViewPort = X_Class_override(
case 'beforeunload' :
// ie ã§ã¯ãa href='javascript' ãªè¦ç´ ã§ã beforeunload ãèµ·ãã
href = e.target && e.target[ 'attr' ] && e.target[ 'attr' ]( 'href' );
- if( href && href.indexOf && href.indexOf( 'javascript:' ) === 0 ) return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
+ if( X_Type_isString( href ) && !href.toLowerCase().indexOf( 'javascript:' ) ) return X_CALLBACK_PREVENT_DEFAULT | X_CALLBACK_STOP_PROPAGATION;
return X_ViewPort[ 'dispatch' ]( X_EVENT_BEFORE_UNLOAD );
@@ -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' ]();
- this[ 'kill' ]();
-
+ X_ViewPort[ 'kill' ]();
//X_System[ 'dispatch' ]( X_EVENT_SHUT_DOWN );
break;
@@ -75,7 +74,11 @@ X_ViewPort = X_Class_override(
case 'blur' :
case 'focusout' :
- if( 5 < X_UA[ 'IE' ] && X_UA[ 'IE' ] < 9 ){
+ 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( xnode ){
xnode[ 'listenOnce' ]( [ 'focus', 'blur' ], X_ViewPort_detectFocusForIE );
@@ -136,6 +139,7 @@ function X_ViewPort_changeFocus(){
};
+// TODO EventDispatcherProxy
/**
* window ã«ç¸å½ãã ViewPort æ
å ±ãæä¾ãããªãã¸ã§ã¯ãã
* @namespace X.ViewPort
@@ -256,8 +260,8 @@ X[ 'ViewPort' ] = {
},
//https://developer.mozilla.org/en-US/docs/Web/API/Element.getBoundingClientRect
//use window.pageXOffset and window.pageYOffset instead of window.scrollX and window.scrollY
-//(((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
+//(((t = document.documentElement) || (t = X_elmBody.parentNode)) && typeof t.ScrollLeft == 'number' ? t : X_elmBody).ScrollLeft;
+//(((t = document.documentElement) || (t = X_elmBody.parentNode)) && typeof t.ScrollTop == 'number' ? t : X_elmBody).ScrollTop
// TODO X.Doc ã¸
/**
@@ -268,12 +272,13 @@ X[ 'ViewPort' ] = {
// http://orera.g.hatena.ne.jp/edvakf/20100515/1273908051
//http://onozaty.hatenablog.com/entry/20060803/p1
// Safari2.0.4ã§ã¯æ¨æºã»äºæã©ã¡ãã document.body
+ // http://hisasann.com/housetect/2008/08/jqueryheightwidthopera95.html ãã®document.body[ "client" + name ]ã¯ããããOpera9.5æªæºã®ãã¼ã¸ã§ã³ã§æå¹ãªããããªãããªï¼
X_Node_updateTimerID && X_Node_startUpdate();
/*X_UA[ 'Opera' ] ?
( document.documentElement && document.documentElement.clientWidth ?
new Function( 'return[document.documentElement.clientWidth,document.documentElement.clientHeight]' ) :
- new Function( 'return[document.body.clientWidth,document.body.clientHeight]' )
+ new Function( 'return[X_elmBody.clientWidth,X_elmBody.clientHeight]' )
) :*/
return [
X_ViewPort_rootElement.scrollWidth || X_ViewPort_rootElement.offsetWidth,
@@ -299,7 +304,7 @@ X[ 'ViewPort' ] = {
( function(){
X_Node_updateTimerID && X_Node_startUpdate();
// body 㯠Safari2-
- return[ X_ViewPort_scrollX = X_ViewPort_rootElement.scrollLeft || document.body.scrollLeft, X_ViewPort_scrollY = X_ViewPort_rootElement.scrollTop || document.body.scrollTop ];
+ return[ X_ViewPort_scrollX = X_ViewPort_rootElement.scrollLeft || X_elmBody.scrollLeft, X_ViewPort_scrollY = X_ViewPort_rootElement.scrollTop || X_elmBody.scrollTop ];
} ),
/**
@@ -415,7 +420,7 @@ X[ 'ViewPort' ] = {
};
X_TEMP.onDomContentLoaded = function(){
- var s, size, elmHtml, elmHead, elmBody, html, head, body;
+ var html, head, body;
console.log( '> X_TEMP.onDomContentLoaded rs:' + X_ViewPort_readyState );
@@ -425,40 +430,32 @@ X[ 'ViewPort' ] = {
// DOMContentLoaded ã®ç¡ããã©ã¦ã¶ã§ X_TEMP.onDomContentLoaded ã¸ã®åç
§ãæ®ãç¶ããã®ãåé¿
X_TEMP.onDomContentLoaded && X_ViewPort_document[ 'unlisten' ]( 'DOMContentLoaded', X_TEMP.onDomContentLoaded );
delete X_TEMP.onDomContentLoaded;
-
- elmHtml = document.documentElement ||
- X_UA_DOM.W3C ? document.getElementsByTagName( 'html' )[ 0 ] :
- X_UA_DOM.IE4 ? document.all.tags( 'html' )[ 0 ] : null;
-
- elmHead =
- X_UA_DOM.W3C ? document.getElementsByTagName( 'head' )[ 0 ] :
- X_UA_DOM.IE4 ? document.all.tags( 'head' )[ 0 ] : null;
- elmBody = document.body;
+ X_elmBody = document.body;
- X_ViewPort_rootElement = document.compatMode !== 'CSS1Compat' ? elmBody : elmHtml || elmBody;
+ X_ViewPort_rootElement = document.compatMode !== 'CSS1Compat' ? X_elmBody : X_elmHtml || X_elmBody;
/**
- * Node( documentElement )
+ * X.Node( documentElement )
* @alias X.Doc.html
* @type {Node}
*/
- X[ 'Doc' ][ 'html' ] = html = X_Node_html = elmHtml && Node( 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;
/**
- * Node( head )
+ * X.Node( head )
* @alias X.Doc.head
* @type {Node}
*/
- X[ 'Doc' ][ 'head' ] = head = X_Node_head = elmHead && Node( elmHead );
+ X[ 'Doc' ][ 'head' ] = head = X_Node_head = X_elmHead && Node( X_elmHead );
/**
- * Node( documentElement )
+ * X.Node( body )
* @alias X.Doc.body
* @type {Node}
*/
- X[ 'Doc' ][ 'body' ] = body = X_Node_body = Node( elmBody );
+ X[ 'Doc' ][ 'body' ] = body = X_Node_body = Node( X_elmBody );
body[ 'parent ' ] = head[ 'parent' ] = html;
html[ '_xnodes' ] = [ head, body ];
@@ -466,13 +463,12 @@ X[ 'ViewPort' ] = {
html[ 'appendTo' ] = html[ 'prev' ] = html[ 'next' ] = html[ 'clone' ] = html[ 'remove' ] = html[ 'kill' ] =
html[ 'create' ] = html[ 'createText' ] = html[ 'createAt' ] = html[ 'createTextAt' ] = html[ 'append' ] = html[ 'appendAt' ] = html[ 'empty' ] = html[ 'html' ] = html[ 'text' ] =
html[ 'css' ] = html[ 'cssText' ] =
- head[ 'appendTo' ] = head[ 'prev' ] = head[ 'next' ] = head[ 'clone' ] = head[ 'remove' ] = head[ 'kill' ] =
+ head[ 'appendTo' ] = head[ 'prev' ] = head[ 'clone' ] = head[ 'remove' ] = head[ 'kill' ] =
head[ 'createText' ] = head[ 'createTextAt' ] = head[ 'empty' ] = head[ 'html' ] = head[ 'text' ] = head[ 'css' ] = head[ 'cssText' ] =
- body[ 'appendTo' ] = body[ 'prev' ] = body[ 'next' ] = body[ 'clone' ] = body[ 'remove' ] = body[ 'kill' ] = new Function( 'return this' );
+ body[ 'appendTo' ] = body[ 'next' ] = body[ 'clone' ] = body[ 'remove' ] = body[ 'kill' ] = new Function( 'return this' );
X_ViewPort[ 'listenOnce' ]( X_EVENT_PRE_INIT, function(){
X_ViewPort_readyState = X_EVENT_XTREE_READY;
- if( X_TEMP.X_Dom_useBuilder ) X_TEMP.X_Dom_useBuilder = !!document.body.children.length;
!X_TEMP.X_Dom_useBuilder && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_XTREE_READY );
} );
@@ -492,24 +488,23 @@ X[ 'ViewPort' ] = {
var size = X_ViewPort_getWindowSize(),
// http://jsdo.it/imaya/kTYg
- body = document.body,
- defaultOverflow = document.body.style.overflow,
+ defaultOverflow = X_elmBody.style.overflow,
w, h;
X_ViewPort_width = size[ 0 ];
X_ViewPort_height = size[ 1 ];
- body.style.overflow = 'hidden';
- w = body.clientWidth;
- h = body.clientHeight;
+ X_elmBody.style.overflow = 'hidden';
+ w = X_elmBody.clientWidth;
+ h = X_elmBody.clientHeight;
- body.style.overflow = 'scroll';
- w -= body.clientWidth;
- h -= body.clientHeight;
+ X_elmBody.style.overflow = 'scroll';
+ w -= X_elmBody.clientWidth;
+ h -= X_elmBody.clientHeight;
- if( !w ) w = body.offsetWidth - body.clientWidth;
- if( !h ) h = body.offsetHeight - body.clientHeight;
- body.style.overflow = defaultOverflow;
+ if( !w ) w = X_elmBody.offsetWidth - X_elmBody.clientWidth;
+ if( !h ) h = X_elmBody.offsetHeight - X_elmBody.clientHeight;
+ X_elmBody.style.overflow = defaultOverflow;
X_ViewPort_vScrollbarSize = w;
X_ViewPort_hScrollbarSize = h;
@@ -520,11 +515,11 @@ X[ 'ViewPort' ] = {
//
if( X_ViewPort_orientationchange ){
- X_EventDispatcher_systemListen( X_ViewPort, 'orientationchange', X_ViewPort_orientationchange );
+ X_ViewPort[ 'listen' ]( 'orientationchange', X_ViewPort_orientationchange );
};
if( X_ViewPort_detectFontSize ){
- X_EventDispatcher_systemListen( X_ViewPort, 'resize', X_ViewPort_resize );
+ X_ViewPort[ 'listen' ]( 'resize', X_ViewPort_resize );
X_Timer_add( 333, X_ViewPort_detectFontSize );
} else {
X_Timer_add( 333, X_ViewPort_resize );
@@ -535,44 +530,37 @@ X[ 'ViewPort' ] = {
X_ViewPort[ 'asyncDispatch' ]( X_ViewPort_readyState = X_EVENT_XDOM_READY );
} );
- X_ViewPort[ 'asyncDispatch' ]( X_EVENT_PRE_INIT );
+ if( X_TEMP.X_Dom_useBuilder ) X_TEMP.X_Dom_useBuilder = !!X_elmBody.children.length;
+ X_ViewPort[ 'asyncDispatch' ]( X_EVENT_PRE_INIT );
+ X_ViewPort[ 'listen' ]( [ 'beforeunload', 'unload' ] );
- X_EventDispatcher_systemListen( X_ViewPort, [ 'beforeunload', 'unload' ] );
-
-//ãã©ã¦ã¶ã®æ»ããã¿ã³ã§æ»ã£ãã¨ãã«å¼ã°ããã¤ãã³ãã¨ããã£ãã·ã¥ã¨ããããã¸ãã®ãã¨
-//http://d.hatena.ne.jp/koumiya/20080916/1221580149
-
-console.log( '------------------->' );
+ //ãã©ã¦ã¶ã®æ»ããã¿ã³ã§æ»ã£ãã¨ãã«å¼ã°ããã¤ãã³ãã¨ããã£ãã·ã¥ã¨ããããã¸ãã®ãã¨
+ //http://d.hatena.ne.jp/koumiya/20080916/1221580149
if( document[ 'webkitHidden' ] !== undefined ){
- console.log( '--> has webkitvisibilitychange' );
- X_EventDispatcher_systemListen( X_ViewPort_document, 'webkitvisibilitychange', X_ViewPort );
+ X_ViewPort_document[ 'listen' ]( '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( '!!!!!!!!!!!!!!!!' ) };
+ X_ViewPort_document[ 'listen' ]( 'visibilitychange', X_ViewPort );
} else
if( document[ 'msHidden' ] !== undefined ){
- X_EventDispatcher_systemListen( X_ViewPort_document, 'msvisibilitychange', X_ViewPort );
+ X_ViewPort_document[ 'listen' ]( 'msvisibilitychange', X_ViewPort );
} else
if( document[ 'mozHidden' ] !== undefined ){
- X_EventDispatcher_systemListen( X_ViewPort_document, 'mozvisibilitychange', X_ViewPort );
+ X_ViewPort_document[ 'listen' ]( 'mozvisibilitychange', X_ViewPort );
};
if( window[ 'onpageshow' ] !== undefined ){
- console.log( '-------------------> pageshow, pagehide' );
- X_EventDispatcher_systemListen( X_ViewPort, [ 'pageshow', 'pagehide' ] );
+ X_ViewPort[ 'listen' ]( [ 'pageshow', 'pagehide' ] );
};
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 );
+ X_ViewPort_document[ 'listen' ]( [ 'focusin', 'focusout' ], X_ViewPort );
};
- X_EventDispatcher_systemListen( X_ViewPort, [ 'focus', 'blur' ] );
+ X_ViewPort[ 'listen' ]( [ 'focus', 'blur' ] );
return X_CALLBACK_UN_LISTEN;
};
@@ -601,15 +589,15 @@ console.log( 'X.Dom dom:w3c=' + X_UA_DOM.W3C + ' ev:w3c=' + X_UA_EVENT.W3C );
if( X_UA_EVENT.W3C ){
X_ViewPort_document[ 'listenOnce' ]( 'DOMContentLoaded', X_TEMP.onDomContentLoaded );
} else
-if( 6 <= X_UA[ 'IE' ] && X[ 'inHead' ] && !X_UA[ 'ieExeComError' ] ){ // standalone ã®é¤å¤ -> && !X_UA[ 'ieExeComError' ]
+if( 6 <= X_UA[ 'IE' ] && X[ 'inHead' ] /* && !X_UA[ 'ieExeComError' ] */ ){ // standalone ã®é¤å¤ -> && !X_UA[ 'ieExeComError' ]
// if this script in Head
//document.write( '' );
//X_TEMP._script = document.getElementById( '__ieonload' );
// ä¸ã®ã³ã¼ãã¯ã¹ã¿ã³ãã¢ãã¼ã³çie6ã§ã¨ã©ã¼
- X_TEMP._script = document.createElement( '' ) ;
- document.getElementsByTagName( 'head' )[ 0 ].appendChild( X_TEMP._script );
-
+ X_TEMP._script = document.createElement( '' );
+ X_elmHead.appendChild( X_TEMP._script );
+
X_TEMP._script.onreadystatechange = function(){
var s = X_TEMP._script;
if( s && s.readyState === 'complete' ){