X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F15_XEventDispatcher.js;fp=0.6.x%2Fjs%2F01_core%2F13_XEventDispatcher.js;h=4ee48a8a9767389a7a4144476276e43c10e6a7f9;hb=24f935c7a129b0a00d800e4983da6491a913aeef;hp=27649dbd8c6c46605ab1aab972b5ac39d0e9e3cd;hpb=b722f049986136ce6f382557104f2ea9aabf797b;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_core/13_XEventDispatcher.js b/0.6.x/js/01_core/15_XEventDispatcher.js similarity index 91% rename from 0.6.x/js/01_core/13_XEventDispatcher.js rename to 0.6.x/js/01_core/15_XEventDispatcher.js index 27649db..4ee48a8 100644 --- a/0.6.x/js/01_core/13_XEventDispatcher.js +++ b/0.6.x/js/01_core/15_XEventDispatcher.js @@ -23,7 +23,6 @@ * * @class __Listeners__ * @private - * @abstract */ var X_Listeners_; @@ -39,7 +38,6 @@ var /** @const */ X_LISTENERS_KILL_RESERVED = 4; // X.Event ã§ãã¤ãã³ãIDã 5 ããå§ãã¦ããã®ã§æ³¨æã - // ------------------------------------------------------------------------- // // ------------ local variables -------------------------------------------- // // ------------------------------------------------------------------------- // @@ -65,27 +63,15 @@ var X_EventDispatcher_once = false, // ------------------------------------------------------------------------- // /** + *
ãºã£ããR ãã¬ã¼ã ã¯ã¼ã¯ã®ç¹å¾´ã§ããã¤ãã³ããªã¹ãã®ä½æ³ã¯æ¬¡ã®è¨äºã§è©³ãã解説ãã¦ãã¾ãã + * ãºã£ããRãã¬ã¼ã ã¯ã¼ã¯ã®ã³ã¼ã«ããã¯ã®ãä½æ³ + * *
EventListener ãã¤ãã³ãå¦çä¸ã« EventTarget ã«è¿½å ãããå ´åããããç¾å¨ã®ã¢ã¯ã·ã§ã³ã«ãã£ã¦å®è¡ããããã¨ã¯ããã¾ããããæµ®ä¸ãã§ã¼ãºã®ããã«ãå¾ã®æ®µéã®ã¤ãã³ãããã¼ã§å®è¡ãããããããã¾ããã - *
ã¤ãã³ããªã¹ãã¼ã ã¤ãã³ããå¦çä¸ã§ããã¤ãã³ãã¿ã¼ã²ããããåé¤ãããå ´åãç¾å¨ã®ã¢ã¯ã·ã§ã³ã«ãã£ã¦ãã®ã¤ãã³ããªã¹ãã¼ãå®è¡ããããã¨ã¯ããã¾ããã - *
ã¤ãã³ããªã¹ãã¼ã¯ã決ãã¦åé¤ãããå¾ã«å®è¡ããããã¨ã¯ããã¾ããã - *
ã¤ãã³ãã¿ã¼ã²ããä¸ã«ããç¾å¨ã®ã©ã®ã¤ãã³ããªã¹ãã¼ãæå®ãã¦ããªãå¼æ°ä»ãã® removeEventListener ã¯ãä½ã®å¹æãããã¾ããã - *
listen, unlisten, dispatch ã¨ãã addEventListener, removeEventListener, dispatchEvent ã«å¯¾å¿ããé¢æ°ãæã¡ã¾ãã * ã¾ã listening ã¨ãã ActionScript3 ã® hasEventListener ã«ç¸å½ããé¢æ°ãæã¡ã¾ãã * @@ -123,7 +109,7 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] = * Arrayã«ã¯ã{kind:種é¡,context:ã³ã³ããã¹ã(thisObject),func:ã³ã¼ã«ããã¯é¢æ°,supplement:ãµããªã¡ã³ãããå¼æ°ã®é å} ã¨ããããã·ã¥ãã¾ãã¯é¢æ°ãèãããã¦ãã¾ãã * * @private - * @type {__X_EventDispatcher_Listeners__} + * @type {__Listeners__} */ '_listeners' : null, @@ -205,12 +191,12 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] = if( ( unlistens = listeners[ X_LISTENERS_UNLISTENS ] ) && ( unlistens = unlistens[ opt_type ] ) ){ for( i = unlistens.length; i; ){ f = unlistens[ --i ]; - if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.supplement === cbHash.supplement && f.lock === lock ) ) return false; + if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ) return false; }; }; for( i = list.length; i; ){ f = list[ --i ]; - if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.supplement === cbHash.supplement && f.lock === lock ) ){ + if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ){ // index ãè¦æ±ãããå ´åãlock ããã¦ããªããã¾ã㯠unlock ãªã index ãè¿ã return X_EventDispatcher_needsIndex ? i : true; }; @@ -412,7 +398,7 @@ function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){ if( !listeners ) listeners = this[ '_listeners' ] = {}; list = listeners[ type ] || ( listeners[ type ] = [] ); - add && X_EventDispatcher_addEvent( this, type, raw, list ); + add && X_EventDispatcher_actualAddEvent( this, type, raw, list ); f = X_Callback_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this ); list[ list.length ] = f; @@ -480,11 +466,13 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){ ( listeners[ X_LISTENERS_UNLISTENS ][ opt_type ] = [ f ] ); } else { delete f.once; - list.splice( i, 1 ); - if( !list.length ){ - raw = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); + if( list.length !== 1 ){ + list.splice( i, 1 ); + } else { + list.length = 0; + delete listeners[ opt_type ]; - //empty = X_Object_isEmpty( listeners ); + // TODO ã«ã¦ã³ã¿ã¼ empty = true; for( k in listeners ){ @@ -492,9 +480,12 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){ empty = false; break; }; - if( raw && !X_String_isNumberString( '' + opt_type ) ){ // æ°åã¤ãã³ãã®é¤å¤ - X_EventDispatcher_removeEvent( this, opt_type, raw, list, !empty ); + + if( !X_String_isNumberString( '' + opt_type ) ){ // æ°åã¤ãã³ãã®é¤å¤ + raw = this[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( this ); + raw && X_EventDispatcher_actualRemoveEvent( this, opt_type, raw, list, !empty ); }; + if( empty ) delete this[ '_listeners' ]; }; }; @@ -525,7 +516,7 @@ function X_EventDispatcher_unlistenAll( that ){ }; }; -function X_EventDispatcher_addEvent( that, type, raw, list ){ +function X_EventDispatcher_actualAddEvent( that, type, raw, list ){ var i, f; X_EventDispatcher_lock || ( type = X_Event_Rename[ type ] || type ); @@ -638,7 +629,7 @@ function X_EventDispatcher_sliverLightDispatch( sender, e, type ){ return this[ 'dispatch' ]( type ); }; -function X_EventDispatcher_removeEvent( that, type, raw, list, skip ){ +function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){ var i; X_EventDispatcher_unlock || ( type = X_Event_Rename[ type ] || type ); @@ -814,7 +805,7 @@ if( X_UA[ 'WebKit' ] < 525.13 ){ // Safari3- function X_EventDispatcher_toggleAllEvents( that, add ){ var list = that[ '_listeners' ], raw = that[ '_rawObject' ] || X_UA_DOM.IE4 && X_Node__ie4getRawNode( that ), - func = add ? X_EventDispatcher_addEvent : X_EventDispatcher_removeEvent, + func = add ? X_EventDispatcher_actualAddEvent : X_EventDispatcher_actualRemoveEvent, type; if( !list || !raw ) return; for( type in list ){