From 003fff3f160afb3e3a2cceb3d20b19a17977e94d Mon Sep 17 00:00:00 2001 From: itozyun Date: Sat, 11 Oct 2014 19:01:38 +0900 Subject: [PATCH] Version 0.6.96. add lock function @X.EventDispatcher. --- 0.6.x/index.html | 3 + 0.6.x/js/01_core/01_X.js | 4 +- 0.6.x/js/01_core/10_XCallback.js | 67 +++------- 0.6.x/js/01_core/11_XClass.js | 157 ++++++++++++----------- 0.6.x/js/01_core/12_XEvent.js | 49 +++++++- 0.6.x/js/01_core/13_XEventDispatcher.js | 155 ++++++++++++----------- 0.6.x/js/01_core/14_XTimer.js | 2 +- 0.6.x/js/01_core/15_XSystem.js | 25 ++++ 0.6.x/js/02_dom/00_XDom.js | 23 ++-- 0.6.x/js/02_dom/02_XDomNode.js | 12 +- 0.6.x/js/02_dom/03_XDomEvent.js | 200 ++++++++++++------------------ 0.6.x/js/02_dom/09_XDomParser.js | 52 ++++---- 0.6.x/js/02_dom/20_XDomImage.js | 10 +- 0.6.x/js/02_dom/22_XDomBuilder.js | 11 +- 0.6.x/js/04_util/01_XNinjaIframe.js | 4 +- 0.6.x/js/05_net/00_XNet.js | 4 +- 0.6.x/js/05_net/01_XNetXHR.js | 16 +-- 0.6.x/js/05_net/04_XNetImage.js | 14 +-- 0.6.x/js/06_audio/01_XHTML5Audio.js | 2 +- 0.6.x/js/06_audio/02_XSilverlightAudio.js | 4 +- 0.6.x/js/20_ui/04_XUI_Event.js | 172 ++++++++++++------------- 0.6.x/js/20_ui/17_Text.js | 4 +- 0.6.x/js/import.js | 6 +- 0.6.x/js/onReachEndOfScript.js | 4 + 24 files changed, 513 insertions(+), 487 deletions(-) create mode 100644 0.6.x/js/01_core/15_XSystem.js create mode 100644 0.6.x/js/onReachEndOfScript.js diff --git a/0.6.x/index.html b/0.6.x/index.html index 10acb8e..b18a5e2 100644 --- a/0.6.x/index.html +++ b/0.6.x/index.html @@ -14,6 +14,7 @@ + @@ -28,6 +29,8 @@ + + diff --git a/0.6.x/js/01_core/01_X.js b/0.6.x/js/01_core/01_X.js index 49c8ed5..97ef4e9 100644 --- a/0.6.x/js/01_core/01_X.js +++ b/0.6.x/js/01_core/01_X.js @@ -10,7 +10,9 @@ if( !window['console'] || ( window.parent && window.parent.log ) ) console = { l var undefined, X = new Function( 'return X._shortcut && X._shortcut.apply( X._shortcut, arguments )' ), - X_TEMP = { onSystemReady : [] }; + X_TEMP = { onSystemReady : [] }, + X_shortcutFunction, + X_shortcutContext; X.VERSION = '0.6.89'; diff --git a/0.6.x/js/01_core/10_XCallback.js b/0.6.x/js/01_core/10_XCallback.js index a57ce6c..ce295d6 100644 --- a/0.6.x/js/01_core/10_XCallback.js +++ b/0.6.x/js/01_core/10_XCallback.js @@ -39,47 +39,18 @@ var callbackHash; var functionHash; X.Callback = { - NONE : X_Callback_NONE, UN_LISTEN : X_Callback_UN_LISTEN, STOP_PROPAGATION : X_Callback_STOP_PROPAGATION, STOP_NOW : X_Callback_STOP_NOW, PREVENT_DEFAULT : X_Callback_PREVENT_DEFAULT, - MONOPOLY : X_Callback_MONOPOLY, - - create : X_Callback_create, - - sys_monitor : function(){ - return { - 'Live callback' : X_Callback_LIVE_LIST.length, - 'Pool callback' : X_Callback_POOL_LIST.length - }; - }, - - sys_gc : function(){ - var list = X_Callback_POOL_LIST, - f; - while( 0 < list.length ){ - f = list.shift(); - X_Callback_correct( f ); - delete f[ 'kill' ]; - delete f[ 'same' ]; - }; - } + MONOPOLY : X_Callback_MONOPOLY }; -X_TEMP.onSystemReady.push( X_Callback_handleSystemEvent ); - // ------------------------------------------------------------------------- // // --- implements ---------------------------------------------------------- // // ------------------------------------------------------------------------- // -function X_Callback_handleSystemEvent( e ){ - switch( e ){ - case '': - }; -}; - function X_Callback_create( thisObject, opt_callback, opt_args /* [ listener || ( context + function ) || function ][ args... ] */ ){ var obj = X_Callback_classifyCallbackArgs( thisObject, opt_callback, opt_args ), l, ret, _obj; @@ -93,11 +64,9 @@ function X_Callback_create( thisObject, opt_callback, opt_args /* [ listener || _obj.s = obj.s; } else { ret = X_Closure_actualClosure( obj ); - ret.kill = X_Callback_kill; - ret.same = X_Callback_same; }; X_Callback_LIVE_LIST[ X_Callback_LIVE_LIST.length ] = ret; - return ret; + return ret; }; function X_Closure_actualClosure( obj ){ @@ -200,20 +169,6 @@ function X_Callback_proxyCallback( xfunc, _args ){ return X_Callback_NONE; }; -function X_Callback_same( arg1, arg2, arg3 ){ - var hash; - - if( arg1 && arg1[ 'kill' ] === X_Callback_kill ) return this === arg1; - - hash = X_Callback_classifyCallbackArgs( arg1, arg2, arg3 ); - - return hash && this.k === hash.k && this.x === hash.x && this.f === hash.f && this.s === hash.s; -}; - -function X_Callback_kill(){ - X_Callback_correct( this ); -}; - function X_Callback_correct( f ){ var i = X_Callback_LIVE_LIST.indexOf( f ), obj; @@ -231,6 +186,24 @@ function X_Callback_correct( f ){ }; +// sys +X_TEMP.X_Callback_onSystemReady = function( sys ){ + delete X_TEMP.X_Callback_onSystemReady; + sys.monitor( X_Callback_monitor ); + sys.gc( X_Callback_gc ); +}; + +function X_Callback_monitor(){ + return { + 'Callback:Live' : X_Callback_LIVE_LIST.length, + 'Callback:Pool' : X_Callback_POOL_LIST.length + }; +}; +function X_Callback_gc(){ + X_Callback_POOL_LIST.length = 0; // ? +}; + +X_TEMP.onSystemReady.push( X_TEMP.X_Callback_onSystemReady ); console.log( 'X.Core.Callback' ); diff --git a/0.6.x/js/01_core/11_XClass.js b/0.6.x/js/01_core/11_XClass.js index 86b1e23..1bf0697 100644 --- a/0.6.x/js/01_core/11_XClass.js +++ b/0.6.x/js/01_core/11_XClass.js @@ -24,6 +24,83 @@ var X_Class_CLASS_LIST = [], X_Class_useObjectCreate = false, // !!Object.create, http://jsperf.com/prototype-vs-object-create-perf X_Class_use_proto_ = !!X.emptyFunction.prototype.__proto__; +/* + * X.Class.create で作られたクラスのインスタンスが共通で備えるメソッド + */ +var X_Class_CommonProps = { + kill : function(){ + var instance = this, + klass = X_Class_getClass( instance ), + def = X_Class_getClassDef( klass ), + data, p, i; + if( def.isPrivate && !X_Class_killPrivateFlag ){ + X.Logger.critical( 'PrivateInstance.kill() work in PrivateUser.kill().' ); + return; + }; + X_Class_killPrivateFlag = false; // onKill 内で PrivateInstance.kill() を防ぐため + + // onKill() === false の場合、kill のキャンセル + // private は false での キャンセル は無視される + + if( this.instanceOf( X.EventDispatcher ) ){ + //console.log( 'this.instanceOf( X.EventDispatcher )! ' + this._dispatching ); + if( !def.isPrivate ){ + if( this._dispatching ){ + this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); + this._killReserved = true; + this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); + return; + } else + if( this.dispatch( X.Event.BEFORE_KILL_INSTANCE ) & X.Callback.PREVENT_DEFAULT ){ + this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); + return; + }; + } else { + this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); + }; + this.dispatch( X.Event.KILL_INSTANCE ); + this._listeners && X_EventDispatcher_systemUnlisten( this ); //.unlisten(); + } else + if( X.Type.isFunction( instance.onKill ) && instance.onKill() === false && !def.isPrivate ){ + return; + }; + + for( p in instance ){ + if( instance.hasOwnProperty && !instance.hasOwnProperty( p ) ) continue; + delete instance[ p ]; + }; + if( def.pool ){ + def.live && def.live.splice( def.live.indexOf( instance ), 1 ); + def.pool[ def.pool.length ] = instance; + }; + if( def.privateClass ){ + i = def.userList.indexOf( instance ); + if( i !== -1 ){ + data = X_Class_getPrivate( instance ); + X_Class_killPrivateFlag = true; + if( data._dispatching && data.instanceOf( X.EventDispatcher ) ){ + data._killReserved = true; + } else { + data.kill(); + }; + def.dataList.splice( i, 1 ); + def.userList.splice( i, 1 ); + }; + }; + }, + + // TODO Super + // superCall + + instanceOf : function( klass ){ + var Super = this; + if( this.constructor === klass ) return true; + while( Super = X_Class_getClassDef( Super ).SuperClass ){ + if( Super === klass ) return true; + }; + return false; + } +}; // ------------------------------------------------------------------------- // // --- interface ----------------------------------------------------------- // // ------------------------------------------------------------------------- // @@ -328,86 +405,6 @@ function X_Class_inherits( /* displayName, classSetting, opt_PrivateClass, props return klass; }; - -/* X.Class.create で作られたクラスのインスタンスが共通で備えるメソッド - * - * - */ -var X_Class_CommonProps = { - kill : function(){ - var instance = this, - klass = X_Class_getClass( instance ), - def = X_Class_getClassDef( klass ), - data, p, i; - if( def.isPrivate && !X_Class_killPrivateFlag ){ - X.Logger.critical( 'PrivateInstance.kill() work in PrivateUser.kill().' ); - return; - }; - X_Class_killPrivateFlag = false; // onKill 内で PrivateInstance.kill() を防ぐため - - // onKill() === false の場合、kill のキャンセル - // private は false での キャンセル は無視される - - if( this.instanceOf( X.EventDispatcher ) ){ - console.log( 'this.instanceOf( X.EventDispatcher )! ' + this._dispatching ); - if( !def.isPrivate ){ - if( this._dispatching ){ - this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); - this._killReserved = true; - this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); - return; - } else - if( this.dispatch( X.Event.BEFORE_KILL_INSTANCE ) & X.Callback.PREVENT_DEFAULT ){ - this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); - return; - }; - } else { - this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); - }; - console.log('kill ' + this._dispatching); - this.dispatch( X.Event.KILL_INSTANCE ); - this._listeners && this.unlisten(); - } else - if( X.Type.isFunction( instance.onKill ) && instance.onKill() === false && !def.isPrivate ){ - return; - }; - - for( p in instance ){ - if( instance.hasOwnProperty && !instance.hasOwnProperty( p ) ) continue; - delete instance[ p ]; - }; - if( def.pool ){ - def.live && def.live.splice( def.live.indexOf( instance ), 1 ); - def.pool[ def.pool.length ] = instance; - }; - if( def.privateClass ){ - i = def.userList.indexOf( instance ); - if( i !== -1 ){ - data = X_Class_getPrivate( instance ); - X_Class_killPrivateFlag = true; - if( data._dispatching && data.instanceOf( X.EventDispatcher ) ){ - data._killReserved = true; - } else { - data.kill(); - }; - def.dataList.splice( i, 1 ); - def.userList.splice( i, 1 ); - }; - }; - }, - - // TODO Super - // superCall - - instanceOf : function( klass ){ - var Super = this; - if( this.constructor === klass ) return true; - while( Super = X_Class_getClassDef( Super ).SuperClass ){ - if( Super === klass ) return true; - }; - return false; - } -}; /* * new の実体.コンストラクタの機能は instance.Constructor に書く. diff --git a/0.6.x/js/01_core/12_XEvent.js b/0.6.x/js/01_core/12_XEvent.js index 2474315..758fb1a 100644 --- a/0.6.x/js/01_core/12_XEvent.js +++ b/0.6.x/js/01_core/12_XEvent.js @@ -1,4 +1,32 @@ +var X_Event_last = 0, + X_Event_Rename = {}, + X_Event_RenameTo = {}, + + X_Event_toPointer = !X_UA_HID.POINTER && ( X_UA_HID.TOUCH ? + { + touchdown : 'pointerdown', + mousedown : 'pointerdown', + touchup : 'pointerup', + mouseup : 'pointerup', + touchmove : 'pointermove', + mousemove : 'pointermove', + touchcancel : 'pointercancel', + contextmenu : 'contextmenu', + dbclick : 'dbclick', + click : 'click', + tap : 'click' + } : + { + mousedown : 'pointerdown', + mouseup : 'pointerup', + mousemove : 'pointermove', + contextmenu : 'contextmenu', + dbclick : 'dbclick', + click : 'click' + }); + +// 内部イベント X_TEMP.SYSTEM_EVENT_PRE_INIT = 1; X_TEMP.SYSTEM_EVENT_XTREE = 2; X_TEMP.SYSTEM_EVENT_INIT = 3; @@ -16,7 +44,22 @@ X.Event = { TIMEOUT : 12, BEFORE_KILL_INSTANCE : 13, KILL_INSTANCE_CANCELED : 14, - KILL_INSTANCE : 15, + KILL_INSTANCE : 15 +}; + +X_Event_last = 15; - _LAST_EVENT : 15 -}; \ No newline at end of file +X_TEMP.onSystemReady.push( + function(){ + var k, name, i; + for( k in X_Event_Rename ){ + name = X_Event_Rename[ k ]; + if( X.Type.isArray( name ) ){ + for( i = name.length; i; ){ + X_Event_RenameTo[ name[ --i ] ] = k; + }; + } else { + X_Event_RenameTo[ name ] = k; + }; + }; + }); diff --git a/0.6.x/js/01_core/13_XEventDispatcher.js b/0.6.x/js/01_core/13_XEventDispatcher.js index 0dab627..24fea1b 100644 --- a/0.6.x/js/01_core/13_XEventDispatcher.js +++ b/0.6.x/js/01_core/13_XEventDispatcher.js @@ -21,6 +21,8 @@ // ------------ local variables -------------------------------------------- // // ------------------------------------------------------------------------- // var X_EventDispatcher_once = false, + X_EventDispatcher_lock = false, + X_EventDispatcher_unlock = false, X_EventDispatcher_needsIndex = false, X_EventDispatcher_safariPreventDefault = false; // Safari3- @@ -30,7 +32,7 @@ var X_EventDispatcher_once = false, // ------------------------------------------------------------------------- // /** - * イベントターゲット(widnow, document, Image, XHR 等)をラップする場合、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor} + * イベントターゲット(widnow, document, Image, XHR, Silverlight 等)をラップする場合、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor} * アプリケーション独自のイベントをやり取りしたいだけ、という場合、イベントターゲットは不要です。 * @class * @classdesc EventTarget オブジェクトをラップしたり、アプリケーションで独自に定義したイベントを発信するためのクラスです。 @@ -39,6 +41,8 @@ var X_EventDispatcher_once = false, * イベントターゲットオブジェクト(widnow, document, HTMLElement, XHR 等)が _rawObject に設定されていた場合に、それらへ実際のイベント登録・解除も行います。 * このイベントの登録・解除はクロスブラウザで、IE5~8 の独自イベントの差異を吸収し、DOM0 に対しても複数のコールバックを登録することができます。 * またコールバックに対して、this コンテキストや、追加の引数を指定もできます。 this コンテキストを指定しなかった場合、EventDispatcher インスタンスがコールバックの this になります。 + * unlisten() は、引数を指定しなかった場合、全てのイベントを解除します。ただし、systemListen 経由で登録されたハンドラは解除されません。 + * systemListen, systemUnlisten は、ライブラリ内のコードからしかアクセスできません。 * @param {object=} opt_rawObject */ X.EventDispatcher = @@ -166,7 +170,7 @@ X.EventDispatcher = * @this {X.EventDispatcher} * @return {(number|boolean)} * @param {(string|number)=} opt_type - * @param {(listener|function|Array)=} opt_arg1 + * @param {(listener|function|Array|callbackHash)=} opt_arg1 * @param {(function|Array=} opt_arg2 * @param {Array=} opt_arg3 */ @@ -192,7 +196,10 @@ X.EventDispatcher = }; for( i = list.length; i; ){ f = list[ --i ]; - if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return X_EventDispatcher_needsIndex ? i : true; + if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ){ + // index を要求された場合、lock されていない、または unlock なら index を返す + return X_EventDispatcher_needsIndex ? ( X_EventDispatcher_unlock || !f.lock ? i : false ) : true; + }; }; return false; }, @@ -201,10 +208,15 @@ X.EventDispatcher = * delay(ミリ秒)後にイベントを dispatch する。戻り値は uid = X.Timer.add() のタイマーID(数値)。X.Timer.remove(uid) でタイマーを解除して dispatch を中止できる。 * @this {X.EventDispatcher} * @return {number} - * @param {number=} delay + * @param {number=} delay ms 省略した場合は 0 として扱う asyncDispatch( 'myevent' ) -> asyncDispatch( 0, 'myevent' ) * @param {(eventHash|string|number)=} e */ asyncDispatch : function( delay, e ){ + if( delay && e === undefined ){ + e = delay; + delay = 0; + console.log( 'lazy : ' + e ); + }; return X.Timer.add( delay, 1, this, this.dispatch, [ e ] ); } } @@ -249,12 +261,13 @@ function X_EventDispatcher_dispatch( e ){ }; if( unlistens && unlistens.indexOf( f ) !== -1 ) continue; - r = X_Callback_NONE; - if( f.k ){ - r = X_Callback_proxyCallback( f, args || ( args = [ e ] ) ); - } else { - r = f.call( this, e ); - }; + //if( f !== X.emptyFunction ){ + // if( f.k ){ + r = X_Callback_proxyCallback( f, args || ( args = [ e ] ) ); + // } else { + // r = f.call( this, e ); + // }; + //}; if( f.once || r & X_Callback_UN_LISTEN ){ // dispatch 中に unlisten が作られることがある @@ -276,7 +289,8 @@ function X_EventDispatcher_dispatch( e ){ unlistens = this._unlistens; delete this._dispatching; delete this._unlistens; - + // _unlistens に入っている callbackHash は、lock をクリアしている + X_EventDispatcher_unlock = true; for( type in unlistens ){ list = unlistens[ type ]; for( i = list.length; i; ){ @@ -285,6 +299,7 @@ function X_EventDispatcher_dispatch( e ){ list.length = 0; delete unlistens[ type ]; }; + X_EventDispatcher_unlock = false; if( this._killReserved ){ this.kill(); @@ -293,8 +308,10 @@ function X_EventDispatcher_dispatch( e ){ for( i = 0, l = list.length; i < l; ++i ){ f = list[ i ]; X_EventDispatcher_once = f[ 4 ]; + X_EventDispatcher_lock = f[ 5 ]; this.listen( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] ); X_EventDispatcher_once = false; + X_EventDispatcher_lock = false; f.length = 0; }; list.length = 0; @@ -320,7 +337,7 @@ function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){ if( this._dispatching ){ if( !this._reserves ) this._reserves = []; - this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, X_EventDispatcher_once ]; + this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, X_EventDispatcher_once, X_EventDispatcher_lock ]; return this; }; @@ -339,15 +356,25 @@ function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){ if( !list ) list = this._listeners = {}; if( !( list = list[ type ] ) ) list = this._listeners[ type ] = []; - add && X_EventDispatcher_actualAddEvent( this, type, raw, list ); + add && X_EventDispatcher_addEvent( this, type, raw, list ); f = X_Callback_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this ); list[ list.length ] = f; f.once = X_EventDispatcher_once; + f.lock = X_EventDispatcher_lock; return this; }; +/* + * X_EventDispatcher_systemUnlisten 経由でないと解除できないリスナの登録 + */ +function X_EventDispatcher_systemListen( that, type, opt_arg1, opt_arg2, opt_arg3 ){ + X_EventDispatcher_lock = true; + that.listen( type, opt_arg1, opt_arg2, opt_arg3 ); + X_EventDispatcher_lock = false; +}; + /** * * @this {X.EventDispatcher} @@ -409,26 +436,48 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){ if( i === false ) return this; f = ( _list = list[ opt_type ] )[ i ]; + // _unlistens に入っている callbackHash は、lock をクリアしている if( unlistens = this._unlistens ){ ( unlistens = unlistens[ opt_type ] ) ? ( unlistens[ unlistens.length ] = f ) : ( this._unlistens[ opt_type ] = [ f ] ); } else { delete f.once; - // f.kill === X_Callback_kill && f.kill(); _list.splice( i, 1 ); if( !_list.length ){ raw = this._rawObject || this._ie4getRawNode && this._ie4getRawNode(); delete list[ opt_type ]; if( empty = X_Object_isEmpty( list ) ) delete this._listeners; if( raw && '' + parseFloat( opt_type ) !== '' + opt_type ){ // 数字イベントの除外 - X_EventDispatcher_actualRemoveEvent( this, opt_type, raw, _list, !empty ); + X_EventDispatcher_removeEvent( this, opt_type, raw, _list, !empty ); }; }; }; return this; }; +/* + * X_EventDispatcher_systemListen から登録したイベントの解除 + */ +function X_EventDispatcher_systemUnlisten( that, type, opt_arg1, opt_arg2, opt_arg3 ){ + X_EventDispatcher_unlock = true; + that.unlisten( type, opt_arg1, opt_arg2, opt_arg3 ); + X_EventDispatcher_unlock = false; +}; + +function X_EventDispatcher_addEvent( that, type, raw, list ){ + var i; + X_EventDispatcher_lock || ( type = X_Event_Rename[ type ] || type ); + + if( X.Type.isArray( type ) ){ + for( i = type.length; i; ){ + X_EventDispatcher_systemListen( that, type[ --i ], X.emptyFunction ); + console.log( 'X_EventDispatcher_systemListen ' + type[ i ] ); + }; + } else { + X_EventDispatcher_actualAddEvent( that, type, raw, list ); + }; +}; var X_EventDispatcher_actualAddEvent = // Days on the Moon DOM Events とブラウザの実装 @@ -436,15 +485,6 @@ var X_EventDispatcher_actualAddEvent = // Safari 2 では関数オブジェクトしか EventListener として使えませんが、Safari のナイトリービルドでは handleEvent メソッドを持つオブジェクトも EventListener として使えるようです。 X_UA_EVENT.W3C /* && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) */ ? // Safari3- (function( that, type, raw, list ){ - var i; - - 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 && X.UA.Opera < 12 ){ // Opera11- の XHR は event オブジェクトが返らないため, eventType 毎に callback を指定する addEventListener もない raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] ); @@ -465,18 +505,6 @@ var X_EventDispatcher_actualAddEvent = }) : X_UA_EVENT.IE ? (function( that, type, raw, list ){ - var i; - //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 ] ); @@ -495,19 +523,12 @@ var X_EventDispatcher_actualAddEvent = }; }) : (function( that, type, raw, list ){ - var i; - 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 ){ // ie4 mobile は XHR をサポート! raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] ); } else if( that._isSilverlight ){ + // DOM0 で Silverlight ってあるの? list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] ); list.sltoken = raw.AddEventListener( type, list.slcallback ); } else { @@ -523,17 +544,22 @@ function X_EventDispatcher_sliverLightDispatch( sender, e, type ){ return this.dispatch( type ); }; +function X_EventDispatcher_removeEvent( that, type, raw, list, skip ){ + var i; + X_EventDispatcher_unlock || ( type = X_Event_Rename[ type ] || type ); + + if( X.Type.isArray( type ) ){ + for( i = type.length; i; ){ + X_EventDispatcher_systemUnlisten( that, type[ --i ], X.emptyFunction ); + }; + } else { + X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ); + }; +}; + 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 ] = ''; @@ -557,18 +583,6 @@ var X_EventDispatcher_actualRemoveEvent = }) : X_UA_EVENT.IE ? (function( that, type, raw, list, skip ){ - var i; - //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; @@ -594,13 +608,6 @@ var X_EventDispatcher_actualRemoveEvent = }; }) : (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_Callback_correct( raw[ 'on' + type ] ); raw[ 'on' + type ] = X.emptyFunction; @@ -650,7 +657,7 @@ var X_EventDispatcher_actualHandleEvent = var ev = new X.Dom.Event( e, this ), ret = X_Callback_NONE, i, l; - + console.log( '>>>>>>>>>> ' + e.type ); // touch event -> pointer if( X.Type.isArray( ev ) ){ if( ev.length === 0 ){ @@ -658,6 +665,7 @@ var X_EventDispatcher_actualHandleEvent = ret = X.Callback.STOP_PROPAGATION | X.Callback.PREVENT_DEFAULT; } else { for( i = 0, l = ev.length; i < l; ++i ){ + console.log( 'handleEvent ' + ev[ i ].type ); ret |= this.dispatch( ev[ i ] ) || 0; }; }; @@ -696,12 +704,13 @@ if( X.UA.WebKit < 525.13 ){ // Safari3- function X_EventDispatcher_toggleAllEvents( that, add ){ var list = that._listeners, raw = that._rawObject || that._ie4getRawNode && that._ie4getRawNode(), - f = add ? X_EventDispatcher_actualAddEvent : X_EventDispatcher_actualRemoveEvent, + f = add ? X_EventDispatcher_addEvent : X_EventDispatcher_removeEvent, type; if( !list || !raw ) return; for( type in list ){ // 数字イベントの除外 if( '' + parseFloat( type ) !== type ){ + // TODO type rename はここ f( that, type, raw, list[ type ], true ); }; }; diff --git a/0.6.x/js/01_core/14_XTimer.js b/0.6.x/js/01_core/14_XTimer.js index ca07dac..9d4a849 100644 --- a/0.6.x/js/01_core/14_XTimer.js +++ b/0.6.x/js/01_core/14_XTimer.js @@ -205,7 +205,7 @@ function X_Timer_onTimeout(){ heavy, q, f, c, r, uid; - console.log( '予定時間と発火時間の差:' + ( now - X_Timer_timeStamp - X_Timer_waitTime * X_Timer_INTERVAL_TIME ) + ' -:' + minus + ' next:' + X_Timer_waitTime ); + //console.log( '予定時間と発火時間の差:' + ( now - X_Timer_timeStamp - X_Timer_waitTime * X_Timer_INTERVAL_TIME ) + ' -:' + minus + ' next:' + X_Timer_waitTime ); if( X_Timer_busyTimeout ){ alert( 'X_Timer_busyTimeout フラグが立ったまま!エラーの可能性' ); diff --git a/0.6.x/js/01_core/15_XSystem.js b/0.6.x/js/01_core/15_XSystem.js new file mode 100644 index 0000000..fbb8fe0 --- /dev/null +++ b/0.6.x/js/01_core/15_XSystem.js @@ -0,0 +1,25 @@ + + +var X_System = X.Class._override( + new X.EventDispatcher(), + { + monitor : function(){ + + }, + + gc : function(){ + + } + } +); + +X_TEMP.onRearchEndOfScript = function(){ + var cbs = X_TEMP.onSystemReady, + i = cbs.length; + delete X_TEMP.onRearchEndOfScript; + delete X_TEMP.onSystemReady; + + for( ; i; ){ + cbs[ --i ]( X_System ); + }; +}; \ No newline at end of file diff --git a/0.6.x/js/02_dom/00_XDom.js b/0.6.x/js/02_dom/00_XDom.js index 4590e52..39c5483 100644 --- a/0.6.x/js/02_dom/00_XDom.js +++ b/0.6.x/js/02_dom/00_XDom.js @@ -53,7 +53,7 @@ X.Dom = X.Class._override( /* * X.Event.XDOM_READY 以後に listen した場合の対策 */ - X.Dom.asyncDispatch( 0, { type : type, w : X_Dom_width, h : X_Dom_height } ); + X.Dom.asyncDispatch( { type : type, w : X_Dom_width, h : X_Dom_height } ); }; return X_EventDispatcher_listen.apply( X.Dom, arguments ); }, @@ -117,7 +117,7 @@ X.Dom = X.Class._override( getBaseFontSize : function(){ if( Node._body._updateTimerID ){ Node._body._startUpdate(); - return Node._fontSizeNode._rawObject.offsetHeight; + return X_Dom_baseFontSize = Node._fontSizeNode._rawObject.offsetHeight; }; return X_Dom_baseFontSize; } @@ -171,7 +171,7 @@ X.Dom = X.Class._override( 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_width, h : X_Dom_height } ); + X_Dom_baseFontSize && X.Dom.asyncDispatch( { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); X_Dom_baseFontSize = size; }; @@ -186,13 +186,13 @@ X.Dom = X.Class._override( 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_width = size[ 0 ]; X_Dom_height = size[ 1 ]; X.Timer.once( 100, X_Dom_detectFinishResizing ); } else { console.log( '-- detectFinishResizing : ' + X_Timer_now() ); - X.Dom.asyncDispatch( 0, { type : X.Dom.Event.VIEW_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); + X.Dom.asyncDispatch( { type : X.Dom.Event.VIEW_RESIZED, fontSize : X_Dom_baseFontSize, w : X_Dom_width, h : X_Dom_height } ); X_Dom_lock = false; if( X_Dom_orientationFlag ){ X_Dom_orientationFlag = false; @@ -208,7 +208,7 @@ X.Dom = X.Class._override( X_Dom_readyState = X_TEMP.SYSTEM_EVENT_PRE_INIT; // DOMContentLoaded の無いブラウザで X_TEMP.onDomContentLoaded への参照が残り続けるのを回避 - Node._document.unlisten( 'DOMContentLoaded', X_TEMP.onDomContentLoaded ); + X_TEMP.onDomContentLoaded && Node._document.unlisten( 'DOMContentLoaded', X_TEMP.onDomContentLoaded ); delete X_TEMP.onDomContentLoaded; elmHtml = document.documentElement || @@ -243,7 +243,8 @@ X.Dom = X.Class._override( 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 ); + if( X_TEMP.X_Dom_useBuilder ) X_TEMP.X_Dom_useBuilder = !!document.body.children.length; + !X_TEMP.X_Dom_useBuilder && X.Dom.asyncDispatch( X_TEMP.SYSTEM_EVENT_XTREE ); } ); X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_XTREE, function(){ @@ -254,7 +255,7 @@ X.Dom = X.Class._override( Node._fontSizeNode = Node.create( 'div', { 'class' : 'hidden-system-node' } ).cssText( 'line-height:1;height:1em;' ).text( 'X' ) )._startUpdate(); - X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_INIT ); + X.Dom.asyncDispatch( X_TEMP.SYSTEM_EVENT_INIT ); } ); X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_INIT, function(){ @@ -274,10 +275,10 @@ X.Dom = X.Class._override( X_Dom_baseFontSize = Node._fontSizeNode._rawObject.offsetHeight; 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( { type : X.Event.XDOM_READY, w : X_Dom_width = size[ 0 ], h : X_Dom_height = size[ 1 ] } ); } ); - X.Dom.asyncDispatch( 0, X_TEMP.SYSTEM_EVENT_PRE_INIT ); + console.log( X.Dom.asyncDispatch( X_TEMP.SYSTEM_EVENT_PRE_INIT ) ); Node._window .listen( 'beforeunload', X.Dom ) @@ -314,7 +315,7 @@ if( !( X.UA.IE < 9 || X.UA.iOS ) ){ 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_width, h : X_Dom_height } ); + X_Dom_baseFontSize && X.Dom.asyncDispatch( { type : X.Dom.Event.BASE_FONT_RESIZED, fontSize : size, w : X_Dom_width, h : X_Dom_height } ); X_Dom_baseFontSize = size; }; }; diff --git a/0.6.x/js/02_dom/02_XDomNode.js b/0.6.x/js/02_dom/02_XDomNode.js index 71caaa2..eb8be17 100644 --- a/0.6.x/js/02_dom/02_XDomNode.js +++ b/0.6.x/js/02_dom/02_XDomNode.js @@ -147,7 +147,7 @@ var break; 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 = X_HtmlParser_parse( v, true ) && 1 < xnodes.length ) return new X.Dom.NodeList( xnodes ); if( xnodes.length ) return xnodes[ 0 ]; return Node.none; case X_Node_TYPE.IMAGE : @@ -226,7 +226,7 @@ Node.create = function( tag, opt_attrs, opt_css ){ Node._newByTag = true; return new Node( tag, opt_attrs, opt_css ); case X_Node_TYPE.HTML_STRING : - list = X.Dom.parse( tag, true ); + list = X_HtmlParser_parse( tag, true ); for( i = list.length; 1 < i; ){ list[ --i ].destroy(); }; @@ -371,7 +371,7 @@ Node.prototype.append = function( v ){ break; case X_Node_TYPE.HTML_STRING : case X_Node_TYPE.STRING : - return this.append.apply( this, X.Dom.parse( v, true ) ); + return this.append.apply( this, X_HtmlParser_parse( v, true ) ); case X_Node_TYPE.XNODE : if( v._xnodeType !== 1 && v._xnodeType !== 3 ) return this; // 親の xnodes から v を消す @@ -431,7 +431,7 @@ Node.prototype.appendAt = function( start, v ){ break; case X_Node_TYPE.HTML_STRING : case X_Node_TYPE.STRING : - v = X.Dom.parse( v, true ); + v = X_HtmlParser_parse( v, true ); for( i = v.length; i; ){ this.appendAt( start, v[ --i ] ); }; @@ -470,7 +470,7 @@ Node.prototype.appendTo = function( parent, opt_index ){ parent = new Node( parent ); break; case X_Node_TYPE.HTML_STRING : - parent = X.Dom.parse( parent, true ); + parent = X_HtmlParser_parse( parent, true ); parent = parent[ 0 ] || parent; case X_Node_TYPE.XNODE : break; @@ -766,7 +766,7 @@ Node.prototype.html = function( html ){ // setter if( html !== undefined ){ // String 以外に Number や false null なども許可 if( this._xnodeType === 3 ) return this.text( html ); - return html ? this.empty().append.apply( this, X.Dom.parse( html, true ) ) : this.empty(); + return html ? this.empty().append.apply( this, X_HtmlParser_parse( html, true ) ) : this.empty(); }; // getter diff --git a/0.6.x/js/02_dom/03_XDomEvent.js b/0.6.x/js/02_dom/03_XDomEvent.js index e391e58..b79e4cd 100644 --- a/0.6.x/js/02_dom/03_XDomEvent.js +++ b/0.6.x/js/02_dom/03_XDomEvent.js @@ -20,15 +20,16 @@ var X_Dom_Event_devicePixelRatio = window.devicePixelRatio || ( window.screen.de if( !X.UA.IE || 9 <= X.UA.IE ){ X.Dom.Event = function( e, xnode ){ - var _type = e.type, - type, + var originalType = e.type, + type, pointerType, touches, events, altKey, ctrlKey, metaKey, shiftKey, target, related, elm, i, n, time, touch, ev; //this._event = e; - this.type = type = X.Dom.Event.RenameTo[ _type ] || _type; + this.type = type = X_Event_RenameTo[ originalType ] || originalType; + console.log( 'original : ' + originalType + ' > ' + type ); // http://msdn.microsoft.com/ja-jp/library/ie/dn304886%28v=vs.85%29.aspx // ポインター イベントの更新 if( e.pointerType ){ @@ -52,7 +53,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ //Y-Z 平面と、ペンの軸が含まれる平面の間の角度を返します。Y 軸の範囲は -90 ~ +90 です。X の傾きの正の方向は右方向です。 this.tiltX = e.tiltX; this.tiltY = e.tiltY; - if( _type === 'MSPointerHover' ){ + if( originalType === 'MSPointerHover' ){ this.type = 'pointermove'; // ie10 には pointerhover と pointermoveがあり、ie11 で一本化。ie11 では buttons を見て hover 状態を判定 }; case 'touch' : @@ -85,15 +86,15 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.offsetX = e.offsetX; this.offsetY = e.offsetY; } else - if( X.Dom.Event.toPointer[ _type ] ){ + if( pointerType = X_Event_toPointer[ originalType ] ){ // Touch or Mouse /* e.constructor === window.TouchEvent -> e.touches for iOS3.13 */ - if( touches = e.changedTouches ){ + if( touches = e.changedTouches ){ if( touches.length === 0 ){ alert( 'e.changedTouches.length === 0' ); }; - xnode._cancelMouse = type; + xnode._cancelMouse = pointerType; events = []; altKey = e.altKey; @@ -106,7 +107,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ target = touch.target; related = touch.relatedTarget; events[ i ] = { - type : type, + type : pointerType, pointerType : 'touch', target : X_Node_getXNode( target.nodeType === 3 ? target.parentNode : target ),// defeat Safari bug // xnodetouch.target, currentTarget : xnode, @@ -140,8 +141,9 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ return events.length === 1 ? events[ 0 ] : events; } else { - if( xnode._cancelMouse === type ){ + if( xnode._cancelMouse === pointerType ){ delete xnode._cancelMouse; + console.log( '**** xnode._cancelMouse ' + xnode._cancelMouse ); return []; }; @@ -149,8 +151,6 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.type = type; this.pointerType = 'mouse'; - // http://www.programming-magic.com/20090127231544/ - // TODO Opera で button==2の場合、コンテキストメニューイベントを発火 「ツール」->「設定」->「詳細設定」->「コンテンツ」->「Javascriptオプション」で「右クリックを制御するスクリプトを許可する」 this.button = e.button !== undefined ? e.button : e.which !== undefined ? e.which - 1 : -1; this.buttons = e.buttons !== undefined ? e.buttons : this.button === 0 ? 1 : this.button === 1 ? 2 : this.button === 2 ? 4 : 0; @@ -175,6 +175,14 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.pageY = e.pageY; this.offsetX = e.offsetX || e.layerX; // 要素上の座標を取得 this.offsetY = e.offsetY || e.layerY; + + // http://www.programming-magic.com/20090127231544/ + // Opera で button==2の場合、コンテキストメニューイベントを発火 「ツール」->「設定」->「詳細設定」->「コンテンツ」->「Javascriptオプション」で「右クリックを制御するスクリプトを許可する」 + if( originalType === 'mousedown' && this.button === 2 && X.UA.Opera ){ + events = [ X.Object.clone( this ), X.Object.clone( this ) ]; + events[ 1 ].type = 'contextmenu'; + return events; + }; }; } else { // Other @@ -218,11 +226,11 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ } else if( e.detail !== undefined ){ this.deltaX = this.deltaZ = 0; - this.deltaY = _type === 'MozMousePixelScroll' ? e.detail / 45 : e.detail / 3; // 3 + this.deltaY = originalType === 'MozMousePixelScroll' ? e.detail / 45 : e.detail / 3; // 3 } else { this.deltaX = this.deltaY = this.deltaZ = 0; }; - }; + }; }; this.currentTarget = xnode; // xnode @@ -232,9 +240,9 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; } else { X.Dom.Event = function( e, xnode, element ){ - var _type = e.type, btn, type; + var originalType = e.type, btn, type; - this.type = X.Dom.Event.RenameTo[ _type ] || _type; + this.type = X_Event_RenameTo[ originalType ] || originalType; 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 @@ -247,7 +255,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ this.shiftKey = e.shiftKey; // http://www.programming-magic.com/20090127231544/ - switch( _type ){ + switch( originalType ){ case 'click' : case 'dblclick' : this.button = 0; @@ -266,7 +274,7 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; this.buttons = e.button; - if( type = X.Dom.Event.toPointer[ _type ] ){ + if( type = X_Event_toPointer[ originalType ] ){ this.type = type; this.clientX = e.clientX; this.clientY = e.clientY; @@ -305,27 +313,27 @@ if( !X.UA.IE || 9 <= X.UA.IE ){ }; }; -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; -X.Dom.Event.VIEW_TURNED = ++X.Event._LAST_EVENT; -X.Dom.Event.BASE_FONT_RESIZED = ++X.Event._LAST_EVENT; +X.Dom.Event.VIEW_ACTIVATE = ++X_Event_last; +X.Dom.Event.VIEW_DEACTIVATE = ++X_Event_last; +X.Dom.Event.VIEW_RESIZED = ++X_Event_last; +X.Dom.Event.VIEW_TURNED = ++X_Event_last; +X.Dom.Event.BASE_FONT_RESIZED = ++X_Event_last; // same_page_jump // on_screen_keyboard_show // on_screen_keyboard_hide -// X.Dom.Event.BEFORE_UPDATE = ++X.Event._LAST_EVENT; // このイベントで要素のサイズを取得すると無限ループに! -X.Dom.Event.AFTER_UPDATE = ++X.Event._LAST_EVENT; +// X.Dom.Event.BEFORE_UPDATE = ++X_Event_last; // このイベントで要素のサイズを取得すると無限ループに! +X.Dom.Event.AFTER_UPDATE = ++X_Event_last; // hash_change -X.Dom.Event.BEFORE_UNLOAD = ++X.Event._LAST_EVENT; -X.Dom.Event.UNLOAD = ++X.Event._LAST_EVENT; +X.Dom.Event.BEFORE_UNLOAD = ++X_Event_last; +X.Dom.Event.UNLOAD = ++X_Event_last; + +X.Dom.Event.ANIME_BEFORE_START = ++X_Event_last; +X.Dom.Event.ANIME_START = ++X_Event_last; +X.Dom.Event.ANIME = ++X_Event_last; +X.Dom.Event.ANIME_END = ++X_Event_last; +X.Dom.Event.ANIME_BEFORE_STOP = ++X_Event_last; // xnode.stop() のみ、指定時間による停止では呼ばれない +X.Dom.Event.ANIME_STOP = ++X_Event_last; -X.Dom.Event.ANIME_BEFORE_START = ++X.Event._LAST_EVENT; -X.Dom.Event.ANIME_START = ++X.Event._LAST_EVENT; -X.Dom.Event.ANIME = ++X.Event._LAST_EVENT; -X.Dom.Event.ANIME_END = ++X.Event._LAST_EVENT; -X.Dom.Event.ANIME_BEFORE_STOP = ++X.Event._LAST_EVENT; // xnode.stop() のみ、指定時間による停止では呼ばれない -X.Dom.Event.ANIME_STOP = ++X.Event._LAST_EVENT; -X.Dom.Event._LAST_EVENT = X.Event._LAST_EVENT; // ここに書いてあるイベントの最後の値 X.Dom.Event.ANIME_STOP と同じ値 // TODO load -> readystatechange this.readyState === "loaded" || this.readyState === "complete" X.Dom.Event._LOAD_FIX_TAGS = { @@ -334,32 +342,6 @@ X.Dom.Event._LOAD_FIX_TAGS = { //LINK : true }; -X.Dom.Event.Rename = {}; -X.Dom.Event.RenameTo = {}; -X.Dom.Event.toPointer = !X_UA_HID.POINTER && ( X_UA_HID.TOUCH ? - { - touchdown : 'pointerdown', - mousedown : 'pointerdown', - touchup : 'pointerup', - mouseup : 'pointerup', - touchmove : 'pointermove', - mousemove : 'pointermove', - touchcancel : 'pointercancel', - contextmenu : 'contextmenu', - dbclick : 'dbclick', - click : 'click', - tap : 'click' - } : - { - mousedown : 'pointerdown', - mouseup : 'pointerup', - mousemove : 'pointermove', - contextmenu : 'contextmenu', - dbclick : 'dbclick', - click : 'click' - }); - - // https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js // https://developer.mozilla.org/en-US/docs/Web/Events/wheel // @@ -368,17 +350,17 @@ if( document.onwheel === undefined ){ if( X.UA.Gecko && window.MouseScrollEvent ){ if( 2 <= X.UA.Gecko || ( 1.9 <= X.UA.Gecko && 1 <= X.UA.GeckoPatch ) ){ // Gecko 1.9.1+ (firefox3.5+) console.log( 'wheel <= MozMousePixelScroll' ); - X.Dom.Event.Rename[ 'wheel' ] = 'MozMousePixelScroll'; + X_Event_Rename[ 'wheel' ] = 'MozMousePixelScroll'; } else if( 1 <= X.UA.Gecko || ( 0.9 <= X.UA.Gecko && 7 <= X.UA.GeckoPatch ) ){ // Gecko 0.9.7+ (NN6.2+?) console.log( 'wheel <= DOMMouseScroll' ); - X.Dom.Event.Rename[ 'wheel' ] = 'DOMMouseScroll'; + X_Event_Rename[ 'wheel' ] = 'DOMMouseScroll'; }; } else { - X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel'; + X_Event_Rename[ 'wheel' ] = 'mousewheel'; }; //if( document.onmousewheel !== undefined ){ // Opera で判定失敗する - // X.Dom.Event.Rename[ 'wheel' ] = 'mousewheel'; + // X_Event_Rename[ 'wheel' ] = 'mousewheel'; //}; }; @@ -386,92 +368,78 @@ if( document.onwheel === undefined ){ if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){ console.log( 'animationend <= webkitAnimationEnd' ); - X.Dom.Event.Rename[ 'animationend' ] = 'webkitAnimationEnd'; - X.Dom.Event.Rename[ 'animationstart' ] = 'webkitAnimationStart'; - X.Dom.Event.Rename[ 'animationiteration' ] = 'webkitAnimationIteration'; + X_Event_Rename[ 'animationend' ] = 'webkitAnimationEnd'; + X_Event_Rename[ 'animationstart' ] = 'webkitAnimationStart'; + X_Event_Rename[ 'animationiteration' ] = 'webkitAnimationIteration'; } else if( window.onoanimationend !== undefined && window.onanimationend === undefined ){ console.log( 'animationend <= oAnimationEnd' ); - X.Dom.Event.Rename[ 'animationend' ] = 'oAnimationEnd'; - X.Dom.Event.Rename[ 'animationstart' ] = 'oAnimationStart'; - X.Dom.Event.Rename[ 'animationiteration' ] = 'oAnimationIteration'; + X_Event_Rename[ 'animationend' ] = 'oAnimationEnd'; + X_Event_Rename[ 'animationstart' ] = 'oAnimationStart'; + X_Event_Rename[ 'animationiteration' ] = 'oAnimationIteration'; } else /* if( window.onmozanimationend !== undefined && window.onanimationend === undefined ){ - X.Dom.Event.Rename[ 'animationend' ] = 'mozAnimationEnd'; - X.Dom.Event.RenameTo[ 'mozAnimationEnd' ] = 'animationend'; - X.Dom.Event.Rename[ 'animationstart' ] = 'mozAnimationStart'; - X.Dom.Event.RenameTo[ 'mozAnimationStart' ] = 'animationstart'; - X.Dom.Event.Rename[ 'animationiteration' ] = 'mozAnimationIteration'; - X.Dom.Event.RenameTo[ 'mozAnimationIteration' ] = 'animationiteration'; + X_Event_Rename[ 'animationend' ] = 'mozAnimationEnd'; + X_Event_RenameTo[ 'mozAnimationEnd' ] = 'animationend'; + X_Event_Rename[ 'animationstart' ] = 'mozAnimationStart'; + X_Event_RenameTo[ 'mozAnimationStart' ] = 'animationstart'; + X_Event_Rename[ 'animationiteration' ] = 'mozAnimationIteration'; + X_Event_RenameTo[ 'mozAnimationIteration' ] = 'animationiteration'; } else*/ if( document.documentElement && document.documentElement.style.msAnimation !== undefined && document.documentElement.style.animation === undefined ){ //document.documentElement.style.msAnimation console.log( 'animationend <= MSAnimationEnd' ); - X.Dom.Event.Rename[ 'animationend' ] = 'MSAnimationEnd'; - X.Dom.Event.Rename[ 'animationstart' ] = 'MSAnimationStart'; - X.Dom.Event.Rename[ 'animationiteration' ] = 'MSAnimationIteration'; + X_Event_Rename[ 'animationend' ] = 'MSAnimationEnd'; + X_Event_Rename[ 'animationstart' ] = 'MSAnimationStart'; + X_Event_Rename[ 'animationiteration' ] = 'MSAnimationIteration'; }; // https://developer.mozilla.org/en-US/docs/Web/Events/transitionend // chrome1+, firefox4+, IE10+, Opera10.5+, Safari3.2+, Android2.1+ if( window.onwebkittransitionend !== undefined && window.ontransitionend === undefined ){ console.log( 'transitionend <= webkitTransitionEnd' ); - X.Dom.Event.Rename[ 'transitionend' ] = 'webkitTransitionEnd'; + X_Event_Rename[ 'transitionend' ] = 'webkitTransitionEnd'; } else if( window.onotransitionend !== undefined && window.ontransitionend === undefined ){ if( X.UA.Opera < 12 ){ console.log( 'transitionend <= oTransitionEnd|ver.' + X.UA.Opera ); - X.Dom.Event.Rename[ 'transitionend' ] = 'oTransitionEnd'; + X_Event_Rename[ 'transitionend' ] = 'oTransitionEnd'; } else { console.log( 'transitionend <= otransitionEnd|ver.' + X.UA.Opera ); - X.Dom.Event.Rename[ 'transitionend' ] = 'otransitionEnd'; + X_Event_Rename[ 'transitionend' ] = 'otransitionEnd'; }; } else if( window.onmoztransitionend !== undefined && window.ontransitionend === undefined ){ console.log( 'transitionend <= mozTransitionEnd' ); - X.Dom.Event.Rename[ 'transitionend' ] = 'mozTransitionEnd'; + X_Event_Rename[ 'transitionend' ] = 'mozTransitionEnd'; }; if( !navigator.pointerEnabled ){ if( navigator.msPointerEnabled ){ console.log( 'pointerdown <= MSPointerDown' ); - X.Dom.Event.Rename[ 'pointerdown' ] = 'MSPointerDown'; - X.Dom.Event.Rename[ 'pointerup' ] = 'MSPointerUp'; - X.Dom.Event.Rename[ 'pointermove' ] = [ 'MSPointerMove', 'MSPointerHover' ];// ie10 と ie11 でペンのhoverevent の値が異なる - X.Dom.Event.Rename[ 'pointercancel' ] = 'MSPointerCancel'; + X_Event_Rename[ 'pointerdown' ] = 'MSPointerDown'; + X_Event_Rename[ 'pointerup' ] = 'MSPointerUp'; + X_Event_Rename[ 'pointermove' ] = [ 'MSPointerMove', 'MSPointerHover' ];// ie10 と ie11 でペンのhoverevent の値が異なる + X_Event_Rename[ 'pointercancel' ] = 'MSPointerCancel'; // http://msdn.microsoft.com/ja-jp/library/ie/dn304886%28v=vs.85%29.aspx } else if( X_UA_HID.TOUCH ){ - X.Dom.Event.Rename[ 'pointerdown' ] = [ 'touchdown', 'mousedown' ]; - 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_Event_Rename[ 'pointerdown' ] = [ 'touchdown', 'mousedown' ]; + X_Event_Rename[ 'pointerup' ] = [ 'touchup', 'mouseup' ]; + X_Event_Rename[ 'pointermove' ] = [ 'touchmove', 'mousemove' ]; + X_Event_Rename[ 'pointercancel' ] = 'touchcancel'; + // X_Event_Rename[ 'click' ] = [ 'click', 'tap' ]; // ループになってしまう!直した! } else { - X.Dom.Event.Rename[ 'pointerdown' ] = 'mousedown'; - X.Dom.Event.Rename[ 'pointerup' ] = 'mouseup'; - X.Dom.Event.Rename[ 'pointermove' ] = 'mousemove'; - X.Dom.Event.Rename[ 'pointercancel' ] = 'mouseleave';//?? - // Opera - // X.Dom.Event.Rename[ 'contextmenu' ] = 'mousedown'; button==2 の場合 + X_Event_Rename[ 'pointerdown' ] = 'mousedown'; + X_Event_Rename[ 'pointerup' ] = 'mouseup'; + X_Event_Rename[ 'pointermove' ] = 'mousemove'; + X_Event_Rename[ 'pointercancel' ] = 'mouseleave';//?? + + // Opera は ブラウザ設定から右クリックの通知を許可すると mousedown で e.button==2 が返る,キャンセルは可能?? + X.UA.Opera && ( + X_Event_Rename[ 'contextmenu' ] = 'mousedown' ); }; }; - -(function( rename, renameTo ){ - var k, name, i; - for( k in rename ){ - name = rename[ k ]; - if( X.Type.isArray( name ) ){ - for( i = name.length; i; ){ - renameTo[ name[ --i ] ] = k; - }; - } else { - renameTo[ name ] = k; - }; - }; -})( X.Dom.Event.Rename, X.Dom.Event.RenameTo ); - - /* ----------------------------------------------- * Document Ready * Dean Edwards/Matthias Miller/John Resig @@ -511,10 +479,4 @@ if( X.UA.WebKit || X.UA.Safari < 3 ){ // sniff /* for other browsers */ Node._window.listenOnce( 'load', X_TEMP.onDomContentLoaded ); -// -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/09_XDomParser.js b/0.6.x/js/02_dom/09_XDomParser.js index d4030e2..af11c4b 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 @@ * */ -var X_Dom_Parser = { +var X_Dom_Parser = { // HTMLParser 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, @@ -305,17 +305,17 @@ var X_Dom_Parser = { }; -X.Dom._htmlStringToXNode = { +var X_HTMLParser_htmlStringToXNode = { flat : null, nest : [], err : function( html ){ - X.Dom._htmlStringToXNode.flat.length = 0; - X.Dom._htmlStringToXNode.ignoreError !== true && X.Logger.warn( 'X_Dom_Parser() error ' + html ); + X_HTMLParser_htmlStringToXNode.flat.length = 0; + X_HTMLParser_htmlStringToXNode.ignoreError !== true && X.Logger.warn( 'X_Dom_Parser() error ' + html ); }, start : function( tagName, attrs, noChild, length ){ var xnode, - nest = X.Dom._htmlStringToXNode.nest, - flat = X.Dom._htmlStringToXNode.flat, + nest = X_HTMLParser_htmlStringToXNode.nest, + flat = X_HTMLParser_htmlStringToXNode.flat, l = nest.length, attr, name, i, _attrs; //, toIndex; if( l ){ @@ -328,7 +328,7 @@ X.Dom._htmlStringToXNode = { _attrs = {}; for( ; i; ){ if( attr = attrs[ --i ] ){ - if( typeof attr === 'string' ){ + if( X.Type.isString( attr ) ){ name = attr; _attrs[ name ] = true; } else { @@ -341,20 +341,20 @@ X.Dom._htmlStringToXNode = { }; }, end : function(){ - 0 < X.Dom._htmlStringToXNode.nest.length && ( --X.Dom._htmlStringToXNode.nest.length ); + 0 < X_HTMLParser_htmlStringToXNode.nest.length && ( --X_HTMLParser_htmlStringToXNode.nest.length ); }, chars : function( text ){ - if( X.Dom._htmlStringToXNode.nest.length ){ - X.Dom._htmlStringToXNode.nest[ X.Dom._htmlStringToXNode.nest.length - 1 ].createText( text ); + if( X_HTMLParser_htmlStringToXNode.nest.length ){ + X_HTMLParser_htmlStringToXNode.nest[ X_HTMLParser_htmlStringToXNode.nest.length - 1 ].createText( text ); } else { - X.Dom._htmlStringToXNode.flat[ X.Dom._htmlStringToXNode.flat.length ] = X.Dom.Node.createText( text ); + X_HTMLParser_htmlStringToXNode.flat[ X_HTMLParser_htmlStringToXNode.flat.length ] = X.Dom.Node.createText( text ); }; }, comment : X.emptyFunction }; -X.Dom.parse = function( html, ignoreError ){ - var worker = X.Dom._htmlStringToXNode, ret; +function X_HtmlParser_parse( html, ignoreError ){ + var worker = X_HTMLParser_htmlStringToXNode, ret; worker.flat = []; worker.nest.length = 0; worker.ignoreError = ignoreError; @@ -364,29 +364,29 @@ X.Dom.parse = function( html, ignoreError ){ return ret; }; -X.Dom._asyncHtmlStringToXNode = { +var X_HTMLParser_asyncHtmlStringToXNode = { err : function( html ){ - X.Dom._htmlStringToXNode.err( html ); - this.asyncDispatch( 0, { type : X.Event.ERROR } ); + X_HTMLParser_htmlStringToXNode.err( html ); + this.asyncDispatch( X.Event.ERROR ); }, - start : X.Dom._htmlStringToXNode.start, - end : X.Dom._htmlStringToXNode.end, - chars : X.Dom._htmlStringToXNode.chars, + start : X_HTMLParser_htmlStringToXNode.start, + end : X_HTMLParser_htmlStringToXNode.end, + chars : X_HTMLParser_htmlStringToXNode.chars, comment : X.emptyFunction, progress : function( pct ){ - this.asyncDispatch( 0, { type : X.Event.PROGRESS, percent : pct } ); + this.asyncDispatch( { type : X.Event.PROGRESS, percent : pct } ); }, complete : function(){ - var ret = X.Dom._htmlStringToXNode.flat; - delete X.Dom._htmlStringToXNode.flat; - this.asyncDispatch( 0, { type : X.Event.SUCCESS, xnodes : ret } ); + var ret = X_HTMLParser_htmlStringToXNode.flat; + delete X_HTMLParser_htmlStringToXNode.flat; + this.asyncDispatch( { type : X.Event.SUCCESS, xnodes : ret } ); } }; -X.Dom.asyncParse = function( html, ignoreError ){ - var dispatcher = X.Class._override( new X.EventDispatcher(), X.Dom._asyncHtmlStringToXNode ), - worker = X.Dom._htmlStringToXNode; +function X_HTMLParser_asyncParse( html, ignoreError ){ + var dispatcher = X.Class._override( new X.EventDispatcher(), X_HTMLParser_asyncHtmlStringToXNode ), + worker = X_HTMLParser_htmlStringToXNode; dispatcher.listenOnce( X.Event.SUCCESS, dispatcher, dispatcher.kill ); worker.flat = []; worker.nest.length = 0; diff --git a/0.6.x/js/02_dom/20_XDomImage.js b/0.6.x/js/02_dom/20_XDomImage.js index 1ab2830..b59c8d4 100644 --- a/0.6.x/js/02_dom/20_XDomImage.js +++ b/0.6.x/js/02_dom/20_XDomImage.js @@ -128,7 +128,7 @@ X.Dom.Image = { case 'abort' : if( this.finish ) return; this.finish = true; - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR } ); break; case 'load' : // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 @@ -136,11 +136,11 @@ X.Dom.Image = { this.finish = true; this.timerID && X.Timer.remove( this.timerID ); if( window.opera && !this.xnode._rawObject.complete ){ - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR } ); return; }; size = X.Dom.Image.getActualDimension( X.UA.IE < 9 ? this.abspath : this.xnode ); - this.timerID = this.asyncDispatch( 0, { + this.timerID = this.asyncDispatch( { type : X.Event.SUCCESS, src : this.abspath, w : size[ 0 ], @@ -164,12 +164,12 @@ X.Dom.Image = { if( this.xnode._rawObject && this.xnode._rawObject.complete ){ this.finish = true; if( this.xnode._rawObject.width ) return; - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR } ); return; }; if( ( this.tick += this.delay ) > this.timeout ){ this.finish = true; - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR, msg : 'timeout' } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR, msg : 'timeout' } ); return; }; this.timerID = X.Timer.once( this.delay, this, this._detect ); diff --git a/0.6.x/js/02_dom/22_XDomBuilder.js b/0.6.x/js/02_dom/22_XDomBuilder.js index efa4a8d..fe25591 100644 --- a/0.6.x/js/02_dom/22_XDomBuilder.js +++ b/0.6.x/js/02_dom/22_XDomBuilder.js @@ -112,6 +112,9 @@ X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, body = r._rawObject, copy, i, l, node, html, elmProgress; + + if( !X_TEMP.X_Dom_useBuilder ) return; + // TODO // textarea の内容を控えて、消す。xnode tree 構築後に復帰。でないと、html パースでこける //X.UA.MacIE && alert( body.innerHTML ); @@ -188,7 +191,7 @@ X.Dom.listenOnce( X_TEMP.SYSTEM_EVENT_PRE_INIT, elmProgress.style.cssText = 'position:absolute;top:0;left:0;z-index:9999;width:0;height:0.5em;background:#00f;overflow:hidden;'; elmProgress.setAttribute( 'style', 'position:absolute;top:0;left:0;z-index:9999;width:0;height:0.5em;background:#00f;overflow:hidden;' ); - X.Dom.asyncParse( html, true ) + X_HTMLParser_asyncParse( html, true ) .listen( X.Event.PROGRESS, function(e){ elmProgress.style.width = ( e.percent * 100 | 0 ) + '%'; @@ -210,6 +213,9 @@ X_UA_DOM.IE4 ? elmProgress = '_xdom_builder_progress', html; + + if( !X_TEMP.X_Dom_useBuilder ) return; + /* * http://support.microsoft.com/kb/812417/ja * PRB: outerHTML の HTML 要素のプロパティは、既定の属性は表示されません。 @@ -220,7 +226,7 @@ X_UA_DOM.IE4 ? body.insertAdjacentHTML( 'BeforeEnd', '
' ); elmProgress = document.all[ elmProgress ]; - X.Dom.asyncParse( html, true ) + X_HTMLParser_asyncParse( html, true ) .listen( X.Event.PROGRESS, function( e ){ elmProgress.style.width = ( e.percent * 100 | 0 ) + '%'; @@ -304,6 +310,7 @@ X_TEMP.asyncCreateTree = function ( parent, elems, elmProgress, async ){ delete X_TEMP.asyncCreateTree; delete X_TEMP.bindElementToXnode; delete X_TEMP.X_Dom_useBuilder; + delete X_TEMP._isCleanupTarget; }; X_TEMP.bindElementToXnode = diff --git a/0.6.x/js/04_util/01_XNinjaIframe.js b/0.6.x/js/04_util/01_XNinjaIframe.js index cdcc24e..c0d9871 100644 --- a/0.6.x/js/04_util/01_XNinjaIframe.js +++ b/0.6.x/js/04_util/01_XNinjaIframe.js @@ -75,10 +75,10 @@ X.Util.NinjaIframe = X.EventDispatcher.inherits( // onload case 'load' : console.log( 'iframe load.' ); - this.asyncDispatch( 0, X.Event.SUCCESS ); + this.asyncDispatch( X.Event.SUCCESS ); break; case 'error' : - this.asyncDispatch( 0, X.Event.ERROR ); + this.asyncDispatch( X.Event.ERROR ); break; }; diff --git a/0.6.x/js/05_net/00_XNet.js b/0.6.x/js/05_net/00_XNet.js index 71c3172..5586e4e 100644 --- a/0.6.x/js/05_net/00_XNet.js +++ b/0.6.x/js/05_net/00_XNet.js @@ -84,7 +84,7 @@ var X_NET_TYPE_XHR = 1, var i = X_NET_QUEUE_LIST.indexOf( this ); if( i !== -1 ){ X_NET_QUEUE_LIST.splice( i, 1 ); - this.asyncDispatch( 0, { type : X.Event.CANCELED } ); + this.asyncDispatch( { type : X.Event.CANCELED } ); } else if( this === X_NET_currentQueue ){ X_NET_currentWrapper.cancel(); @@ -111,7 +111,7 @@ function X_NET_proxyDispatch( e ){ case X.Event.CANCELED : console.log( 'q: ' + e.type ); this.dispatch( e ); - this.asyncDispatch( 0, { type : X.Event.COMPLETE } ); + this.asyncDispatch( { type : X.Event.COMPLETE } ); break; case X.Event.COMPLETE : console.log( 'complete. then kill()' ); diff --git a/0.6.x/js/05_net/01_XNetXHR.js b/0.6.x/js/05_net/01_XNetXHR.js index 5a657f6..8121fe5 100644 --- a/0.6.x/js/05_net/01_XNetXHR.js +++ b/0.6.x/js/05_net/01_XNetXHR.js @@ -185,10 +185,10 @@ if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){ case 1 : return; case 2 : // 0% ajaxstart - live && this.asyncDispatch( 0, { type : X.Event.PROGRESS, percent : 0 } ); + live && this.asyncDispatch( { type : X.Event.PROGRESS, percent : 0 } ); return; case 3 : - live && this.asyncDispatch( 0, { type : X.Event.PROGRESS, percent : this._percent < 99.9 ? 99.9 : ( this._percent + 100 ) / 2 } ); + live && this.asyncDispatch( { type : X.Event.PROGRESS, percent : this._percent < 99.9 ? 99.9 : ( this._percent + 100 ) / 2 } ); // 99.9% return; case 4 : @@ -246,9 +246,9 @@ if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){ break; }; - this.asyncDispatch( 0, { type : X.Event.SUCCESS, status : status || 200, data : data } ); + this.asyncDispatch( { type : X.Event.SUCCESS, status : status || 200, data : data } ); } else { - live && this.asyncDispatch( 0, { type : X.Event.ERROR, status : raw.status || 0, percent : 100 } ); + live && this.asyncDispatch( { type : X.Event.ERROR, status : raw.status || 0, percent : 100 } ); }; break; @@ -256,23 +256,23 @@ if( X_Net_XHR_W3C || X_Net_XHR_ACTIVE_X ){ // TODO X.Dom.Event でコピーしていないのでまだ動かない、、、 if( e.lengthComputable ){ this._percent = e.loaded / e.total; - live && this.asyncDispatch( 0, { type : X.Event.PROGRESS, percent : this._percent } ); + live && this.asyncDispatch( { type : X.Event.PROGRESS, percent : this._percent } ); }; break; case 'error' : //console.dir( e ); this._busy = false; - live && this.asyncDispatch( 0, { type : X.Event.ERROR, status : raw.status } ); + live && this.asyncDispatch( { type : X.Event.ERROR, status : raw.status } ); break; //case 'abort' : // this._busy = false; - // this.asyncDispatch( 0, { type : X.Event.ERROR, status : raw.status } ); + // this.asyncDispatch( { type : X.Event.ERROR, status : raw.status } ); // break; case 'timeout' : // Gecko 12.0 https://developer.mozilla.org/ja/docs/XMLHttpRequest/Synchronous_and_Asynchronous_Requests this._busy = false; - live && this.asyncDispatch( 0, { type : X.Event.ERROR, status : raw.status } ); + live && this.asyncDispatch( { type : X.Event.ERROR, status : raw.status } ); break; }; }, diff --git a/0.6.x/js/05_net/04_XNetImage.js b/0.6.x/js/05_net/04_XNetImage.js index 94eae12..84d200d 100644 --- a/0.6.x/js/05_net/04_XNetImage.js +++ b/0.6.x/js/05_net/04_XNetImage.js @@ -7,7 +7,7 @@ */ var X_Net_Image_hasImage = !!window[ 'Image' ], - X_Net_Image_image = X_Net_Image_hasImage && new window[ 'Image' ](), + X_Net_Image_image = X_Net_Image_hasImage && new Image(), X_Net_Image_isElement = X.Type.isHTMLElement( X_Net_Image_image ); @@ -60,7 +60,7 @@ X_NET_ImageWrapper = ( !X_Net_Image_isElement ? X.EventDispatcher : X.Dom.Node ) if( this.finish ) return; this.finish = true; this.timerID && X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR } ); break; case 'load' : // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 @@ -68,11 +68,11 @@ X_NET_ImageWrapper = ( !X_Net_Image_isElement ? X.EventDispatcher : X.Dom.Node ) this.finish = true; this.timerID && X.Timer.remove( this.timerID ); if( X.UA.Opera && !this._rawObject.complete ){ - this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); + this.timerID = this.asyncDispatch( { type : X.Event.ERROR } ); return; }; size = X.Dom.Image.getActualDimension( !X_Net_Image_isElement ? this.abspath : this ); - this.timerID = this.asyncDispatch( 0, { + this.timerID = this.asyncDispatch( { type : X.Event.SUCCESS, src : this.abspath, w : size[ 0 ], @@ -83,7 +83,7 @@ X_NET_ImageWrapper = ( !X_Net_Image_isElement ? X.EventDispatcher : X.Dom.Node ) case X.Event.ERROR : case X.Event.TIMEOUT : this.timerID && X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( 0, X.Event.COMPLETE ); + this.timerID = this.asyncDispatch( X.Event.COMPLETE ); break; case X.Event.KILL_INSTANCE : this.reset(); @@ -98,12 +98,12 @@ X_NET_ImageWrapper = ( !X_Net_Image_isElement ? X.EventDispatcher : X.Dom.Node ) this.finish = true; if( this._rawObject.width ) return; X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( 0, X.Event.ERROR ); + this.timerID = this.asyncDispatch( X.Event.ERROR ); } else if( this.timeout < ( this.tick += this.delay ) ){ this.finish = true; X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( 0, X.Event.TIMEOUT ); + this.timerID = this.asyncDispatch( X.Event.TIMEOUT ); }; }, cancel : function(){ diff --git a/0.6.x/js/06_audio/01_XHTML5Audio.js b/0.6.x/js/06_audio/01_XHTML5Audio.js index 6a282dc..e6d9ad6 100644 --- a/0.6.x/js/06_audio/01_XHTML5Audio.js +++ b/0.6.x/js/06_audio/01_XHTML5Audio.js @@ -79,7 +79,7 @@ if( window.HTMLAudioElement ){ ok = X_Audio_rawAudio.canPlayType( mineType ); }; - this.asyncDispatch( 0, ok ? 'support' : 'nosupport' ); + this.asyncDispatch( ok ? 'support' : 'nosupport' ); return this; }, diff --git a/0.6.x/js/06_audio/02_XSilverlightAudio.js b/0.6.x/js/06_audio/02_XSilverlightAudio.js index 13b499e..dfddccb 100644 --- a/0.6.x/js/06_audio/02_XSilverlightAudio.js +++ b/0.6.x/js/06_audio/02_XSilverlightAudio.js @@ -34,7 +34,7 @@ if( X.Pulgin.SilverlightEnabled ){ detect : function( source, ext ){ var ok = ext === 'mp3' || ext === 'wma'; - this.asyncDispatch( 0, ok ? 'support' : 'nosupport' ); + this.asyncDispatch( ok ? 'support' : 'nosupport' ); return this; }, @@ -165,7 +165,7 @@ if( X.Pulgin.SilverlightEnabled ){ this._callback.kill(); delete this._callback; - if( sender.findName('media') ) alert( 'exist' ); + //if( sender.findName('media') ) alert( 'exist' ); sender.children.add( sender.GetHost(). diff --git a/0.6.x/js/20_ui/04_XUI_Event.js b/0.6.x/js/20_ui/04_XUI_Event.js index 05b40d5..1f1c85f 100644 --- a/0.6.x/js/20_ui/04_XUI_Event.js +++ b/0.6.x/js/20_ui/04_XUI_Event.js @@ -1,18 +1,18 @@ X.UI.Event = { - INIT : ++X.Dom.Event._LAST_EVENT, - ADDED : ++X.Dom.Event._LAST_EVENT, - CREATION_COMPLETE : ++X.Dom.Event._LAST_EVENT, - REMOVED : ++X.Dom.Event._LAST_EVENT, + INIT : ++X_Event_last, + ADDED : ++X_Event_last, + CREATION_COMPLETE : ++X_Event_last, + REMOVED : ++X_Event_last, // http://d.hatena.ne.jp/edvakf/20100205/1265338487 // http://d.hatena.ne.jp/uupaa/20100401/1270097629 - ENTER_VIEW : ++X.Dom.Event._LAST_EVENT, // 要素が視界に入った - OUT_VIEW : ++X.Dom.Event._LAST_EVENT, + ENTER_VIEW : ++X_Event_last, // 要素が視界に入った + OUT_VIEW : ++X_Event_last, - POINTER_OUT : ++X.Dom.Event._LAST_EVENT, - POINTER_IN : ++X.Dom.Event._LAST_EVENT, + POINTER_OUT : ++X_Event_last, + POINTER_IN : ++X_Event_last, // FOCUS // DISABLED @@ -20,106 +20,106 @@ X.UI.Event = { // BASE_FONT_SIZE_CHANGE /* -- Pointing Device Event -- */ - _START_POINTER : X.Dom.Event._LAST_EVENT + 0.5, + _START_POINTER : X_Event_last + 0.5, - CONTEXT_MENU : ++X.Dom.Event._LAST_EVENT, // rightclick or longtouch or menukey or ctrl + click + CONTEXT_MENU : ++X_Event_last, // rightclick or longtouch or menukey or ctrl + click /* -- ここよりあとはノード上をバブルアップ -- */ - _START_BUBLEUP : X.Dom.Event._LAST_EVENT + 0.5, + _START_BUBLEUP : X_Event_last + 0.5, // raw pointing device event - _POINTER_DOWN : ++X.Dom.Event._LAST_EVENT, - _POINTER_UP : ++X.Dom.Event._LAST_EVENT, - _POINTER_MOVE : ++X.Dom.Event._LAST_EVENT, - _POINTER_CANCEL : ++X.Dom.Event._LAST_EVENT, - _TOUCH_START : ++X.Dom.Event._LAST_EVENT, - _TOUCH_END : ++X.Dom.Event._LAST_EVENT, - _TOUCH_MOVE : ++X.Dom.Event._LAST_EVENT, - _TOUCH_CANCEL : ++X.Dom.Event._LAST_EVENT, - _MOUSE_DOWN : ++X.Dom.Event._LAST_EVENT, - _MOUSE_UP : ++X.Dom.Event._LAST_EVENT, - _MOUSE_MOVE : ++X.Dom.Event._LAST_EVENT, - _MOUSE_CANCEL : ++X.Dom.Event._LAST_EVENT, + _POINTER_DOWN : ++X_Event_last, + _POINTER_UP : ++X_Event_last, + _POINTER_MOVE : ++X_Event_last, + _POINTER_CANCEL : ++X_Event_last, + _TOUCH_START : ++X_Event_last, + _TOUCH_END : ++X_Event_last, + _TOUCH_MOVE : ++X_Event_last, + _TOUCH_CANCEL : ++X_Event_last, + _MOUSE_DOWN : ++X_Event_last, + _MOUSE_UP : ++X_Event_last, + _MOUSE_MOVE : ++X_Event_last, + _MOUSE_CANCEL : ++X_Event_last, - FILE_DRAG : ++X.Dom.Event._LAST_EVENT, - FILE_DRAG_START : ++X.Dom.Event._LAST_EVENT, - FILE_DRAG_END : ++X.Dom.Event._LAST_EVENT, - FILE_HOLD : ++X.Dom.Event._LAST_EVENT, - FILE_HOLD_END : ++X.Dom.Event._LAST_EVENT, - FILE_DROP_BEFORE : ++X.Dom.Event._LAST_EVENT, - FILE_DROP : ++X.Dom.Event._LAST_EVENT, - FILE_DROP_CANCEL : ++X.Dom.Event._LAST_EVENT, + FILE_DRAG : ++X_Event_last, + FILE_DRAG_START : ++X_Event_last, + FILE_DRAG_END : ++X_Event_last, + FILE_HOLD : ++X_Event_last, + FILE_HOLD_END : ++X_Event_last, + FILE_DROP_BEFORE : ++X_Event_last, + FILE_DROP : ++X_Event_last, + FILE_DROP_CANCEL : ++X_Event_last, /* -- ここより後は X.UI 用のイベント -- */ - _START_XUI_EVENT : X.Dom.Event._LAST_EVENT + 0.5, + _START_XUI_EVENT : X_Event_last + 0.5, /* -- Mouse & Floating touch(Xperia sola)?? -- */ - HOVER_MOVE : ++X.Dom.Event._LAST_EVENT, - HOVER_STAY : ++X.Dom.Event._LAST_EVENT, - HOVER_STAY_END : ++X.Dom.Event._LAST_EVENT, - WHEEL : ++X.Dom.Event._LAST_EVENT, + HOVER_MOVE : ++X_Event_last, + HOVER_STAY : ++X_Event_last, + HOVER_STAY_END : ++X_Event_last, + WHEEL : ++X_Event_last, /* -- Gesuture Event -- */ - HOLD : ++X.Dom.Event._LAST_EVENT, - HOLD_END : ++X.Dom.Event._LAST_EVENT, - TAP : ++X.Dom.Event._LAST_EVENT, - DOUBLE_TAP : ++X.Dom.Event._LAST_EVENT, - DRAG : ++X.Dom.Event._LAST_EVENT, - DRAG_START : ++X.Dom.Event._LAST_EVENT, - DRAG_END : ++X.Dom.Event._LAST_EVENT, - DRAG_UP : ++X.Dom.Event._LAST_EVENT, - DRAG_RIGHT : ++X.Dom.Event._LAST_EVENT, - DRAG_LEFT : ++X.Dom.Event._LAST_EVENT, - DRAG_DOWN : ++X.Dom.Event._LAST_EVENT, - SWIP : ++X.Dom.Event._LAST_EVENT, - SWIP_UP : ++X.Dom.Event._LAST_EVENT, - SWIP_RIGHT : ++X.Dom.Event._LAST_EVENT, - SWIP_LEFT : ++X.Dom.Event._LAST_EVENT, - SWIP_DOWN : ++X.Dom.Event._LAST_EVENT, - TRANSFORM : ++X.Dom.Event._LAST_EVENT, - TRANSFORM_START : ++X.Dom.Event._LAST_EVENT, - TRANSFORM_END : ++X.Dom.Event._LAST_EVENT, - PINCH : ++X.Dom.Event._LAST_EVENT, - PINCH_IN : ++X.Dom.Event._LAST_EVENT, - PINCH_OUT : ++X.Dom.Event._LAST_EVENT, - ROTATE : ++X.Dom.Event._LAST_EVENT, + HOLD : ++X_Event_last, + HOLD_END : ++X_Event_last, + TAP : ++X_Event_last, + DOUBLE_TAP : ++X_Event_last, + DRAG : ++X_Event_last, + DRAG_START : ++X_Event_last, + DRAG_END : ++X_Event_last, + DRAG_UP : ++X_Event_last, + DRAG_RIGHT : ++X_Event_last, + DRAG_LEFT : ++X_Event_last, + DRAG_DOWN : ++X_Event_last, + SWIP : ++X_Event_last, + SWIP_UP : ++X_Event_last, + SWIP_RIGHT : ++X_Event_last, + SWIP_LEFT : ++X_Event_last, + SWIP_DOWN : ++X_Event_last, + TRANSFORM : ++X_Event_last, + TRANSFORM_START : ++X_Event_last, + TRANSFORM_END : ++X_Event_last, + PINCH : ++X_Event_last, + PINCH_IN : ++X_Event_last, + PINCH_OUT : ++X_Event_last, + ROTATE : ++X_Event_last, - _END_XUI_EVENT : X.Dom.Event._LAST_EVENT + 0.5, + _END_XUI_EVENT : X_Event_last + 0.5, - _END_POINTER : X.Dom.Event._LAST_EVENT + 0.5, + _END_POINTER : X_Event_last + 0.5, /* -- Pointing Device Event -- */ - KEY_DOWN : ++X.Dom.Event._LAST_EVENT, - KEY_UP : ++X.Dom.Event._LAST_EVENT, - KEY_HOLD : ++X.Dom.Event._LAST_EVENT, - KEY_CANCEL : ++X.Dom.Event._LAST_EVENT, + KEY_DOWN : ++X_Event_last, + KEY_UP : ++X_Event_last, + KEY_HOLD : ++X_Event_last, + KEY_CANCEL : ++X_Event_last, - SCROLL_BEFORE_START : ++X.Dom.Event._LAST_EVENT, // cancelable - SCROLL_START : ++X.Dom.Event._LAST_EVENT, - SCROLL_BEFORE_MOVE : ++X.Dom.Event._LAST_EVENT, - SCROLL_MOVE : ++X.Dom.Event._LAST_EVENT, - SCROLL_END : ++X.Dom.Event._LAST_EVENT, - SCROLL_REFRESH : ++X.Dom.Event._LAST_EVENT, + SCROLL_BEFORE_START : ++X_Event_last, // cancelable + SCROLL_START : ++X_Event_last, + SCROLL_BEFORE_MOVE : ++X_Event_last, + SCROLL_MOVE : ++X_Event_last, + SCROLL_END : ++X_Event_last, + SCROLL_REFRESH : ++X_Event_last, - ANIME_BEFORE_START : ++X.Dom.Event._LAST_EVENT, - ANIME_START : ++X.Dom.Event._LAST_EVENT, - ANIME : ++X.Dom.Event._LAST_EVENT, - ANIME_END : ++X.Dom.Event._LAST_EVENT, - ANIME_BEFORE_STOP : ++X.Dom.Event._LAST_EVENT, // before cancel - ANIME_STOP : ++X.Dom.Event._LAST_EVENT, + ANIME_BEFORE_START : ++X_Event_last, + ANIME_START : ++X_Event_last, + ANIME : ++X_Event_last, + ANIME_END : ++X_Event_last, + ANIME_BEFORE_STOP : ++X_Event_last, // before cancel + ANIME_STOP : ++X_Event_last, - PAGE_BEFORE_SHOW : ++X.Dom.Event._LAST_EVENT, - PAGE_SHOW : ++X.Dom.Event._LAST_EVENT, - PAGE_AFTER_SHOW : ++X.Dom.Event._LAST_EVENT, - PAGE_BEFORE_HIDE : ++X.Dom.Event._LAST_EVENT, - PAGE_HIDE : ++X.Dom.Event._LAST_EVENT, - PAGE_AFTER_HIDE : ++X.Dom.Event._LAST_EVENT, + PAGE_BEFORE_SHOW : ++X_Event_last, + PAGE_SHOW : ++X_Event_last, + PAGE_AFTER_SHOW : ++X_Event_last, + PAGE_BEFORE_HIDE : ++X_Event_last, + PAGE_HIDE : ++X_Event_last, + PAGE_AFTER_HIDE : ++X_Event_last, // X.UI.Form - CHANGE : ++X.Dom.Event._LAST_EVENT, - SUBMIT : ++X.Dom.Event._LAST_EVENT, - SELECT : ++X.Dom.Event._LAST_EVENT, // click or tap or enterkey + CHANGE : ++X_Event_last, + SUBMIT : ++X_Event_last, + SELECT : ++X_Event_last, // click or tap or enterkey IdToName : {}, NameToID : {} diff --git a/0.6.x/js/20_ui/17_Text.js b/0.6.x/js/20_ui/17_Text.js index 10624d7..3e93b97 100644 --- a/0.6.x/js/20_ui/17_Text.js +++ b/0.6.x/js/20_ui/17_Text.js @@ -5,8 +5,8 @@ X.UI._Text = X.UI._AbstractUINode.inherits( content : null, Constructor : function( content ){ - if( !( this.User.instanceOf( Text ) ) ){ - //throw new Error( 'Text を継承したインスタンスだけが _Text のオーナーになれます' ); + if( !( this.User.instanceOf( X.UI.Text ) ) ){ + alert( 'Text を継承したインスタンスだけが _Text のオーナーになれます' ); }; this.xnode = X.Dom.Node.create( 'div' ); diff --git a/0.6.x/js/import.js b/0.6.x/js/import.js index 5d820a3..c87e1d3 100644 --- a/0.6.x/js/import.js +++ b/0.6.x/js/import.js @@ -1,4 +1,4 @@ -document.write( [ +document.write( [ '