From 36e3d975f201a804af90f1a21ff352d14a438f6c Mon Sep 17 00:00:00 2001 From: itozyun Date: Wed, 8 Oct 2014 21:31:07 +0900 Subject: [PATCH] Version 0.6.95, fix X.Timer, fix xhr @opera11-, fix for touch device. --- 0.6.x/js/01_core/00_builtin.js | 3 + 0.6.x/js/01_core/01_X.js | 3 - 0.6.x/js/01_core/06_XURL.js | 31 ++- 0.6.x/js/01_core/10_XCallback.js | 2 +- 0.6.x/js/01_core/12_XEvent.js | 32 ++- 0.6.x/js/01_core/13_XEventDispatcher.js | 183 ++++++------- 0.6.x/js/01_core/14_XTimer.js | 80 +++--- 0.6.x/js/02_dom/00_XDom.js | 413 +++++++++++++++--------------- 0.6.x/js/02_dom/02_XDomNode.js | 320 +++++++++++------------ 0.6.x/js/02_dom/03_XDomEvent.js | 60 ++--- 0.6.x/js/02_dom/04_XDomBoxModel.js | 24 +- 0.6.x/js/02_dom/05_XDomAttr.js | 20 +- 0.6.x/js/02_dom/06_XDomStyle.js | 40 +-- 0.6.x/js/02_dom/07_XDomNodeList.js | 2 +- 0.6.x/js/02_dom/08_XDomSelector.js | 8 +- 0.6.x/js/02_dom/09_XDomParser.js | 16 +- 0.6.x/js/02_dom/22_XDomBuilder.js | 12 +- 0.6.x/js/03_plugin/00_XPlugin.js | 5 +- 0.6.x/js/04_util/01_XNinjaIframe.js | 2 +- 0.6.x/js/05_net/00_XNet.js | 1 + 0.6.x/js/06_audio/00_XAudio.js | 2 +- 0.6.x/js/06_audio/02_XSilverlightAudio.js | 4 +- 0.6.x/js/20_ui/15_ScrollBox.js | 10 +- 0.6.x/js/20_ui/20_PageRoot.js | 14 +- 24 files changed, 670 insertions(+), 617 deletions(-) diff --git a/0.6.x/js/01_core/00_builtin.js b/0.6.x/js/01_core/00_builtin.js index 767914f..d98e43a 100644 --- a/0.6.x/js/01_core/00_builtin.js +++ b/0.6.x/js/01_core/00_builtin.js @@ -229,6 +229,9 @@ if (window.ActiveXObject ? !Number.prototype.toFixed : (!navigator.taintEnabled * web.paulownia.jp - JavaScriptとクロージャ * https://web.archive.org/web/20070526063400/http://web.paulownia.jp/script/oop/closure.html * MacOSX 10.3のsafariにはhasOwnPropertyが実装されていないので、独自に追加する必要があります。 + * + * prototype汚染問題でhasOwnPropertyを使わないクロスブラウザな方法 + * http://os0x.hatenablog.com/entry/20080901/1220272509 */ /* Object.prototype.hasOwnProperty || (Object.prototype.hasOwnProperty = function( p ){ diff --git a/0.6.x/js/01_core/01_X.js b/0.6.x/js/01_core/01_X.js index 9706243..49c8ed5 100644 --- a/0.6.x/js/01_core/01_X.js +++ b/0.6.x/js/01_core/01_X.js @@ -15,9 +15,6 @@ var undefined, X.VERSION = '0.6.89'; X.bootTime = + new Date; - -X.getTime = Date.now ? Date.now : new Function( 'return +new Date' ); - X.emptyFunction = new Function; diff --git a/0.6.x/js/01_core/06_XURL.js b/0.6.x/js/01_core/06_XURL.js index 96be643..6973201 100644 --- a/0.6.x/js/01_core/06_XURL.js +++ b/0.6.x/js/01_core/06_XURL.js @@ -1,33 +1,42 @@ +// ------------------------------------------------------------------------- // +// ------------ local variables -------------------------------------------- // +// ------------------------------------------------------------------------- // var X_URL_BASE_URL = ( function( parts ){ var last = 1 < parts.length && parts[ parts.length - 1 ]; if( last !== false && ( last === '' || //末尾が/で終わるとき - last.indexOf( '.' ) !== -1 ) ){//末尾がファイル名で終わる時 - + last.indexOf( '.' ) !== -1 ) ){ //末尾がファイル名で終わる時 --parts.length; }; return parts.join( '/' ); })( location.href.split( '?' )[ 0 ].split( '#' )[ 0 ].split( '/' ) ), - X_URL_IS_LOCAL = location.protocol === 'file:' || location.hostname === 'localhost' || location.hostname === '127.0.0.1'; - + X_URL_IS_FILE = location.protocol === 'file:', + + X_URL_IS_LOCAL = X_URL_IS_FILE || location.hostname === 'localhost' || location.hostname === '127.0.0.1'; +// ------------------------------------------------------------------------- // +// --- interface ----------------------------------------------------------- // +// ------------------------------------------------------------------------- // X.URL = { BASE_URL : X_URL_BASE_URL, + IS_FILE : X_URL_IS_FILE, + IS_LOCAL : X_URL_IS_LOCAL, toAbsolutePath : X_URL_toAbsolutePath }; - - - /* - * original - * AS3で相対パスを絶対パスに変換する - * http://www.shin-go.net/motionlab/?p=449 - */ +// ------------------------------------------------------------------------- // +// --- implements ---------------------------------------------------------- // +// ------------------------------------------------------------------------- // +/* + * original + * AS3で相対パスを絶対パスに変換する + * http://www.shin-go.net/motionlab/?p=449 + */ function X_URL_toAbsolutePath( path ){ var s = '/', ss = '//', diff --git a/0.6.x/js/01_core/10_XCallback.js b/0.6.x/js/01_core/10_XCallback.js index 4fb5aaa..a57ce6c 100644 --- a/0.6.x/js/01_core/10_XCallback.js +++ b/0.6.x/js/01_core/10_XCallback.js @@ -10,7 +10,7 @@ var X_Callback_LIVE_LIST = [], X_Callback_THIS_FUNC = 1, X_Callback_HANDLEEVENT = 2, - X_Callback_FUNC_ONLY = 3; + X_Callback_FUNC_ONLY = 3, X_Callback_NONE = 0, X_Callback_UN_LISTEN = 1, diff --git a/0.6.x/js/01_core/12_XEvent.js b/0.6.x/js/01_core/12_XEvent.js index 87f02e7..2474315 100644 --- a/0.6.x/js/01_core/12_XEvent.js +++ b/0.6.x/js/01_core/12_XEvent.js @@ -1,14 +1,22 @@ + +X_TEMP.SYSTEM_EVENT_PRE_INIT = 1; +X_TEMP.SYSTEM_EVENT_XTREE = 2; +X_TEMP.SYSTEM_EVENT_INIT = 3; + X.Event = { - COMPLETE : 1, - READY : 2, - SUCCESS : 3, - ERROR : 4, - PROGRESS : 5, - BEFORE_CANCEL : 6, - CANCELED : 7, - TIMEOUT : 8, - BEFORE_KILL_INSTANCE : 9, - KILL_INSTANCE : 10, - KILL_INSTANCE_CANCELED : 11, - _LAST_EVENT : 11 + XDOM_READY : 4, + + COMPLETE : 5, + READY : 6, + SUCCESS : 7, + ERROR : 8, + PROGRESS : 9, + BEFORE_CANCEL : 10, + CANCELED : 11, + TIMEOUT : 12, + BEFORE_KILL_INSTANCE : 13, + KILL_INSTANCE_CANCELED : 14, + KILL_INSTANCE : 15, + + _LAST_EVENT : 15 }; \ No newline at end of file diff --git a/0.6.x/js/01_core/13_XEventDispatcher.js b/0.6.x/js/01_core/13_XEventDispatcher.js index 970b3f6..0dab627 100644 --- a/0.6.x/js/01_core/13_XEventDispatcher.js +++ b/0.6.x/js/01_core/13_XEventDispatcher.js @@ -444,19 +444,23 @@ var X_EventDispatcher_actualAddEvent = for( i = type.length; i; ){ X_EventDispatcher_actualAddEvent( that, type[ --i ], raw, list ); }; - } else { + } else + if( that._isXHR && X.UA.Opera < 12 ){ + // Opera11- の XHR は event オブジェクトが返らないため, eventType 毎に callback を指定する addEventListener もない + raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] ); + } else + if( that._isSilverlight ){ + list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); + list.sltoken = raw.AddEventListener( type, list.slcallback ); + } else { that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) ); - - if( that._isSilverlight ){ - list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); - list.sltoken = raw.AddEventListener( type, list.slcallback ); - } else + if( raw.addEventListener ){ raw.addEventListener( type, that._handleEvent, false ); } else { // Safari は Image, Opera7 は window raw[ 'on' + type ] = that._handleEvent; - }; + }; }; }) : X_UA_EVENT.IE ? @@ -465,29 +469,29 @@ var X_EventDispatcher_actualAddEvent = //if( type === 'load' && that._tag && X.Dom.Event._LOAD_FIX_TAGS[ that._tag ] ){ // type = 'readystatechange'; //}; + + type = X.Dom.Event.Rename[ type ] || type; + + if( X.Type.isArray( type ) ){ + for( i = type.length; i; ){ + X_EventDispatcher_actualAddEvent( that, type[ --i ], raw, list ); + }; + } else if( that._isXHR ){ // ie8- の XHR は window.event が更新されないため, eventType 毎に callback を指定する raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] ); - } else { - type = X.Dom.Event.Rename[ type ] || type; + } else + if( that._isSilverlight ){ + list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); + list.sltoken = raw.AddEventListener( type, list.slcallback ); + } else { + that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) ); - if( X.Type.isArray( type ) ){ - for( i = type.length; i; ){ - X_EventDispatcher_actualAddEvent( that, type[ --i ], raw, list ); - }; - } else{ - that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) ); - - if( that._isSilverlight ){ - list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); - list.sltoken = raw.AddEventListener( type, list.slcallback ); - } else - if( raw.attachEvent ){ - raw.attachEvent( 'on' + type, that._handleEvent ); - } else { - raw[ 'on' + type ] = that._handleEvent; - }; - }; + if( raw.attachEvent ){ + raw.attachEvent( 'on' + type, that._handleEvent ); + } else { + raw[ 'on' + type ] = that._handleEvent; + }; }; }) : (function( that, type, raw, list ){ @@ -498,15 +502,16 @@ var X_EventDispatcher_actualAddEvent = for( i = type.length; i; ){ X_EventDispatcher_actualAddEvent( that, type[ --i ], raw, list ); }; + } else + if( that._isXHR ){ + // ie4 mobile は XHR をサポート! + raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] ); + } else + if( that._isSilverlight ){ + list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); + list.sltoken = raw.AddEventListener( type, list.slcallback ); } else { - that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) ); - - if( that._isSilverlight ){ - list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); - list.sltoken = raw.AddEventListener( type, list.slcallback ); - } else { - raw[ 'on' + type ] = that._handleEvent; - }; + raw[ 'on' + type ] = that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) ); }; }); @@ -521,29 +526,32 @@ function X_EventDispatcher_sliverLightDispatch( sender, e, type ){ var X_EventDispatcher_actualRemoveEvent = X_UA_EVENT.W3C /*&& ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 )*/ ? // Safari3- (function( that, type, raw, list, skip ){ + var i; type = X.Dom.Event.Rename[ type ] || type; if( X.Type.isArray( type ) ){ for( i = type.length; i; ){ X_EventDispatcher_actualRemoveEvent( that, type[ --i ], raw, list, i ? true : skip ); }; + } else + if( that._isXHR && X.UA.Opera < 12 ){ + X_Callback_correct( raw[ 'on' + type ] ); + raw[ 'on' + type ] = ''; + } else + if( that._isSilverlight ){ + raw.RemoveEventListener( type, list.sltoken ); // token + X_Callback_correct( list.slcallback ); + delete list.sltoken; + delete list.slcallback; } else { - - if( that._isSilverlight ){ - raw.RemoveEventListener( type, list.sltoken ); // token - X_Callback_correct( list.slcallback ); - delete list.sltoken; - delete list.slcallback; + if( raw.addEventListener ){ + raw.removeEventListener( type, that._handleEvent, false ); } else { - if( raw.addEventListener ){ - raw.removeEventListener( type, that._handleEvent, false ); - } else { - raw[ 'on' + type ] = null; - }; - if( !skip ){ - X_Callback_correct( that._handleEvent ); - delete that._handleEvent; - }; + raw[ 'on' + type ] = null; + }; + if( !skip ){ + X_Callback_correct( that._handleEvent ); + delete that._handleEvent; }; }; }) : @@ -553,37 +561,35 @@ var X_EventDispatcher_actualRemoveEvent = //if( type === 'load' && that._tag && X.Dom.Event._LOAD_FIX_TAGS[ that._tag ] ){ // type = 'readystatechange'; //}; + + type = X.Dom.Event.Rename[ type ] || type; + + if( X.Type.isArray( type ) ){ + for( i = type.length; i; ){ + X_EventDispatcher_actualRemoveEvent( that, type[ --i ], raw, list, i ? true : skip ); + }; + } else if( that._isXHR ){ X_Callback_correct( raw[ 'on' + type ] ); raw[ 'on' + type ] = X.emptyFunction; raw[ 'on' + type ] = ''; + } else + if( that._isSilverlight ){ + raw.RemoveEventListener( type, list.sltoken ); // token + X_Callback_correct( list.slcallback ); + delete list.sltoken; + delete list.slcallback; } else { - type = X.Dom.Event.Rename[ type ] || type; - - if( X.Type.isArray( type ) ){ - for( i = type.length; i; ){ - X_EventDispatcher_actualRemoveEvent( that, type[ --i ], raw, list, i ? true : skip ); - }; + if( raw.attachEvent ){ + raw.detachEvent( 'on' + type, that._handleEvent ); } else { - - if( that._isSilverlight ){ - raw.RemoveEventListener( type, list.sltoken ); // token - X_Callback_correct( list.slcallback ); - delete list.sltoken; - delete list.slcallback; - } else { - if( raw.attachEvent ){ - raw.detachEvent( 'on' + type, that._handleEvent ); - } else { - raw[ 'on' + type ] = X.emptyFunction; - raw[ 'on' + type ] = ''; - }; - - if( !skip ){ - X_Callback_correct( that._handleEvent ); - delete that._handleEvent; - }; - }; + raw[ 'on' + type ] = X.emptyFunction; + raw[ 'on' + type ] = ''; + }; + + if( !skip ){ + X_Callback_correct( that._handleEvent ); + delete that._handleEvent; }; }; }) : @@ -594,21 +600,24 @@ var X_EventDispatcher_actualRemoveEvent = for( i = type.length; i; ){ X_EventDispatcher_actualRemoveEvent( that, type[ --i ], raw, list, i ? true : skip ); }; + } else + if( that._isXHR ){ + X_Callback_correct( raw[ 'on' + type ] ); + raw[ 'on' + type ] = X.emptyFunction; + raw[ 'on' + type ] = ''; + } else + if( that._isSilverlight ){ + raw.RemoveEventListener( type, list.sltoken ); // token + X_Callback_correct( list.slcallback ); + delete list.sltoken; + delete list.slcallback; } else { + raw[ 'on' + type ] = X.emptyFunction; + raw[ 'on' + type ] = ''; - if( that._isSilverlight ){ - raw.RemoveEventListener( type, list.sltoken ); // token - X_Callback_correct( list.slcallback ); - delete list.sltoken; - delete list.slcallback; - } else { - raw[ 'on' + type ] = X.emptyFunction; - raw[ 'on' + type ] = ''; - - if( !skip ){ - X_Callback_correct( that._handleEvent ); - delete that._handleEvent; - }; + if( !skip ){ + X_Callback_correct( that._handleEvent ); + delete that._handleEvent; }; }; }); diff --git a/0.6.x/js/01_core/14_XTimer.js b/0.6.x/js/01_core/14_XTimer.js index 0725037..ca07dac 100644 --- a/0.6.x/js/01_core/14_XTimer.js +++ b/0.6.x/js/01_core/14_XTimer.js @@ -34,7 +34,9 @@ // ------------ local variables -------------------------------------------- // // ------------------------------------------------------------------------- // -var X_Timer_SET_TIMEOUT = window.setTimeout, +var X_Timer_now = Date.now || function(){ return +new Date; }, + + X_Timer_SET_TIMEOUT = window.setTimeout, X_Timer_CLEAR_TIMEOUT = window.clearTimeout, X_Timer_REQ_ANIME_FRAME = @@ -56,11 +58,12 @@ var X_Timer_SET_TIMEOUT = window.setTimeout, X_Timer_INTERVAL_TIME = 16, X_Timer_TICKET_LIST = [], X_Timer_removal = null, + X_Timer_skipUpdate = false, X_Timer_uid = 0, X_Timer_timerId = 0, - X_Timer_next = 0, - X_Timer_busyTimeout = false, - X_Timer_endTime = 0, // iOS + X_Timer_busyTimeout = false, + X_Timer_timeStamp = 0, // setTimeout に登録した時間 + X_Timer_waitTime = 0, // 待ち時間 X_Timer_REQ_FRAME_LIST = [], X_Timer_requestID = 0, @@ -71,6 +74,8 @@ var X_Timer_SET_TIMEOUT = window.setTimeout, // ------------------------------------------------------------------------- // X.Timer = { + now : X_Timer_now, + add : function( time, opt_count, args1, args2, args3 ){ var list = X_Timer_TICKET_LIST, hash, obj; @@ -112,10 +117,9 @@ X.Timer = { X_Timer_removal[ uid ] = true; } else { for( ; i; ){ - if( ( q = list[ --i ] ).uid === uid ){ list.splice( i, 1 ); - ( /* q[ INDEX_COUNT ] <= next || */ l === 1 ) && X_Timer_update(); + !X_Timer_skipUpdate && ( q.last <= X_Timer_waitTime || l === 1 ) && X_Timer_update(); break; }; }; @@ -192,26 +196,30 @@ if( X.UA.IE4 || X.UA.MacIE ){ }; function X_Timer_onTimeout(){ - var next = X_Timer_next, + var now = X_Timer_now(), + minus = ( ( now - X_Timer_timeStamp ) / X_Timer_INTERVAL_TIME | 0 ) || 1, list = X_Timer_TICKET_LIST, i = 0, l = list.length, - limit = X.getTime() + X_Timer_INTERVAL_TIME / 2, + limit = X_Timer_now() + X_Timer_INTERVAL_TIME / 2, heavy, q, f, c, r, uid; + console.log( '予定時間と発火時間の差:' + ( now - X_Timer_timeStamp - X_Timer_waitTime * X_Timer_INTERVAL_TIME ) + ' -:' + minus + ' next:' + X_Timer_waitTime ); + if( X_Timer_busyTimeout ){ - alert( 'busy!' ); + alert( 'X_Timer_busyTimeout フラグが立ったまま!エラーの可能性' ); }; X_Timer_busyTimeout = true; for( ; i < l; ++i ){ q = list[ i ]; - if( X_Timer_removal && X_Timer_removal[ q.uid ] ) continue; - if( 0 < ( q.last -= next ) ) continue; - if( heavy ){ - if( q.last <= 0 ) q.last = 1; + if( + ( X_Timer_removal && X_Timer_removal[ q.uid ] ) || // timerId は remove 登録されている + 0 < ( q.last -= minus ) || // 時間が経過していない + heavy && ( q.last = 1 ) // 時間は経過したが、ヘビーフラグが立っている + ){ continue; }; c = q.count; @@ -225,7 +233,7 @@ function X_Timer_onTimeout(){ //console.log( 'fire....' ); - if( limit <= X.getTime() ){ + if( limit <= X_Timer_now() ){ console.log( '******* heavy!' ); // 関数の実行に時間がかかる場合、次のタイミングに heavy = true; @@ -242,10 +250,13 @@ function X_Timer_onTimeout(){ }; X_Timer_timerId = 0; X_Timer_busyTimeout = false; + if( X_Timer_removal ){ + X_Timer_skipUpdate = true; for( uid in X_Timer_removal ){ - X.Timer.remove( X_Timer_removal[ uid ] ); + X.Timer.remove( uid ); }; + X_Timer_skipUpdate = false; X_Timer_removal = null; }; X_Timer_update(); @@ -265,23 +276,36 @@ function X_Timer_update(){ n = list[ i - 1 ].last; - if( n < X_Timer_next || X_Timer_timerId === 0 ){ - X_Timer_timerId && X_Timer_CLEAR_TIMEOUT( X_Timer_timerId ); - X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, X_Timer_INTERVAL_TIME * n ); - X_Timer_endTime = X.getTime() + X_Timer_INTERVAL_TIME * n; // iOS - X_Timer_next = n; + if( n < X_Timer_waitTime || X_Timer_timerId === 0 ){ + if( X_Timer_timerId ){ + X_Timer_CLEAR_TIMEOUT( X_Timer_timerId ); + n -= ( X_Timer_now() - X_Timer_timeStamp ) / X_Timer_INTERVAL_TIME | 0; + 0 <= n || ( n = 0 ); // 負の数は 0 に + }; + X_Timer_timeStamp = X_Timer_now(); + X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, X_Timer_INTERVAL_TIME * n ); + X_Timer_waitTime = n; }; }; +// 大きい -> 小さい +function X_Timer_compareQueue( a, b ){ + return a.last < b.last ? 1 : a.last === b.last ? 0 : -1; +}; + // http://havelog.ayumusato.com/develop/javascript/e528-ios6_scrolling_timer_notcall.html // iOS6 スクロール中のタイマー発火絡みのバグ備忘 if( X.UA.iOS ){ window.addEventListener( 'scroll', function(){ - var last; + var last, now; if( X_Timer_timerId ){ - window.clearTimeout( X_Timer_timerId ); - last = X_Timer_endTime - X.getTime(); + X_Timer_CLEAR_TIMEOUT( X_Timer_timerId ); + now = X_Timer_now(); + last = X_Timer_timeStamp + X_Timer_INTERVAL_TIME * X_Timer_waitTime - now; X_Timer_timerId = X_Timer_SET_TIMEOUT( X_Timer_onTimeout, 0 < last ? last : 0 ); + // 更新 + X_Timer_timeStamp = now; + X_Timer_waitTime = last / X_Timer_INTERVAL_TIME | 0; }; }); }; @@ -293,9 +317,9 @@ function X_Timer_onEnterFrame( time ){ l = list.length, i = 0, q, uid, args; - time = time || X.getTime(); + time = time || X_Timer_now(); X_Timer_busyOnFrame = true; - // console.log( X.getTime() + ' , ' + time ); + // console.log( X_Timer_now() + ' , ' + time ); for( ; i < l; ++i ){ q = list[ i ]; @@ -322,10 +346,4 @@ function X_Timer_onEnterFrame( time ){ }; }; -// 大きい -> 小さい -function X_Timer_compareQueue( a, b ){ - return a.last < b.last ? 1 : a.last === b.last ? 0 : -1; -}; - - console.log( 'X.Core.Timer' ); diff --git a/0.6.x/js/02_dom/00_XDom.js b/0.6.x/js/02_dom/00_XDom.js index 22a96cf..4590e52 100644 --- a/0.6.x/js/02_dom/00_XDom.js +++ b/0.6.x/js/02_dom/00_XDom.js @@ -1,15 +1,133 @@ +var X_Dom_readyState, + X_Dom_active = !!window.parent || !!document.activeElement, // parent は frameに読み込まれた場合のieのerror回避 + X_Dom_rootElement, + X_Dom_lock, + X_Dom_width, + X_Dom_height, + X_Dom_baseFontSize, + X_Dom_orientationFlag; + X.Dom = X.Class._override( new X.EventDispatcher(), { - readyState : -1, - active : !!window.parent || !!document.activeElement, // parent は frameに読み込まれた場合のieのerror回避 - _root : null, - _lock : false, - w : 0, - h : 0, - baseFontSize : 0, + handleEvent : function( e ){ + var href; + switch( e.type ){ + 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; + + return X.Dom.dispatch( X.Dom.Event.BEFORE_UNLOAD ); + case 'unload' : + X.Dom.dispatch( X.Dom.Event.UNLOAD ); + + Node._window.unlisten(); + Node._document.unlisten(); + Node._html._actualRemove( true ); + break; + case 'visibilitychange' : + X.Dom.dispatch( { type : ( X_Dom_active = document[ 'hidden' ] ) ? X.Dom.Event.VIEW_DEACTIVATE : X.Dom.Event.VIEW_ACTIVATE } ); + break; + case 'webkitvisibilitychange' : + X.Dom.dispatch( { type : ( X_Dom_active = document[ 'webkitHidden' ] ) ? X.Dom.Event.VIEW_DEACTIVATE : X.Dom.Event.VIEW_ACTIVATE } ); + break; + case 'pageshow' : + case 'focus' : + X_Dom_active = true; + X.Dom.dispatch( X.Dom.Event.VIEW_ACTIVATE ); + break; + case 'pagehide' : + case 'blur' : + X_Dom_active = false; + X.Dom.dispatch( X.Dom.Event.VIEW_DEACTIVATE ); + break; + }; + }, + + listen : function( type ){ + if( type <= X_Dom_readyState ){ + /* + * X.Event.XDOM_READY 以後に listen した場合の対策 + */ + X.Dom.asyncDispatch( 0, { type : type, w : X_Dom_width, h : X_Dom_height } ); + }; + return X_EventDispatcher_listen.apply( X.Dom, arguments ); + }, + + getPointerPosition : function(){ + + }, + + /* 要素が視界に入った http://remysharp.com/2009/01/26/element-in-view-event-plugin/ */ + inView : function( elm ){ + + }, + + getSize : function(){ + return [ X_Dom_width, X_Dom_height ]; + }, +//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 + + getDocumentSize : function(){ + // Opera は互換モードでは document.body.scrollHeight、標準モードでは document.documentElement.scrollHeight でページの高さが取れる。と思ってたんだけど、例外があった。 + // http://orera.g.hatena.ne.jp/edvakf/20100515/1273908051 + //http://onozaty.hatenablog.com/entry/20060803/p1 + // Safari2.0.4では標準・互換どちらも document.body + + Node._body._updateTimerID && Node._body._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]' ) + ) :*/ + return [ + X_Dom_rootElement.scrollWidth || X_Dom_rootElement.offsetWidth, + X_Dom_rootElement.scrollHeight || X_Dom_rootElement.offsetHeight + ]; + }, + + getScrollPosition : + window.pageXOffset !== undefined ? + ( function(){ + Node._body._updateTimerID && Node._body._startUpdate(); + return[ window.pageXOffset, window.pageYOffset ]; + } ) : + window.scrollLeft !== undefined ? + ( function(){ + Node._body._updateTimerID && Node._body._startUpdate(); + return[ window.scrollLeft, window.scrollTop ]; + } ) : + ( function(){ + Node._body._updateTimerID && Node._body._startUpdate(); + // body は Safari2- + return[ X_Dom_rootElement.scrollLeft || document.body.scrollLeft, X_Dom_rootElement.scrollTop || document.body.scrollTop ]; + } ), + + getScrollbarSize : function(){ + return [ X.Dom.BoxModel.vScrollbarSize, X.Dom.BoxModel.hScrollbarSize ]; + }, + + getBaseFontSize : function(){ + if( Node._body._updateTimerID ){ + Node._body._startUpdate(); + return Node._fontSizeNode._rawObject.offsetHeight; + }; + return X_Dom_baseFontSize; + } + } +); + + + + + /* ----------------------------------------------- * Resize @@ -36,84 +154,84 @@ X.Dom = X.Class._override( * * getBoundingClientRect で fontsize の調査 */ - _resize : + var X_Dom_resize = // iOS もループで回す,,,iOS3.1.3, iOS6 で確認 X.UA.IE < 9 || X.UA.iOS ? (function(){ var size; - if( !X.Dom._lock ){ - size = X.Dom._getSize(); - if( X.Dom.w !== size[ 0 ] || X.Dom.h !== size[ 1 ] ){ - X.Dom.w = size[ 0 ]; - X.Dom.h = size[ 1 ]; - X.Timer.once( 100, X.Dom._detectFinishResizing ); - X.Dom._lock = true; + if( !X_Dom_lock ){ + size = X_Dom_getWindowSize(); + if( X_Dom_width !== size[ 0 ] || X_Dom_height !== size[ 1 ] ){ + X_Dom_width = size[ 0 ]; + X_Dom_height = size[ 1 ]; + X.Timer.once( 100, X_Dom_detectFinishResizing ); + X_Dom_lock = true; }; }; size = Node._fontSizeNode._rawObject.offsetHeight; - if( X.Dom.baseFontSize !== size ){ - X.Dom.baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X.Dom.w, h : X.Dom.h } ); - X.Dom.baseFontSize = size; + if( X_Dom_baseFontSize !== size ){ + X_Dom_baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); + X_Dom_baseFontSize = size; }; }) : (function( e ){ - console.log( '-- resize : ' + X.getTime() ); + console.log( '-- resize : ' + X_Timer_now() ); - !X.Dom._lock && ( X.Dom._lock = true ) && X.Timer.once( 100, X.Dom._detectFinishResizing ); + !X_Dom_lock && ( X_Dom_lock = true ) && X.Timer.once( 100, X_Dom_detectFinishResizing ); return X.Callback.PREVENT_DEFAULT | X.Callback.STOP_PROPAGATION; - }), + }); - _detectFinishResizing : function (){ - var size = X.Dom._getSize(); - if( X.Dom.w !== size[ 0 ] || X.Dom.h !== size[ 1 ] ){ - X.Dom.w = size[ 0 ]; - X.Dom.h = size[ 1 ]; - X.Timer.once( 100, X.Dom._detectFinishResizing ); + function X_Dom_detectFinishResizing(){ + var size = X_Dom_getWindowSize(); + if( X_Dom_width !== size[ 0 ] || X_Dom_height !== size[ 1 ] ){ + X_Dom_width = size[ 0 ]; + X_Dom_height = size[ 1 ]; + X.Timer.once( 100, X_Dom_detectFinishResizing ); } else { - console.log( '-- detectFinishResizing : ' + X.getTime() ); + console.log( '-- detectFinishResizing : ' + X_Timer_now() ); - X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, w : X.Dom.w, h : X.Dom.h } ); - X.Dom._lock = false; - if( X.Dom._orientationFlag ){ - X.Dom._orientationFlag = false; + X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); + X_Dom_lock = false; + if( X_Dom_orientationFlag ){ + X_Dom_orientationFlag = false; X.Dom.asyncDispatch( 100, { type : X.Dom.Event.VIEW_TURNED, orientation : window.orientation } ); }; }; - }, + }; - _init : function(){ - var s, size, html, head, body; - if( X.Dom.Event.DOM_PRE_INIT <= X.Dom.readyState ) return X_Callback_UN_LISTEN; + X_TEMP.onDomContentLoaded = function(){ + var s, size, elmHtml, elmHead, elmBody, html, head, body; - console.log( 'X.Dom._init()' ); + if( X_TEMP.SYSTEM_EVENT_PRE_INIT <= X_Dom_readyState ) return X_Callback_UN_LISTEN; + X_Dom_readyState = X_TEMP.SYSTEM_EVENT_PRE_INIT; - delete X.Dom._init; - // DOMContentLoaded の無いブラウザで X.Dom._init への参照が残り続けるのを回避 - Node._document.unlisten( 'DOMContentLoaded', X.Dom._init ); + // DOMContentLoaded の無いブラウザで X_TEMP.onDomContentLoaded への参照が残り続けるのを回避 + Node._document.unlisten( 'DOMContentLoaded', X_TEMP.onDomContentLoaded ); + delete X_TEMP.onDomContentLoaded; - X.Dom.readyState = X.Dom.Event.DOM_PRE_INIT; + elmHtml = document.documentElement || + X_UA_DOM.W3C ? document.getElementsByTagName( 'html' )[ 0 ] : + X_UA_DOM.IE4 ? document.all.tags( 'html' )[ 0 ] : null; - X.Dom._root = document.compatMode !== 'CSS1Compat' ? document.body : document.documentElement || document.body; + elmHead = + X_UA_DOM.W3C ? document.getElementsByTagName( 'head' )[ 0 ] : + X_UA_DOM.IE4 ? document.all.tags( 'head' )[ 0 ] : null; + + elmBody = document.body; - html = Node._html = - document.documentElement ? - new Node( document.documentElement ) : - X_UA_DOM.W3C ? - new Node( document.getElementsByTagName( 'html' )[ 0 ] ) : - X_UA_DOM.IE4 ? - new Node( document.all.tags( 'html' )[ 0 ] ) : - null; + X_Dom_rootElement = document.compatMode !== 'CSS1Compat' ? elmBody : elmHtml || elmBody; + + html = Node._html = elmHtml && new Node( elmHtml ); - head = Node._head = - X_UA_DOM.W3C ? - new Node( document.getElementsByTagName( 'head' )[ 0 ] ) : - X_UA_DOM.IE4 ? - new Node( document.all.tags( 'head' )[ 0 ] ) : - null; + head = Node._head = elmHead && new Node( elmHead ); - body = Node._body = new Node( document.body ); + body = Node._body = new Node( elmBody ); + + body._root = html._root = head._root = body;// _root は html だろ + body.parent = head.parent = html; + html._xnodes = [ head, body ]; Node.root = body; // 後方互換 @@ -122,48 +240,44 @@ X.Dom = X.Class._override( head.appendTo = head.appendToRoot = head.before = head.after = head.clone = head.remove = head.destroy = head.prevNode = head.nextNode = head.empty = head.html = head.text = body.appendTo = body.appendToRoot = body.before = body.after = body.clone = body.remove = body.destroy = body.prevNode = body.nextNode = new Function( 'return this' ); - - body._root = html._root = head._root = body; - body.parent = head.parent = html; - html._xnodes = [ head, body ]; - X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){ - X.Dom.readyState = X.Dom.Event.DOM_BUILDER_COMPLETE; - !X_TEMP.X_Dom_useBuilder && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_BUILDER_COMPLETE } ); + X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, function(){ + X_Dom_readyState = X_TEMP.SYSTEM_EVENT_XTREE; + !X_TEMP.X_Dom_useBuilder && X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_XTREE ); } ); - X.Dom.listenOnce( X.Dom.Event.DOM_BUILDER_COMPLETE, function(){ - X.Dom.readyState = X.Dom.Event.DOM_INIT; + X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_XTREE, function(){ + X_Dom_readyState = X_TEMP.SYSTEM_EVENT_INIT; //X.UA.Opera7 && alert( 'bc' ); Node._body.appendAt( 0, Node._systemNode = Node.create( 'div', { 'class' : 'hidden-system-node' } ), Node._fontSizeNode = Node.create( 'div', { 'class' : 'hidden-system-node' } ).cssText( 'line-height:1;height:1em;' ).text( 'X' ) )._startUpdate(); - X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_INIT } ); + X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_INIT ); } ); - X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){ - var size = X.Dom._getSize(); + X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ + var size = X_Dom_getWindowSize(); - if( X.Dom._orientationchange ){ - X.Dom.Node._window.listen( 'orientationchange', X.Dom._orientationchange ); + if( X_Dom_orientationchange ){ + X.Dom.Node._window.listen( 'orientationchange', X_Dom_orientationchange ); }; - if( X.Dom._detectFontSize ){ - X.Dom.Node._window.listen( 'resize', X.Dom._resize ); - X.Timer.add( 333, X.Dom._detectFontSize ); + if( X_Dom_detectFontSize ){ + X.Dom.Node._window.listen( 'resize', X_Dom_resize ); + X.Timer.add( 333, X_Dom_detectFontSize ); } else { - X.Timer.add( 333, X.Dom._resize ); + X.Timer.add( 333, X_Dom_resize ); }; - X.Dom.baseFontSize = Node._fontSizeNode._rawObject.offsetHeight; + X_Dom_baseFontSize = Node._fontSizeNode._rawObject.offsetHeight; - X.Dom.readyState = X.Dom.Event.XDOM_READY; - X.Dom.asyncDispatch( 0, { type : X.Dom.Event.XDOM_READY, w : X.Dom.w = size[ 0 ], h : X.Dom.h = size[ 1 ] } ); + X_Dom_readyState = X.Event.XDOM_READY; + X.Dom.asyncDispatch( 0, { type : X.Event.XDOM_READY, w : X_Dom_width = size[ 0 ], h : X_Dom_height = size[ 1 ] } ); } ); - X.Dom.asyncDispatch( 0, { type : X.Dom.Event.DOM_PRE_INIT } ); + X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_PRE_INIT ); Node._window .listen( 'beforeunload', X.Dom ) @@ -187,141 +301,32 @@ X.Dom = X.Class._override( }; return X_Callback_UN_LISTEN; - }, - - handleEvent : function( e ){ - var href; - switch( e.type ){ - 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; - - return X.Dom.dispatch( { type : X.Dom.Event.BEFORE_UNLOAD } ); - case 'unload' : - X.Dom.dispatch( { type : X.Dom.Event.UNLOAD } ); - - Node._window.unlisten(); - Node._document.unlisten(); - Node._html._actualRemove( true ); - break; - case 'visibilitychange' : - X.Dom.dispatch( { type : ( X.Dom.activate = document[ 'hidden' ] ) ? X.Dom.Event.VIEW_DEACTIVATE : X.Dom.Event.VIEW_ACTIVATE } ); - break; - case 'webkitvisibilitychange' : - X.Dom.dispatch( { type : ( X.Dom.activate = document[ 'webkitHidden' ] ) ? X.Dom.Event.VIEW_DEACTIVATE : X.Dom.Event.VIEW_ACTIVATE } ); - break; - case 'pageshow' : - case 'focus' : - X.Dom.activate = true; - X.Dom.dispatch( { type : X.Dom.Event.VIEW_ACTIVATE } ); - break; - case 'pagehide' : - case 'blur' : - X.Dom.activate = false; - X.Dom.dispatch( { type : X.Dom.Event.VIEW_DEACTIVATE } ); - break; - }; - }, - - listen : function( type ){ - if( type <= X.Dom.readyState ){ - /* - * X.Dom.Event.XDOM_READY 以後に listen した場合の対策 - */ - X.Dom.asyncDispatch( 0, { type : type, w : X.Dom.w, h : X.Dom.h } ); - }; - return X_EventDispatcher_listen.apply( X.Dom, arguments ); - }, - - getPointerPosition : function(){ - - }, - - /* 要素が視界に入った http://remysharp.com/2009/01/26/element-in-view-event-plugin/ */ - inView : function( elm ){ - - }, + }; - _getSize : - X.UA.IE ? - new Function( 'return[X.Dom._root.clientWidth,X.Dom._root.clientHeight]' ) : - new Function( 'return[window.innerWidth,window.innerHeight]' ), - - getSize : function(){ - return [ X.Dom.w, X.Dom.h ]; - }, -//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 - - getDocumentSize : function(){ - // Opera は互換モードでは document.body.scrollHeight、標準モードでは document.documentElement.scrollHeight でページの高さが取れる。と思ってたんだけど、例外があった。 - // http://orera.g.hatena.ne.jp/edvakf/20100515/1273908051 - //http://onozaty.hatenablog.com/entry/20060803/p1 - // Safari2.0.4では標準・互換どちらも document.body - - Node._body._updateTimerID && Node._body._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]' ) - ) :*/ - return [ - X.Dom._root.scrollWidth || X.Dom._root.offsetWidth, - X.Dom._root.scrollHeight || X.Dom._root.offsetHeight - ]; - }, - - getScrollPosition : - window.pageXOffset !== undefined ? - ( function(){ - Node._body._updateTimerID && Node._body._startUpdate(); - return[ window.pageXOffset, window.pageYOffset ]; - } ) : - window.scrollLeft !== undefined ? - ( function(){ - Node._body._updateTimerID && Node._body._startUpdate(); - return[ window.scrollLeft, window.scrollTop ]; - } ) : - ( function(){ - Node._body._updateTimerID && Node._body._startUpdate(); - // body は Safari2- - return[ X.Dom._root.scrollLeft || document.body.scrollLeft, X.Dom._root.scrollTop || document.body.scrollTop ]; - } ), + function X_Dom_getWindowSize(){ + return X.UA.IE ? + [ X_Dom_rootElement.clientWidth, X_Dom_rootElement.clientHeight ] : + [ window.innerWidth, window.innerHeight ]; + }; - getScrollbarSize : function(){ - return [ X.Dom.BoxModel.vScrollbarSize, X.Dom.BoxModel.hScrollbarSize ]; - }, - - getBaseFontSize : function(){ - if( Node._body._updateTimerID ){ - Node._body._startUpdate(); - return Node._fontSizeNode._rawObject.offsetHeight; - }; - return X.Dom.baseFontSize; - } - } -); if( !( X.UA.IE < 9 || X.UA.iOS ) ){ - X.Dom._detectFontSize = function(){ + var X_Dom_detectFontSize = function(){ var size = Node._fontSizeNode._rawObject.offsetHeight; - if( X.Dom.baseFontSize !== size ){ - X.Dom.baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X.Dom.w, h : X.Dom.h } ); - X.Dom.baseFontSize = size; + if( X_Dom_baseFontSize !== size ){ + X_Dom_baseFontSize && X.Dom.asyncDispatch( 0, { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); + X_Dom_baseFontSize = size; }; }; }; if( window[ 'orientation' ] !== undefined ){ - X.Dom._orientationchange = function( e ){ - X.Dom._orientationFlag = true; - !X.UA.Android && X.Dom._resize(); - console.log( '-- orientationchange : ' + X.Dom.getSize[ 0 ] + ' ' + X.Dom.getSize[ 1 ] ); - }; + var X_Dom_orientationchange = function( e ){ + X_Dom_orientationFlag = true; + !X.UA.Android && X_Dom_resize(); + //console.log( '-- orientationchange : ' + X.Dom.getSize[ 0 ] + ' ' + X.Dom.getSize[ 1 ] ); + }, + X_Dom_orientationFlag; }; console.log( 'X.Dom dom:w3c=' + X_UA_DOM.W3C + ' ev:w3c=' + X_UA_EVENT.W3C ); diff --git a/0.6.x/js/02_dom/02_XDomNode.js b/0.6.x/js/02_dom/02_XDomNode.js index ecacc7a..71caaa2 100644 --- a/0.6.x/js/02_dom/02_XDomNode.js +++ b/0.6.x/js/02_dom/02_XDomNode.js @@ -1,42 +1,55 @@ -X.Dom.Dirty = { - CLEAN : 0, - CHILD_IS_DIRTY : 1, - ID : 2, // width, height, x, y - CONTENT : 4, // width, height, x, y textNode の内容 - CLASSNAME : 8, // _getCharSize, width, height, x, y - ATTR : 16, // _getCharSize, width, height, x, y - CSS : 32, // _getCharSize, width, height, x, y - IE_FILTER : X.UA.IE < 9 && !X.UA.MacIE ? 64 : 0, - UNKNOWN_TAG_FIX : 128, - IE4_TEXTNODE_FIX : 256 -}; - -X.Dom.State = { - DESTROYED : 0, - EXIST : 1, - BELONG_TREE : 2, - DISPLAY_NONE : 4, - DISPLAY_BLOCK : 8, - DISPLAY_INLINE : 16, - POSITION_ABSOLUTE : 32, - OVERFLOW_HIDDEN : 64, - HAS_WIDTH_LENGTH : 128, - HAS_WIDTH_PERCENT : 256, - HAS_HEIGHT_LENGTH : 512, - HAS_HEIGHT_PERCENT : 1024, - IE4_ONLY_TEXT : 2048, - IE5_DISPLAY_NONE_FIX : !X.UA.MacIE && X.UA.IE5 ? 4096 : 0 // filterがかかっていると不可? MacIE5.2- は ? -}; - -X.Dom._strictElmCreation = !X.UA.MacIE && X.UA.IE5678;// && !X.UA.MacIE; - -X.Dom._useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 5.5 <= X.UA.IE ) && document.createDocumentFragment(); +var + X_Node_Dirty = { + CLEAN : 0, + CHILD_IS_DIRTY : 1, + ID : 2, // width, height, x, y + CONTENT : 4, // width, height, x, y textNode の内容 + CLASSNAME : 8, // _getCharSize, width, height, x, y + ATTR : 16, // _getCharSize, width, height, x, y + CSS : 32, // _getCharSize, width, height, x, y + IE_FILTER : X.UA.IE < 9 && !X.UA.MacIE ? 64 : 0, + UNKNOWN_TAG_FIX : 128, + IE4_TEXTNODE_FIX : 256 + }, + + X_Node_State = { + DESTROYED : 0, + EXIST : 1, + BELONG_TREE : 2, + DISPLAY_NONE : 4, + DISPLAY_BLOCK : 8, + DISPLAY_INLINE : 16, + POSITION_ABSOLUTE : 32, + OVERFLOW_HIDDEN : 64, + HAS_WIDTH_LENGTH : 128, + HAS_WIDTH_PERCENT : 256, + HAS_HEIGHT_LENGTH : 512, + HAS_HEIGHT_PERCENT : 1024, + IE4_ONLY_TEXT : 2048, + IE5_DISPLAY_NONE_FIX : !X.UA.MacIE && X.UA.IE5 ? 4096 : 0 // filterがかかっていると不可? MacIE5.2- は ? + }, + + X_Node_TYPE = { + XNODE : 1, + RAW_HTML : 2, + RAW_TEXT : 3, + HTML_STRING : 4, + STRING : 5, + //DOC_FRAG : 6, + XNODE_LIST : 7, + WINDOW : 8, + DOCUMENT : 9, + IMAGE : 10 + }, + + X_Node_strictElmCreation = !X.UA.MacIE && X.UA.IE5678,// && !X.UA.MacIE; + + X_Node_useDocumentFragment = document.createDocumentFragment && ( !X.UA.IE || 5.5 <= X.UA.IE ) && document.createDocumentFragment(), /* * Node( rawElement | rawTextnode | htmlString | textString ) - */ - -X.Dom.Node = X.EventDispatcher.inherits( + */ + Node = X.Dom.Node = X.EventDispatcher.inherits( 'XDomNode', X.Class.POOL_OBJECT, { @@ -44,7 +57,7 @@ X.Dom.Node = X.EventDispatcher.inherits( _state : 0, _dirty : 0, - _isNew : false, + _isNew : false, // state にまとめる _rawObject : null, _rect : null, // @@ -59,9 +72,9 @@ X.Dom.Node = X.EventDispatcher.inherits( _id : null, _className : '', - _attrs : null, // X.Dom.Attr + _attrs : null, // X_Node_Attr _newAttrs : null, - _attrText : '', // X.Dom.Attr.objToAttrText が必要な場合は false が入っている + _attrText : '', // X_Node_Attr.objToAttrText が必要な場合は false が入っている _css : null, // X.Dom.Style _cssText : null, @@ -80,7 +93,7 @@ X.Dom.Node = X.EventDispatcher.inherits( Node._newByTag = false; this._tag = v.toUpperCase(); this._xnodeType = 1; - this._state = X.Dom.State.DISPLAY_INLINE; // todo + this._state = X_Node_State.DISPLAY_INLINE; // todo arguments[ 1 ] && this.attr( arguments[ 1 ] ); css = arguments[ 2 ]; css && this[ X.Type.isString( css ) ? 'cssText' : 'css' ]( css ); @@ -89,32 +102,32 @@ X.Dom.Node = X.EventDispatcher.inherits( Node._newByText = false; this._text = v; this._xnodeType = 3; - this._state = X.Dom.State.DISPLAY_INLINE; + this._state = X_Node_State.DISPLAY_INLINE; } else { if( 1 < arguments.length ) return new X.Dom.NodeList( arguments ); if( X.Type.isArray( v ) && v.length ) return new X.Dom.NodeList( v ); //if( !this || this.append !== Node.prototype.append ){ // return new Node( v ); //}; - switch( Node._getType( v ) ){ - case Node.IS_XNODE : - case Node.IS_XNODE_LIST : + switch( X_Node_getType( v ) ){ + case X_Node_TYPE.XNODE : + case X_Node_TYPE.XNODE_LIST : return v; - case Node.IS_RAW_HTML : - if( xnode = Node._getXNode( v ) ) return xnode; + case X_Node_TYPE.RAW_HTML : + if( xnode = X_Node_getXNode( v ) ) return xnode; // v.parentNode || v.parentElement : dom1 || dom0 - this.parent = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && Node._getXNode( parent ); + this.parent = ( parent = v.parentNode || v.parentElement ) && parent.tagName /* ie7- */ && X_Node_getXNode( parent ); this._root = this.parent ? this.parent._root : null; this._rawObject = v; this._xnodeType = 1; - this._state = X.Dom.State.DISPLAY_BLOCK; // todo + this._state = X_Node_State.DISPLAY_BLOCK; // todo this._tag = v.tagName.toUpperCase(); this._id = v.id; this._className = v.className; this.cssText( v.style.cssText ); - // X.Dom.Dirty.CSS を落とす + // X_Node_Dirty.CSS を落とす this._dirty = 0; - // attr の回収は不可能、、、 + // TODO attr の回収は不可能、、、 if( X_UA_DOM.IE4 ){ v.setAttribute( 'UID', '' + uid ); } else { @@ -122,35 +135,35 @@ X.Dom.Node = X.EventDispatcher.inherits( }; // childNodes... break; - case Node.IS_RAW_TEXT : - if( xnode = Node._getXNode( v ) ) return xnode; - this.parent = Node._getXNode( v.parentNode ); + case X_Node_TYPE.RAW_TEXT : + if( xnode = X_Node_getXNode( v ) ) return xnode; + this.parent = X_Node_getXNode( v.parentNode ); this._root = this.parent ? this.parent._root : null; this._rawObject = v; this._xnodeType = 3; - this._state = X.Dom.State.DISPLAY_INLINE; + this._state = X_Node_State.DISPLAY_INLINE; this._text = v.data; v.UID = uid; break; - case Node.IS_HTML_STRING : - case Node.IS_STRING : + case X_Node_TYPE.HTML_STRING : + case X_Node_TYPE.STRING : if( xnodes = X.Dom.parse( v, true ) && 1 < xnodes.length ) return new X.Dom.NodeList( xnodes ); if( xnodes.length ) return xnodes[ 0 ]; return Node.none; - case Node.IS_IMAGE : - if( xnode = Node._getXNode( v ) ) return xnode; + case X_Node_TYPE.IMAGE : + if( xnode = X_Node_getXNode( v ) ) return xnode; this._rawObject = v; this._xnodeType = 4; v.UID = uid; - this._state = X.Dom.State.EXIST; + this._state = X_Node_State.EXIST; break; /* - case Node.IS_WINDOW : - case Node.IS_DOCUMENT : - if( xnode = Node._getXNode( v ) ) return xnode; + case X_Node_TYPE.WINDOW : + case X_Node_TYPE.DOCUMENT : + if( xnode = X_Node_getXNode( v ) ) return xnode; this._rawObject = v; this._xnodeType = 2; - this._state = X.Dom.State.DISPLAY_BLOCK; + this._state = X_Node_State.DISPLAY_BLOCK; break; */ default : if( Node.none ) return Node.none; @@ -163,54 +176,41 @@ X.Dom.Node = X.EventDispatcher.inherits( } ); -var Node = X.Dom.Node; - -Node.IS_XNODE = 1; -Node.IS_RAW_HTML = 2; -Node.IS_RAW_TEXT = 3; -Node.IS_HTML_STRING = 4; -Node.IS_STRING = 5; -//Node.IS_DOC_FRAG = 6; -Node.IS_XNODE_LIST = 7; -Node.IS_WINDOW = 8; -Node.IS_DOCUMENT = 9; -Node.IS_IMAGE = 10; - -Node._getType = function( v ){ - if( v === '' ) return Node.IS_STRING; +function X_Node_getType( v ){ + if( v === '' ) return X_Node_TYPE.STRING; if( !v ) return 0; - if( v === window ) return Node.IS_WINDOW; - if( v === document ) return Node.IS_DOCUMENT; - if( v.constructor === Node ) return Node.IS_XNODE; - if( v.constructor === X.Dom.NodeList ) return Node.IS_XNODE_LIST; - if( X.Type.isHTMLElement( v ) ) return Node.IS_RAW_HTML; - if( v.nodeType === 3 ) return Node.IS_RAW_TEXT; - if( X.Type.isImage( v ) ) return Node.IS_IMAGE; - if( typeof v === 'string' ){ - return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? Node.IS_HTML_STRING : Node.IS_STRING; + if( v === window ) return X_Node_TYPE.WINDOW; + if( v === document ) return X_Node_TYPE.DOCUMENT; + if( v.constructor === Node ) return X_Node_TYPE.XNODE; + if( v.constructor === X.Dom.NodeList ) return X_Node_TYPE.XNODE_LIST; + if( X.Type.isHTMLElement( v ) ) return X_Node_TYPE.RAW_HTML; + if( v.nodeType === 3 ) return X_Node_TYPE.RAW_TEXT; + if( X.Type.isImage( v ) ) return X_Node_TYPE.IMAGE; + if( X.Type.isString( v ) ){ + return '<' === v.charAt( 0 ) && v.charAt( v.length - 1 ) === '>' ? X_Node_TYPE.HTML_STRING : X_Node_TYPE.STRING; }; - //if( v.nodeType === 11 ) return Node.IS_DOC_FRAG; + //if( v.nodeType === 11 ) return X_Node_TYPE.DOC_FRAG; return 0; }; -Node._getXNode = function( v ){ +function X_Node_getXNode( v ){ var uid, i, chashe, xnode; - switch( Node._getType( v ) ){ - case Node.IS_XNODE : - case Node.IS_XNODE_LIST : + switch( X_Node_getType( v ) ){ + case X_Node_TYPE.XNODE : + case X_Node_TYPE.XNODE_LIST : return v; - case Node.IS_RAW_HTML : - case Node.IS_IMAGE : + case X_Node_TYPE.RAW_HTML : + case X_Node_TYPE.IMAGE : // fake TextNode too. if( X_UA_DOM.IE4 ){ uid = v.getAttribute( 'UID' ); return uid && Node._chashe[ uid ]; }; return v.UID && Node._chashe[ v.UID ]; - case Node.IS_WINDOW : + case X_Node_TYPE.WINDOW : return Node._window; - case Node.IS_DOCUMENT : + case X_Node_TYPE.DOCUMENT : return Node._document; - case Node.IS_RAW_TEXT : + case X_Node_TYPE.RAW_TEXT : if( v.UID ) return Node._chashe[ v.UID ]; for( chashe = Node._chashe, i = chashe.length; i; ){ if( ( xnode = Node._chashe[ --i ] ) && ( xnode._rawObject === v ) ) return xnode; @@ -221,11 +221,11 @@ Node._getXNode = function( v ){ Node.create = function( tag, opt_attrs, opt_css ){ var list, i; - switch( Node._getType( tag ) ){ - case Node.IS_STRING : + switch( X_Node_getType( tag ) ){ + case X_Node_TYPE.STRING : Node._newByTag = true; return new Node( tag, opt_attrs, opt_css ); - case Node.IS_HTML_STRING : + case X_Node_TYPE.HTML_STRING : list = X.Dom.parse( tag, true ); for( i = list.length; 1 < i; ){ list[ --i ].destroy(); @@ -364,15 +364,15 @@ Node.prototype.append = function( v ){ if( !( xnodes = this._xnodes ) ) this._xnodes = xnodes = []; - switch( Node._getType( v ) ){ - case Node.IS_RAW_HTML : - case Node.IS_RAW_TEXT : + switch( X_Node_getType( v ) ){ + case X_Node_TYPE.RAW_HTML : + case X_Node_TYPE.RAW_TEXT : v = new Node( v ); break; - case Node.IS_HTML_STRING : - case Node.IS_STRING : + case X_Node_TYPE.HTML_STRING : + case X_Node_TYPE.STRING : return this.append.apply( this, X.Dom.parse( v, true ) ); - case Node.IS_XNODE : + case X_Node_TYPE.XNODE : if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this; // 親の xnodes から v を消す if( v.parent ){ @@ -424,19 +424,19 @@ Node.prototype.appendAt = function( start, v ){ return this; }; - switch( Node._getType( v ) ){ - case Node.IS_RAW_HTML : - case Node.IS_RAW_TEXT : + switch( X_Node_getType( v ) ){ + case X_Node_TYPE.RAW_HTML : + case X_Node_TYPE.RAW_TEXT : v = new Node( v ); break; - case Node.IS_HTML_STRING : - case Node.IS_STRING : + case X_Node_TYPE.HTML_STRING : + case X_Node_TYPE.STRING : v = X.Dom.parse( v, true ); for( i = v.length; i; ){ this.appendAt( start, v[ --i ] ); }; return this; - case Node.IS_XNODE : + case X_Node_TYPE.XNODE : if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this; // 親の xnodes から v を消す if( v.parent ){ @@ -465,14 +465,14 @@ Node.prototype.appendAt = function( start, v ){ }; Node.prototype.appendTo = function( parent, opt_index ){ - switch( Node._getType( parent ) ){ - case Node.IS_RAW_HTML : + switch( X_Node_getType( parent ) ){ + case X_Node_TYPE.RAW_HTML : parent = new Node( parent ); break; - case Node.IS_HTML_STRING : + case X_Node_TYPE.HTML_STRING : parent = X.Dom.parse( parent, true ); parent = parent[ 0 ] || parent; - case Node.IS_XNODE : + case X_Node_TYPE.XNODE : break; default : return this; @@ -623,7 +623,7 @@ Node.prototype.contains = function( v ){ var elm, type, xnodes, i; if( !v || this._xnodeType !== 1 ) return false; // contains ie4+ - if( ( elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = Node._getType( v ) ) && ( type === Node.IS_RAW_HTML || type === Node.IS_RAW_TEXT ) ){ + if( ( elm = this._rawObject || this._ie4getRawNode && this._ie4getRawNode() ) && document.contains && ( type = X_Node_getType( v ) ) && ( type === X_Node_TYPE.RAW_HTML || type === X_Node_TYPE.RAW_TEXT ) ){ return elm.contains( v ); }; //if( document.compareDocumentPosition ){ @@ -690,7 +690,7 @@ Node.prototype.className = function( v ){ if( this._className === v ) return this; v ? ( this._className = v ) : delete this._className; }; - this._dirty |= X.Dom.Dirty.CLASSNAME; + this._dirty |= X_Node_Dirty.CLASSNAME; this._root && this._reserveUpdate(); return this; }; @@ -774,14 +774,14 @@ Node.prototype.html = function( html ){ return this._text; }; - if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ delete this._cssText; }; html = !Node._outerFlag ? [] : [ '<', this._tag, this._id ? ' id="' + this._id + q : _, this._className ? ' class="' + this._className + q : _, - this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText, + this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, this._cssText ? ' style="' + this._cssText + q : _, '>' ]; @@ -806,7 +806,7 @@ Node.prototype.text = function( text ){ if( this._text !== text ){ text ? ( this._text = text ) : delete this.text; this._root && this._reserveUpdate(); - this._dirty |= X.Dom.Dirty.CONTENT; + this._dirty |= X_Node_Dirty.CONTENT; }; return this; }; @@ -909,7 +909,7 @@ Node.prototype._reserveUpdate = function(){ Node.prototype._startUpdate = function(){ var removal, i, xnode, tmp; - if( X.Dom.readyState < X.Dom.Event.DOM_INIT ){ + if( X_Dom_readyState < X_TEMP.SYSTEM_EVENT_INIT ){ return; }; if( this._updateTimerID ){ @@ -953,7 +953,7 @@ Node.prototype._commitUpdate = var elm = this._rawObject, xnodes, l, i, frg, next, k, v; - if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){ + if( this._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ //alert( this._tag + ' ' + !!elm ); // filter の効いている要素だけdisplay:none が無視される模様。filter を切ればよい? // 親が、display:none の場合は? @@ -971,7 +971,7 @@ Node.prototype._commitUpdate = } else if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ) { - /*if( elm.childNodes.length !== l && ( frg = X.Dom._useDocumentFragment ) ){ + /*if( elm.childNodes.length !== l && ( frg = X_Node_useDocumentFragment ) ){ for( i = 0; i < l; ++i ){ frg.appendChild( xnodes[ i ]._actualCreate( true ) ); }; @@ -988,7 +988,7 @@ Node.prototype._commitUpdate = delete this._fontSize; this._dirty && this._updateRawNode( elm ); - if( this._state & X.Dom.State.IE5_DISPLAY_NONE_FIX ){ + if( this._state & X_Node_State.IE5_DISPLAY_NONE_FIX ){ return nextElement; }; return elm; @@ -1009,7 +1009,7 @@ Node.prototype._commitUpdate = xnodes = this._xnodes; l = xnodes ? xnodes.length : 0; - if( this._dirty & X.Dom.Dirty.IE4_TEXTNODE_FIX || ( this._state & X.Dom.State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0 + if( this._dirty & X_Node_Dirty.IE4_TEXTNODE_FIX || ( this._state & X_Node_State.IE4_ONLY_TEXT && ( l !== 1 || xnodes[ 0 ]._xnodeType !== 3 ) ) ){ // 1 < l && elm.children.length === 0 html = []; for( i = 0; i < l; ++i ){ html[ i ] = xnodes[ i ]._actualCreate(); @@ -1018,9 +1018,9 @@ Node.prototype._commitUpdate = for( i = 0; i < l; ++i ){ xnodes[ i ]._afterActualCreate(); }; - this._state &= ~X.Dom.State.IE4_ONLY_TEXT; + this._state &= ~X_Node_State.IE4_ONLY_TEXT; } else - if( this._state & X.Dom.State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う + if( this._state & X_Node_State.IE4_ONLY_TEXT ){ // textNode が swap した場合の検出は、_root で行う text = xnodes[ 0 ]; if( text._dirty || !text._root ){ elm.innerHTML = text._text; @@ -1046,29 +1046,29 @@ Node.prototype._updateRawNode = var attrs, rename, k, v; // textNode - if( this._dirty & X.Dom.Dirty.CONTENT ){ + if( this._dirty & X_Node_Dirty.CONTENT ){ elm.data = X_String_chrReferanceTo( this._text ); delete this._dirty; return; }; // id - if( this._dirty & X.Dom.Dirty.ID ){ + if( this._dirty & X_Node_Dirty.ID ){ this._id ? ( elm.id = this._id ) : ( elm.id && elm.removeAttribute( 'id' ) ); }; // className - if( this._dirty & X.Dom.Dirty.CLASSNAME ){ + if( this._dirty & X_Node_Dirty.CLASSNAME ){ this._className ? ( elm.className = this._className ) : ( elm.className && elm.removeAttribute( X.UA.IE5678 ? 'className' : 'class' ) ); // className は ie7-? // ie5 only - if( X.Dom.State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){ + if( X_Node_State.IE5_DISPLAY_NONE_FIX && elm.currentStyle.display === 'none' ){ this._actualRemove(); - this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX; + this._state |= X_Node_State.IE5_DISPLAY_NONE_FIX; return; }; }; // style // TODO display:none の場合、更新をスキップ - if( this._dirty & X.Dom.Dirty.CSS ){ + if( this._dirty & X_Node_Dirty.CSS ){ if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ X.UA.Opera78 || X.UA.NN6 ? elm.setAttribute( 'style', this._cssText ) : // opera8用 @@ -1080,14 +1080,14 @@ Node.prototype._updateRawNode = }; }; - if( this._dirty & X.Dom.Dirty.IE_FILTER ){ + if( this._dirty & X_Node_Dirty.IE_FILTER ){ elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); }; // attr // TODO display:none の場合、更新をスキップ - if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ - rename = X.Dom.Attr.renameForDOM; + if( this._dirty & X_Node_Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ + rename = X_Node_Attr.renameForDOM; for( k in attrs ){ if( !X.UA.MacIE && ( X.UA.IE5 || X.UA.IE55 ) ){ // IETester 5.5 ではエラーが出なかった.MultipulIE5.5 ではエラーが出たので if( this._tag === 'TEXTAREA' && k === 'value' ){ @@ -1100,7 +1100,7 @@ Node.prototype._updateRawNode = // TODO IE では input, なぜか buttonも、type の変更が出来ない、object も 同値で置き換えようとしても不可 ( v = attrs[ k ] ) === undefined ? elm.removeAttribute( rename[ k ] || k ) : - ( elm[ rename[ k ] || k ] = X.Dom.Attr.noValue[ k ] ? k : v ); + ( elm[ rename[ k ] || k ] = X_Node_Attr.noValue[ k ] ? k : v ); }; delete this._newAttrs; @@ -1113,7 +1113,7 @@ Node.prototype._updateRawNode = var attrs, rename, k, v; // fake textNode - if( this._dirty & X.Dom.Dirty.CONTENT ){ + if( this._dirty & X_Node_Dirty.CONTENT ){ elm.innerText = this._text; delete this._dirty; return; @@ -1124,14 +1124,14 @@ Node.prototype._updateRawNode = * title、className、id、lang、language には setAttribute でなく、element.id で直接読み書きできる */ // id - if( this._dirty & X.Dom.Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) ); + if( this._dirty & X_Node_Dirty.CONTENT ) elm.setAttribute( 'id', this._id || ( 'ie4uid' + xnode._uid ) ); // className - if( this._dirty & X.Dom.Dirty.CLASSNAME ){ + if( this._dirty & X_Node_Dirty.CLASSNAME ){ this._className ? ( elm.className = this._className ) : elm.removeAttribute( 'class' ); }; // style - if( this._dirty & X.Dom.Dirty.CSS ){ + if( this._dirty & X_Node_Dirty.CSS ){ if( this._cssText !== null || ( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ elm.style.cssText = this._cssText; } else { @@ -1141,19 +1141,19 @@ Node.prototype._updateRawNode = }; }; - if( this._dirty & X.Dom.Dirty.IE_FILTER ){ + if( this._dirty & X_Node_Dirty.IE_FILTER ){ this._rawObject.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); }; // attr - if( this._dirty & X.Dom.Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ - rename = X.Dom.Attr.renameForDOM; + if( this._dirty & X_Node_Dirty.ATTR && ( attrs = this._newAttrs || this._attrs ) ){ + rename = X_Node_Attr.renameForDOM; for( k in attrs ){ ( v = attrs[ k ] ) === undefined ? elm.removeAttribute( rename[ k ] || k ) : this._tag === 'TEXTAREA' && k === 'value' ? ( elm.innerText = v ) : - elm.setAttribute( rename[ k ] || k, X.Dom.Attr.noValue[ k ] ? k : v ); // TODO X.Dom.Attr.noValue[ k ] ? k : v + elm.setAttribute( rename[ k ] || k, X_Node_Attr.noValue[ k ] ? k : v ); // TODO X_Node_Attr.noValue[ k ] ? k : v }; delete this._newAttrs; }; @@ -1191,25 +1191,25 @@ Node.prototype._actualCreate = }; if( !elm ){ - if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ delete this._cssText; }; this._isNew = true; this._rawObject = elm = - X.Dom._strictElmCreation ? + X_Node_strictElmCreation ? document.createElement( [ '<', this._tag, ' UID="', this._uid, '"', this._id ? ' id="' + this._id + '"' : '', this._className ? ' class="' + this._className + '"' : '', - this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText, + this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, this._cssText ? ' style="' + this._cssText + '"' : '', '>' ].join( '' ) ) : document.createElement( this._tag ); }; - if( X.Dom._useDocumentFragment ){ + if( X_Node_useDocumentFragment ){ if( ( xnodes = this._xnodes ) && ( l = xnodes.length ) ){ - !isChild && ( frg = X.Dom._useDocumentFragment ).appendChild( elm ); + !isChild && ( frg = X_Node_useDocumentFragment ).appendChild( elm ); for( i = 0; i < l; ++i ){ elm.appendChild( xnodes[ i ]._actualCreate( true ) ); }; @@ -1229,14 +1229,14 @@ Node.prototype._actualCreate = } else { if( this._rawObject && !isChild ) this._actualRemove( true ); - if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ delete this._cssText; }; html = [ '<', this._tag, ' id=', ( this._id || ( 'ie4uid' + uid ) ), ' UID="', uid, '"', this._className ? ' class="' + this._className + '"' : '', - this._attrText === false ? ( this._attrText = X.Dom.Attr.objToAttrText( this._attrs ) ) : this._attrText, + this._attrText === false ? ( this._attrText = X_Node_Attr.objToAttrText( this._attrs ) ) : this._attrText, this._cssText ? ' style="' + this._cssText + '"' : '', '>' ]; @@ -1246,7 +1246,7 @@ Node.prototype._actualCreate = // only textnode html[ n ] = xnodes[ 0 ]._text; ++n; - this._state |= X.Dom.State.IE4_ONLY_TEXT; + this._state |= X_Node_State.IE4_ONLY_TEXT; } else { for( i = 0; i < l; ++i ){ html[ n ] = xnodes[ i ]._actualCreate( true ); @@ -1278,20 +1278,20 @@ Node.prototype._afterActualCreate = l = xnodes && xnodes.length; if( this._isNew ){ - if( !X.Dom._useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加 + if( !X_Node_useDocumentFragment && l ){// docFrg が使えない場合、doc 追加後に子を追加 for( i = 0; i < l; ++i ){ elm.appendChild( xnodes[ i ]._actualCreate( true ) ); }; }; - if( X.Dom._strictElmCreation ){ - if( this._dirty & X.Dom.Dirty.IE_FILTER ){ + if( X_Node_strictElmCreation ){ + if( this._dirty & X_Node_Dirty.IE_FILTER ){ elm.style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); }; delete this._dirty; } else { elm.UID = this._uid; this._newAttrs = this._attrs; - this._dirty = X.Dom.Dirty.ID | X.Dom.Dirty.CLASSNAME | X.Dom.Dirty.CSS | X.Dom.Dirty.ATTR | X.Dom.Dirty.IE_FILTER; + this._dirty = X_Node_Dirty.ID | X_Node_Dirty.CLASSNAME | X_Node_Dirty.CSS | X_Node_Dirty.ATTR | X_Node_Dirty.IE_FILTER; this._updateRawNode( elm ); }; @@ -1319,7 +1319,7 @@ Node.prototype._afterActualCreate = }; }; // textarea への value の適用はここで - if( this._dirty & X.Dom.Dirty.IE_FILTER ){ + if( this._dirty & X_Node_Dirty.IE_FILTER ){ this._ie4getRawNode().style.filter = X.Dom.Style.SPECIAL_FIX( this._css ); }; delete this._dirty; @@ -1363,7 +1363,7 @@ Node.prototype._actualRemove = if( !elm ) return; this._xnodeType === 1 && X_EventDispatcher_toggleAllEvents( this, false );// イベントの退避 - if( X.Dom.Attr.HAS_VALUE[ this._tag ] && ( !this._newAttrs || !X_Object_inObject( 'value', this._newAttrs ) ) ){ + if( X_Node_Attr.HAS_VALUE[ this._tag ] && ( !this._newAttrs || !X_Object_inObject( 'value', this._newAttrs ) ) ){ this._attrs.value = elm.value; }; elm.removeAttribute( 'id' ); // ? diff --git a/0.6.x/js/02_dom/03_XDomEvent.js b/0.6.x/js/02_dom/03_XDomEvent.js index df7c725..e391e58 100644 --- a/0.6.x/js/02_dom/03_XDomEvent.js +++ b/0.6.x/js/02_dom/03_XDomEvent.js @@ -22,9 +22,9 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ X.Dom.Event = function( e, xnode ){ var _type = e.type, type, - changedTouches, targetTouches, targetIDs, changedTargets, isEnd, + touches, events, altKey, ctrlKey, metaKey, shiftKey, target, related, - i, n, time, touch, ev; + elm, i, n, time, touch, ev; //this._event = e; this.type = type = X.Dom.Event.RenameTo[ _type ] || _type; @@ -66,8 +66,8 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.buttons = e.buttons; this.pointerId = e.pointerId; - this.target = Node._getXNode( e.target ); - this.relatedTarget = Node._getXNode( e.relatedTarget ); // xnode + this.target = X_Node_getXNode( e.target ); + this.relatedTarget = X_Node_getXNode( e.relatedTarget ); // xnode this.isPrimary = e.isPrimary; this.hwTimestamp = e.hwTimestamp; this.timestamp = e.timestamp; @@ -100,7 +100,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ ctrlKey = e.ctrlKey; metaKey = e.metaKey; shiftKey = e.shiftKey; - time = X.getTime(); + time = X_Timer_now(); for( i = touches.length; i; ){ touch = touches[ --i ]; target = touch.target; @@ -108,9 +108,9 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ events[ i ] = { type : type, pointerType : 'touch', - target : Node._getXNode( target.nodeType === 3 ? target.parentNode : target ),// defeat Safari bug // xnodetouch.target, + target : X_Node_getXNode( target.nodeType === 3 ? target.parentNode : target ),// defeat Safari bug // xnodetouch.target, currentTarget : xnode, - relatedTarget : Node._getXNode( related.nodeType === 3 ? related.parentNode : related ), // xnode + relatedTarget : X_Node_getXNode( related.nodeType === 3 ? related.parentNode : related ), // xnode isPrimary : true, hwTimestamp : time, timestamp : time, @@ -157,9 +157,9 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.pressure = ( this.button !== -1 ? 0.5 : 0 ); elm = e.target; - this.target = Node._getXNode( elm.nodeType === 3 ? elm.parentNode : elm );// defeat Safari bug // xnodetouch.target; + this.target = X_Node_getXNode( elm.nodeType === 3 ? elm.parentNode : elm );// defeat Safari bug // xnodetouch.target; this.isPrimary = true; - this.hwTimestamp = this.timestamp = X.getTime(); + this.hwTimestamp = this.timestamp = X_Timer_now(); this.altKey = e.altKey; this.ctrlKey = e.ctrlKey; this.metaKey = e.metaKey; @@ -191,10 +191,10 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ //http://www.quirksmode.org/js/events_properties.html if( elm = e.target ){ - this.target = Node._getXNode( elm.nodeType === 3 ? elm.parentNode : elm );// defeat Safari bug // xnode + this.target = X_Node_getXNode( elm.nodeType === 3 ? elm.parentNode : elm );// defeat Safari bug // xnode }; if( elm = e.relatedTarget ){ - this.relatedTarget = Node._getXNode( elm.nodeType === 3 ? elm.parentNode : elm ); // xnode + this.relatedTarget = X_Node_getXNode( elm.nodeType === 3 ? elm.parentNode : elm ); // xnode }; if( type === 'wheel' ){ @@ -232,13 +232,13 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; } else { X.Dom.Event = function( e, xnode, element ){ - var btn; + var _type = e.type, btn, type; - this.type = X.Dom.Event.RenameTo[ e.type ] || e.type; - this.target = Node._getXNode( e.srcElement ); // xnode + this.type = X.Dom.Event.RenameTo[ _type ] || _type; + this.target = X_Node_getXNode( e.srcElement ); // xnode if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか? this.currentTarget = xnode; // xnode - this.relatedTarget = Node._getXNode( e.formElement || e.toElement ); // xnode + this.relatedTarget = X_Node_getXNode( e.formElement || e.toElement ); // xnode this.eventPhase = e.srcElement === element ? 2: 3; this.keyCode = e.keyCode; @@ -247,7 +247,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.shiftKey = e.shiftKey; // http://www.programming-magic.com/20090127231544/ - switch( this.type ){ + switch( _type ){ case 'click' : case 'dblclick' : this.button = 0; @@ -266,16 +266,16 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; this.buttons = e.button; - if( type = X.Dom.Event.toPointer[ e.type ] ){ + if( type = X.Dom.Event.toPointer[ _type ] ){ this.type = type; this.clientX = e.clientX; this.clientY = e.clientY; //this.screenX = e.screenX; //this.screenY = e.screenY; - //if( X.Dom._root ){ // uuu... - this.pageX = e.clientX + X.Dom._root.scrollLeft; - this.pageY = e.clientY + X.Dom._root.scrollTop; + //if( X_Dom_rootElement ){ // uuu... + this.pageX = e.clientX + X_Dom_rootElement.scrollLeft; + this.pageY = e.clientY + X_Dom_rootElement.scrollTop; // DOMAssistant 2.8.1 //event.pageX = DOMAssistant.def(e.pageX)? e.pageX : (event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0)); //event.pageY = DOMAssistant.def(e.pageY)? e.pageY : (event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0)); @@ -305,10 +305,6 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; }; -X.Dom.Event.DOM_PRE_INIT = ++X.Event._LAST_EVENT; -X.Dom.Event.DOM_BUILDER_COMPLETE= ++X.Event._LAST_EVENT; -X.Dom.Event.DOM_INIT = ++X.Event._LAST_EVENT; -X.Dom.Event.XDOM_READY = ++X.Event._LAST_EVENT; X.Dom.Event.VIEW_ACTIVATE = ++X.Event._LAST_EVENT; X.Dom.Event.VIEW_DEACTIVATE = ++X.Event._LAST_EVENT; X.Dom.Event.VIEW_RESIZED = ++X.Event._LAST_EVENT; @@ -449,7 +445,7 @@ if( !navigator.pointerEnabled ){ X.Dom.Event.Rename[ 'pointerup' ] = [ 'touchup', 'mouseup' ]; X.Dom.Event.Rename[ 'pointermove' ] = [ 'touchmove', 'mousemove' ]; X.Dom.Event.Rename[ 'pointercancel' ] = 'touchcancel'; - X.Dom.Event.Rename[ 'click' ] = [ 'click', 'tap' ]; + //X.Dom.Event.Rename[ 'click' ] = [ 'click', 'tap' ]; // ループになってしまう! } else { X.Dom.Event.Rename[ 'pointerdown' ] = 'mousedown'; X.Dom.Event.Rename[ 'pointerup' ] = 'mouseup'; @@ -487,7 +483,7 @@ if( !navigator.pointerEnabled ){ /* for ie9+/Mozilla/Opera9 */ if( X_UA_EVENT.W3C ){ - Node._document.listenOnce( 'DOMContentLoaded', X.Dom._init ); + Node._document.listenOnce( 'DOMContentLoaded', X_TEMP.onDomContentLoaded ); } else if( 6 <= X.UA.IE && X.inHead ){ // if this script in Head @@ -500,7 +496,7 @@ if( 6 <= X.UA.IE && X.inHead ){ s.onreadystatechange = null; s.parentNode.removeChild( s ); delete X_TEMP._script; - X.Dom._init && X.Dom._init(); + X_TEMP.onDomContentLoaded && X_TEMP.onDomContentLoaded(); }; }; }; @@ -508,16 +504,16 @@ if( 6 <= X.UA.IE && X.inHead ){ // http://lists.apple.com/archives/web-dev/2003/Oct/msg00036.html if( X.UA.WebKit || X.UA.Safari < 3 ){ // sniff X.Timer.add( 16, function(){ - if( !X.Dom._init ) return X_Callback_UN_LISTEN; - if( document.readyState === 'loaded' || document.readyState === 'complete' ) return X.Dom._init(); + if( !X_TEMP.onDomContentLoaded ) return X_Callback_UN_LISTEN; + if( document.readyState === 'loaded' || document.readyState === 'complete' ) return X_TEMP.onDomContentLoaded(); }); }; /* for other browsers */ -Node._window.listenOnce( 'load', X.Dom._init ); +Node._window.listenOnce( 'load', X_TEMP.onDomContentLoaded ); // -X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){ - console.log( 'X.Dom XDomReady ' + X.Dom.readyState ); +X.Dom.listenOnce( X.Event.XDOM_READY, function(e){ + console.log( 'X.Dom XDomReady ' + X_Dom_readyState ); } ); X.Dom.listen( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + ' x ' + e.h ); } ); diff --git a/0.6.x/js/02_dom/04_XDomBoxModel.js b/0.6.x/js/02_dom/04_XDomBoxModel.js index 923cc99..31d2058 100644 --- a/0.6.x/js/02_dom/04_XDomBoxModel.js +++ b/0.6.x/js/02_dom/04_XDomBoxModel.js @@ -15,7 +15,7 @@ X.Dom.BoxModel = { -X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){ +X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ var node = Node._systemNode, @@ -87,7 +87,7 @@ Node.prototype.width = function(){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); return this._rawObject.offsetWidth; @@ -109,7 +109,7 @@ Node.prototype.height = function(){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); return this._rawObject.offsetHeight; @@ -131,7 +131,7 @@ Node.prototype.clientWidth = function(){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); return this._rawObject.clientWidth; @@ -153,7 +153,7 @@ Node.prototype.clientHeight = function(){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); return this._rawObject.clientHeight; @@ -175,7 +175,7 @@ Node.prototype.scrollWidth = function(){ console.log( 'xnode.width() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); return this._rawObject.scrollWidth; @@ -197,7 +197,7 @@ Node.prototype.scrollHeight = function(){ console.log( 'xnode.height() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'height' ); return this._rawObject.scrollHeight; @@ -219,7 +219,7 @@ Node.prototype.scrollLeft = function(){ console.log( 'xnode.scrollLeft() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); return this._rawObject.scrollLeft; @@ -241,7 +241,7 @@ Node.prototype.scrollTop = function(){ console.log( 'xnode.scrollTop() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'width' ); return this._rawObject.scrollTop; @@ -271,7 +271,7 @@ Node.prototype.x = function(){ console.log( 'xnode.x() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'left' ); // this.css( X.Dom.Style.Unit.px, 'translateX' ); @@ -294,7 +294,7 @@ Node.prototype.y = function(){ console.log( 'xnode.y() : not belong tree.' ); return 0; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X_UA_DOM.W3C ){ // this.css( X.Dom.Style.Unit.px, 'top' ); // this.css( X.Dom.Style.Unit.px, 'transisitonY' ); @@ -319,7 +319,7 @@ Node.prototype.offset = function( /* xnodeParent */ ){ console.log( 'xnode.offset() : not belong tree.' ); return { x : 0, y : 0 }; }; - if( this._state & X.Dom.State.DISPLAY_NONE ) return 0; + if( this._state & X_Node_State.DISPLAY_NONE ) return 0; if( X.Dom.Node._body === this || X.Dom.Node._html === this ){ return { x : 0, y : 0 }; diff --git a/0.6.x/js/02_dom/05_XDomAttr.js b/0.6.x/js/02_dom/05_XDomAttr.js index 6e84b1f..2ff418f 100644 --- a/0.6.x/js/02_dom/05_XDomAttr.js +++ b/0.6.x/js/02_dom/05_XDomAttr.js @@ -1,4 +1,4 @@ -X.Dom.Attr = { +var X_Node_Attr = { noValue : { checked : 1, compact : 1, @@ -55,7 +55,7 @@ X.Dom.Attr = { // 動的に生成した input 要素を文書ツリーに挿入する前に設定した checked 属性は反映されず、defaultChecked だと反映される // 先頭にスペース objToAttrText : function( obj ){ - var noValue = X.Dom.Attr.noValue, + var noValue = X_Node_Attr.noValue, attrs = [ '' ], n = 0, p, v; if( !obj ) return ''; // Opera7 for( p in obj ){ @@ -74,13 +74,13 @@ X.Dom.Attr = { for( name in renameForDOM ){ renameForTag[ renameForDOM[ name ] ] = name; }; -})( X.Dom.Attr.renameForDOM, X.Dom.Attr.renameForTag ); +})( X_Node_Attr.renameForDOM, X_Node_Attr.renameForTag ); /* -------------------------------------- * attribute - * X.Dom.Attr.toIndex に定義されている 属性の場合 + * X_Node_Attr.toIndex に定義されている 属性の場合 * * http://nanto.asablo.jp/blog/2005/10/29/123294 * className, onclick等 はここで設定しない @@ -100,7 +100,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ }; if( f ){ this._attrText = false; - this._dirty |= X.Dom.Dirty.ATTR; + this._dirty |= X_Node_Dirty.ATTR; this._root && this._reserveUpdate(); }; return this; @@ -109,7 +109,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ // setter if( this._setAttr( attrs || ( this._attrs = {} ), this._newAttrs || ( this._newAttrs = {} ), nameOrObj, arguments[ 1 ] ) === true ){ this._attrText = false; - this._dirty |= X.Dom.Dirty.ATTR; + this._dirty |= X_Node_Dirty.ATTR; this._root && this._reserveUpdate(); }; return this; @@ -133,7 +133,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ case 'selected' : case 'disabled' : case 'selectedIndex' : - if( X.Dom.Attr.HAS_VALUE[ this._tag ] ){ + if( X_Node_Attr.HAS_VALUE[ this._tag ] ){ if( this._newAttrs && X_Object_inObject( nameOrObj, this._newAttrs ) ) return this._newAttrs[ nameOrObj ]; if( elm = X_UA_DOM.IE4 ? this._rawObject || this._ie4getRawNode() : this._rawObject ){ if( !attrs ) attrs = this._attrs = {}; @@ -142,7 +142,7 @@ X.Dom.Node.prototype.attr = function( nameOrObj /* v */ ){ }; break; }; - return attrs && attrs[ X.Dom.Attr.renameForTag[ nameOrObj ] || nameOrObj ]; + return attrs && attrs[ X_Node_Attr.renameForTag[ nameOrObj ] || nameOrObj ]; }; }; X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ @@ -156,7 +156,7 @@ X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ v = ( v !== 'ie4uid' + this._uid ) ? v : undefined; if( v !== this._id ){ this._id = v; - this._dirty |= X.Dom.Dirty.ID; + this._dirty |= X_Node_Dirty.ID; this._root && this._reserveUpdate(); }; return; @@ -173,7 +173,7 @@ X.Dom.Node.prototype._setAttr = function( attrs, newAttrs, name, v ){ return; }; - name = X.Dom.Attr.renameForTag[ name ] || name; + name = X_Node_Attr.renameForTag[ name ] || name; if( attrs[ name ] === v ) return; if( v == null ){ diff --git a/0.6.x/js/02_dom/06_XDomStyle.js b/0.6.x/js/02_dom/06_XDomStyle.js index f3d8aba..112caf2 100644 --- a/0.6.x/js/02_dom/06_XDomStyle.js +++ b/0.6.x/js/02_dom/06_XDomStyle.js @@ -986,16 +986,16 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ ieFix = X.Dom.Style.IE_FILTER_FIX; for( p in nameOrObj ){ if( ieFix[ p ] ){ - this._dirty |= X.Dom.Dirty.IE_FILTER; + this._dirty |= X_Node_Dirty.IE_FILTER; }; v = nameOrObj[ p ]; v || v === 0 ? css[ camelize( p ) ] = v : delete css[ camelize( p ) ]; if( p === 'display' ){ - v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX ); - v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE ); + v === 'none' ? ( this._state |= X_Node_State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X_Node_State.IE5_DISPLAY_NONE_FIX ); + v === 'none' ? ( this._state |= X_Node_State.DISPLAY_NONE ) : ( this._state &= ~X_Node_State.DISPLAY_NONE ); }; }; - this._dirty |= X.Dom.Dirty.CSS; + this._dirty |= X_Node_Dirty.CSS; this.parent && this._reserveUpdate(); delete this._cssText; return this; @@ -1008,7 +1008,7 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ v = args[ 1 ]; if( css[ name ] === v ) return this; if( X.Dom.Style.IE_FILTER_FIX[ name ] ){ - this._dirty |= X.Dom.Dirty.IE_FILTER; + this._dirty |= X_Node_Dirty.IE_FILTER; }; if( !v && v !== 0 ){ delete css[ name ]; @@ -1016,10 +1016,10 @@ X.Dom.Node.prototype.css = function( nameOrObj /* orUnitID, valuOrUnitOrName */ css[ name ] = v; }; delete this._cssText; - this._dirty |= X.Dom.Dirty.CSS; + this._dirty |= X_Node_Dirty.CSS; if( name === 'display' ){ - v === 'none' ? ( this._state |= X.Dom.State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX ); - v === 'none' ? ( this._state |= X.Dom.State.DISPLAY_NONE ) : ( this._state &= ~X.Dom.State.DISPLAY_NONE ); + v === 'none' ? ( this._state |= X_Node_State.IE5_DISPLAY_NONE_FIX ) : ( this._state &= ~X_Node_State.IE5_DISPLAY_NONE_FIX ); + v === 'none' ? ( this._state |= X_Node_State.DISPLAY_NONE ) : ( this._state &= ~X_Node_State.DISPLAY_NONE ); }; // parent でなく this._root! でなくて this._state & in tree this.parent && this._reserveUpdate(); @@ -1045,15 +1045,15 @@ X.Dom.Node.prototype.cssText = function( v ){ var obj, i, l, attr, name; if( v === '' ){ delete this._css; - this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX; - this._dirty |= X.Dom.Dirty.CSS; + this._state &= ~X_Node_State.IE5_DISPLAY_NONE_FIX; + this._dirty |= X_Node_Dirty.CSS; this.parent && this._reserveUpdate(); delete this._cssText; return this; } else if( X.Type.isString( v ) ){ delete this._css; - this._state &= ~X.Dom.State.IE5_DISPLAY_NONE_FIX; + this._state &= ~X_Node_State.IE5_DISPLAY_NONE_FIX; obj = {}; v = v.split( ';' ); // TODO content ";" などにも対応 for( i = 0, l = v.length; i < l; ++i ){ @@ -1063,7 +1063,7 @@ X.Dom.Node.prototype.cssText = function( v ){ return this.css( obj ); }; // getter - if( this._dirty & X.Dom.Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ + if( this._dirty & X_Node_Dirty.CSS && !( this._cssText = X.Dom.Style.objToCssText( this._css ) ) ){ delete this._cssText; }; return this._cssText; @@ -1072,14 +1072,14 @@ X.Dom.Node.prototype.cssText = function( v ){ /* * ここでは HTMLElement のチ1ェックは行わない! * TODO - * body に css attr がセットされた場合には X.Dom.baseFontSize をクリア + * body に css attr がセットされた場合には X_Dom_baseFontSize をクリア */ X.Dom.Node.prototype._getCharSize = window.getComputedStyle ? (function(){ Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; if( this._fontSize ) return this._fontSize; return this._fontSize = parseFloat( getComputedStyle( this._rawObject, null ).fontSize ); }) : @@ -1087,7 +1087,7 @@ X.Dom.Node.prototype._getCharSize = document.defaultView && document.defaultView.getComputedStyle ? (function(){ Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; if( this._fontSize ) return this._fontSize; return this._fontSize = parseFloat( document.defaultView.getComputedStyle( this._rawObject, null ).fontSize ); }) : @@ -1104,7 +1104,7 @@ X.Dom.Node.prototype._getCharSize = (function(){ var font, vu, v, u, _v; Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; if( this._fontSize ) return this._fontSize; font = this._rawObject.currentStyle.fontSize; @@ -1135,7 +1135,7 @@ X.Dom.Node.prototype._getCharSize = (function(){ var elm, v; Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; if( this._fontSize ) return this._fontSize; this._rawObject.appendChild( elm = document.createElement( 'span' ) ); @@ -1149,7 +1149,7 @@ X.Dom.Node.prototype._getCharSize = (function(){ var font, vu, v, u, _v; Node._body._updateTimerID && Node._body._startUpdate(); - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; if( this._fontSize ) return this._fontSize; if( this._css && ( font = this._css.fontSize ) ){ @@ -1182,7 +1182,7 @@ X.Dom.Node.prototype._getCharSize = }) : (function(){ var elm, v; - if( this === Node._body && X.Dom.baseFontSize ) return X.Dom.baseFontSize; + if( this === Node._body && X_Dom_baseFontSize ) return X_Dom_baseFontSize; Node._body._updateTimerID && Node._body._startUpdate(); if( this._fontSize ) return this._fontSize; @@ -1260,7 +1260,7 @@ X.Dom.Node.prototype._getCharSize = }; } )(); -X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){ +X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ var xnode = Node._systemNode, output = X.Dom.Style._UNIT_RATIO = {}, list = 'cm,mm,in,pt,pc'.split( ',' ), diff --git a/0.6.x/js/02_dom/07_XDomNodeList.js b/0.6.x/js/02_dom/07_XDomNodeList.js index 136a3af..1f8e25e 100644 --- a/0.6.x/js/02_dom/07_XDomNodeList.js +++ b/0.6.x/js/02_dom/07_XDomNodeList.js @@ -52,7 +52,7 @@ X.Dom.NodeList.prototype.each = function( func /* opt_args... */ ){ /* -------------------------------------- * Fuction Base, multi, getter, setter, */ -X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, function(){ +X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, function(){ var target = X.Dom.NodeList.prototype, src = X.Dom.Node.prototype, p, v, multi; diff --git a/0.6.x/js/02_dom/08_XDomSelector.js b/0.6.x/js/02_dom/08_XDomSelector.js index 0c01534..371d81d 100644 --- a/0.6.x/js/02_dom/08_XDomSelector.js +++ b/0.6.x/js/02_dom/08_XDomSelector.js @@ -242,8 +242,8 @@ X.Dom.Query._parse = function( query, last ){ links, className, attr, flag; /*@+debug[*/ - if( X.Dom.readyState < X.Dom.Event.XDOM_READY ){ - alert( 'not ready! use X.Dom.listenOnce( X.Dom.Event.XDOM_READY, callback )' ); + if( X_Dom_readyState < X.Event.XDOM_READY ){ + alert( 'not ready! use X.Dom.listenOnce( X.Event.XDOM_READY, callback )' ); return; }; /*]@+debug*/ @@ -427,7 +427,7 @@ X.Dom.Query._parse = function( query, last ){ op = filter[ 1 ]; val = filter[ 2 ]; - key = X.Dom.Attr.renameForTag[ key ] || key; + key = X_Node_Attr.renameForTag[ key ] || key; // [class~='val'] if( !isXML && key === 'class' && op === 3 ){ @@ -455,7 +455,7 @@ X.Dom.Query._parse = function( query, last ){ //flag_call ? // funcAttr( elem, key ) : //useName ? - // elem[ X.Dom.Attr.renameForDOM[ key ] || key ] : + // elem[ X_Node_Attr.renameForDOM[ key ] || key ] : // elem.getAttribute( key, 2 ); flag = attr != null;// && ( !useName || attr !== '' ); if( flag && op ){ diff --git a/0.6.x/js/02_dom/09_XDomParser.js b/0.6.x/js/02_dom/09_XDomParser.js index db496ef..d4030e2 100644 --- a/0.6.x/js/02_dom/09_XDomParser.js +++ b/0.6.x/js/02_dom/09_XDomParser.js @@ -5,7 +5,7 @@ * */ -X_Dom_Parser = { +var X_Dom_Parser = { CHARS : { A:1,B:1,C:1,D:1,E:1,F:1,G:1,H:1,I:1,J:1,K:1,L:1,M:1,N:1,O:1,P:1,Q:1,R:1,S:1,T:1,U:1,V:1,W:1,X:1,Y:1,Z:1, a:2,b:2,c:2,d:2,e:2,f:2,g:2,h:2,i:2,j:2,k:2,l:2,m:2,n:2,o:2,p:2,q:2,r:2,s:2,t:2,u:2,v:2,w:2,x:2,y:2,z:2, @@ -48,7 +48,7 @@ X_Dom_Parser = { */ // Attributes that have their values filled in disabled="disabled" - fillAttrs : X.Dom.Attr.noValue, //{checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; + fillAttrs : X_Node_Attr.noValue, //{checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; // Special Elements (can contain anything) special : { SCRIPT : 1, STYLE : 1, PLAINTEXT : 1, XMP : 1, TEXTAREA : 1 }, @@ -56,7 +56,7 @@ X_Dom_Parser = { exec : function( html, handler, async ){ var special = X_Dom_Parser.special, //plainText = X_Dom_Parser.plainText, - startTime = async && X.getTime(), + startTime = async && X_Timer_now(), _parseStartTag = X_Dom_Parser._parseStartTag, _parseEndTag = X_Dom_Parser._parseEndTag, stack = async ? async[ 1 ] : [], @@ -124,7 +124,7 @@ X_Dom_Parser = { return; }; - if( async && startTime + 15 <= X.getTime() && html ){ + if( async && startTime + 15 <= X_Timer_now() && html ){ handler.progress( 1 - html.length / async[ 0 ] ); X.Timer.once( 0, X_Dom_Parser.exec, [ html, handler, async ] ); return; @@ -266,7 +266,7 @@ X_Dom_Parser = { }; }, - parseStartTag : function( stack, last, handler, tagName, attrs, unary, index ) { + parseStartTag : function( stack, last, handler, tagName, attrs, empty, index ) { var inline = X_Dom_Parser.inline, parseEndTag = X_Dom_Parser.parseEndTag, sisters = X_Dom_Parser.sisters; @@ -277,10 +277,10 @@ X_Dom_Parser = { }; }; last && X_Dom_Parser.closeSelf[ tagName ] === 1 && ( last === tagName || ( sisters[ tagName ] && sisters[ tagName ][ last ] === 1 ) ) && parseEndTag( stack, handler, last ); - unary = unary || X_Dom_Parser.empty[ tagName ]; - !unary && ( stack[ stack.length ] = tagName ); + empty = empty || X_Dom_Parser.empty[ tagName ]; + !empty && ( stack[ stack.length ] = tagName ); - return handler.start( tagName, attrs, unary, index ); + return handler.start( tagName, attrs, empty, index ); }, parseEndTag : function( stack, handler, tagName ) { diff --git a/0.6.x/js/02_dom/22_XDomBuilder.js b/0.6.x/js/02_dom/22_XDomBuilder.js index daa50fb..efa4a8d 100644 --- a/0.6.x/js/02_dom/22_XDomBuilder.js +++ b/0.6.x/js/02_dom/22_XDomBuilder.js @@ -105,7 +105,7 @@ if( X.UA.Opera7 ){ * http://kojs.sukobuto.com/docs/visible-binding * IE6 には、「空の span エレメントに続く空白は無視される」という謎な癖があります。 */ -X.Dom.listenOnce( X.Dom.Event.DOM_PRE_INIT, +X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, X_UA_DOM.W3C ? (function(){ var r = Node._body, @@ -245,7 +245,7 @@ X_TEMP.asyncCreateTree = function ( parent, elems, elmProgress, async ){ l = async ? 0 : xnodes.length, stack = async ? async.stack : [], done = async ? async.done : 0, - startTime = X.getTime(), + startTime = X_Timer_now(), current = async ? async.current : { me : parent, xnodes : xnodes, @@ -282,7 +282,7 @@ X_TEMP.asyncCreateTree = function ( parent, elems, elmProgress, async ){ continue; }; - if( startTime + 16 <= X.getTime() ){ + if( startTime + 16 <= X_Timer_now() ){ current.i = i; if( async ){ async.current = i < l && current; @@ -299,7 +299,7 @@ X_TEMP.asyncCreateTree = function ( parent, elems, elmProgress, async ){ current = null; }; // complete - X.Dom.asyncDispatch( 0, X.Dom.Event.DOM_BUILDER_COMPLETE ); + X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_XTREE ); elmProgress.parentNode ? elmProgress.parentNode.removeChild( elmProgress ) : ( elmProgress.outerHTML = '' ); delete X_TEMP.asyncCreateTree; delete X_TEMP.bindElementToXnode; @@ -534,8 +534,8 @@ X_TEMP.bindElementToXnode = }; // textNode がある - ( current.flag & 6 ) && ( parent._dirty |= X.Dom.Dirty.IE4_TEXTNODE_FIX ); + ( current.flag & 6 ) && ( parent._dirty |= X_Node_Dirty.IE4_TEXTNODE_FIX ); }); console.log( 'X.Dom.Builder' ); -console.log( 'bootTime : ' + ( X.getTime() - X.bootTime ) ); \ No newline at end of file +console.log( 'bootTime : ' + ( X_Timer_now() - X.bootTime ) ); \ No newline at end of file diff --git a/0.6.x/js/03_plugin/00_XPlugin.js b/0.6.x/js/03_plugin/00_XPlugin.js index b13c5a4..863ebc3 100644 --- a/0.6.x/js/03_plugin/00_XPlugin.js +++ b/0.6.x/js/03_plugin/00_XPlugin.js @@ -22,10 +22,13 @@ var X_Pulgin_FLASH_VERSION = navigator.mimeTypes[ 'application/x-shockwave-flash' ] && navigator.mimeTypes[ 'application/x-shockwave-flash' ].enabledPlugin, +/* + * ie11 の 互換モード(8,7)では、Silverlight が動作しない? + */ X_Pulgin_SILVER_LIGHT_VERSION = !X.UA.IE && navigator.plugins[ 'Silverlight Plug-In' ] ? parseFloat( navigator.plugins[ 'Silverlight Plug-In' ].version ) : - X.UA.ActiveX && 6 <= X.UA.IE ? (function(){ + X.UA.ActiveX && 6 <= X.UA.IE && !X.UA.IECompat ? (function(){ return eval( 'var a,i=0;try{a=new ActiveXObject("AgControl.AgControl");for(i=5;i;--i)if(a.IsVersionSupported(i+".0"))break;}catch(e){i=0}i' ); })() : 0, diff --git a/0.6.x/js/04_util/01_XNinjaIframe.js b/0.6.x/js/04_util/01_XNinjaIframe.js index 26eb94a..cdcc24e 100644 --- a/0.6.x/js/04_util/01_XNinjaIframe.js +++ b/0.6.x/js/04_util/01_XNinjaIframe.js @@ -18,7 +18,7 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( Constructor : function( html ){ - this._name = 'hidden-iframe-' + X.getTime(); + this._name = 'hidden-iframe-' + X_Timer_now(); // https://github.com/polygonplanet/Pot.js/blob/master/src/Worker.js this.xnodeIframe = X.Dom.Node._body.create( diff --git a/0.6.x/js/05_net/00_XNet.js b/0.6.x/js/05_net/00_XNet.js index 0900ae9..71c3172 100644 --- a/0.6.x/js/05_net/00_XNet.js +++ b/0.6.x/js/05_net/00_XNet.js @@ -1,4 +1,5 @@ // TODO onlineevent offlineevent, netspeed +// local への通信に対しては、netspeed を更新しない X.Net = { xhrGet : function( url ){ diff --git a/0.6.x/js/06_audio/00_XAudio.js b/0.6.x/js/06_audio/00_XAudio.js index 175d2ec..4675b13 100644 --- a/0.6.x/js/06_audio/00_XAudio.js +++ b/0.6.x/js/06_audio/00_XAudio.js @@ -60,7 +60,7 @@ function X_Audio_detectComplete( e, proxy, option, sourceList, source, ext, sup }; -X_AudioProxy = X.EventDispatcher.inherits( +var X_AudioProxy = X.EventDispatcher.inherits( 'X.AV.AudioProxy', X.Class.POOL_OBJECT, { diff --git a/0.6.x/js/06_audio/02_XSilverlightAudio.js b/0.6.x/js/06_audio/02_XSilverlightAudio.js index 2019d4a..13b499e 100644 --- a/0.6.x/js/06_audio/02_XSilverlightAudio.js +++ b/0.6.x/js/06_audio/02_XSilverlightAudio.js @@ -130,7 +130,7 @@ if( X.Pulgin.SilverlightEnabled ){ * このページのサンプルは sl5+firefox32 環境で動いている。xaml を js から利用する形ではなく、.xap を sl4 以下で作るのがよさそう. */ this.proxy = proxy; - this._onload = 'XAudioSilverlightOnLoad';// + ( ++X_Audio_SLAudio_uid ); + this._onload = 'XAudioSilverlightOnLoad' + ( ++X_Audio_SLAudio_uid ); this._callback = window[ this._onload ] = X_Callback_create( this, this.onSLReady, [ option.autoplay ] ); this.xnodeObject = X.Dom.Node._body .create( 'object', { @@ -165,6 +165,8 @@ if( X.Pulgin.SilverlightEnabled ){ this._callback.kill(); delete this._callback; + if( sender.findName('media') ) alert( 'exist' ); + sender.children.add( sender.GetHost(). content. diff --git a/0.6.x/js/20_ui/15_ScrollBox.js b/0.6.x/js/20_ui/15_ScrollBox.js index f7dac75..a52c1d7 100644 --- a/0.6.x/js/20_ui/15_ScrollBox.js +++ b/0.6.x/js/20_ui/15_ScrollBox.js @@ -374,7 +374,7 @@ X.Class._override( iScroll.prototype, { this.pointX = point.pageX; this.pointY = point.pageY; - this.startTime = e.timeStamp || X.getTime(); + this.startTime = e.timeStamp || X.Timer.now(); this.uinodeRoot.listen( X.UI.Event.DRAG, this ); this.uinodeRoot.listen( X.UI.Event.DRAG_END, this ); @@ -389,7 +389,7 @@ X.Class._override( iScroll.prototype, { newX = this.x + deltaX, newY = this.y + deltaY, c1, c2, scale, - timestamp = e.timeStamp ||X.getTime(), ret; + timestamp = e.timeStamp ||X.Timer.now(), ret; //if (this.options.onBeforeScrollMove) this.options.onBeforeScrollMove.call(this, e); if( ( ret = this._trigger( X.UI.Event.SCROLL_BEFORE_MOVE ) ) & X.Callback.PREVENT_DEFAULT ){ @@ -448,7 +448,7 @@ X.Class._override( iScroll.prototype, { var point = hasTouch ? e.changedTouches[0] : e, momentumX = { dist:0, time:0 }, momentumY = { dist:0, time:0 }, - duration = ( e.timeStamp ||X.getTime() ) - this.startTime, + duration = ( e.timeStamp ||X.Timer.now() ) - this.startTime, newPosX = this.x, newPosY = this.y, distX, distY, @@ -655,12 +655,12 @@ X.Class._override( iScroll.prototype, { //step.time ? X.Dom.Event.add( this.scroller, TRNEND_EV, this ) /* this._bind(TRNEND_EV) */ : this._resetPos(0); //return; //} - //this._doAnimate( X.getTime(), step, startX, startY ); + //this._doAnimate( X.Timer.now(), step, startX, startY ); }, /* _doAnimate : function( startTime, step, startX, startY ){ - var now =X.getTime(), + var now =X.Timer.now(), easeOut, newX, newY; if (now >= startTime + step.time) { diff --git a/0.6.x/js/20_ui/20_PageRoot.js b/0.6.x/js/20_ui/20_PageRoot.js index d8dbac2..b13f170 100644 --- a/0.6.x/js/20_ui/20_PageRoot.js +++ b/0.6.x/js/20_ui/20_PageRoot.js @@ -1,7 +1,8 @@ X.UI._eventRellay = function( e ){ - var x = e.clientX / X.Dom.baseFontSize, - y = e.clientY / X.Dom.baseFontSize, + var font = X.Dom.getBaseFontSize(), + x = e.clientX / font, + y = e.clientY / font, type = X.UI.Event.NameToID[ e.type ], i = 0, data = X.UI.currentRootData, @@ -84,10 +85,10 @@ X.UI._PageRoot = X.UI._Box.inherits( Constructor : function( layout, args ){ this.SuperConstructor( layout, args ); - if( X.Dom.readyState === X.Dom.Event.XDOM_READY ){ + if( X_Dom_readyState === X.Event.XDOM_READY ){ X.Timer.once( 0, this, this.start ); } else { - X.Dom.listenOnce( X.Dom.Event.XDOM_READY, this, this.start ); + X.Dom.listenOnce( X.Event.XDOM_READY, this, this.start ); }; this.hoverList = []; @@ -154,13 +155,14 @@ X.UI._PageRoot = X.UI._Box.inherits( }; }, calculate : function( e ){ - var font = X.Dom.baseFontSize, - size, w, h; + var font, size, w, h; if( !e ){ size = X.Dom.getSize(); + font = X.Dom.getBaseFontSize(); w = size[ 0 ]; h = size[ 1 ]; } else { + font = e.fontSize; w = e.w; h = e.h; }; -- 2.11.0