X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F21_XViewPort.js;h=c83d9deee88d6c278fff586d6881f1b4c20f1497;hb=34431df46635079c1ce6626c9caf1456f88e91bd;hp=7c29e7d60ef85b247492820d107c6c795c026d6a;hpb=ada5c01a35945aced14a0f6b159035cf76668670;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..c83d9de 100644 --- a/0.6.x/js/01_core/21_XViewPort.js +++ b/0.6.x/js/01_core/21_XViewPort.js @@ -256,8 +256,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 へ /** @@ -273,7 +273,7 @@ X[ 'ViewPort' ] = { /*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 +299,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 +415,7 @@ X[ 'ViewPort' ] = { }; X_TEMP.onDomContentLoaded = function(){ - var s, size, elmHtml, elmHead, elmBody, html, head, body; + var s, size, html, head, body; console.log( '> X_TEMP.onDomContentLoaded rs:' + X_ViewPort_readyState ); @@ -425,25 +425,17 @@ 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 ) * @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 ); html[ '_flags' ] |= X_NodeFlags_IN_TREE; /** @@ -451,14 +443,14 @@ X[ 'ViewPort' ] = { * @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 ) * @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 +458,13 @@ 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; + if( X_TEMP.X_Dom_useBuilder ) X_TEMP.X_Dom_useBuilder = !!X_elmBody.children.length; !X_TEMP.X_Dom_useBuilder && X_ViewPort[ 'asyncDispatch' ]( X_EVENT_XTREE_READY ); } ); @@ -492,24 +484,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; @@ -607,9 +598,9 @@ if( 6 <= X_UA[ 'IE' ] && X[ 'inHead' ] && !X_UA[ 'ieExeComError' ] ){ // standal //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' ){