X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_core%2F15_XEventDispatcher.js;h=5a9864a7c49128ef149c81b9cfc1d2461e8261b8;hb=76ea1040608829b653422cf51b3490801d2ec1fa;hp=4ee48a8a9767389a7a4144476276e43c10e6a7f9;hpb=24f935c7a129b0a00d800e4983da6491a913aeef;p=pettanr%2FclientJs.git
diff --git a/0.6.x/js/01_core/15_XEventDispatcher.js b/0.6.x/js/01_core/15_XEventDispatcher.js
index 4ee48a8..5a9864a 100644
--- a/0.6.x/js/01_core/15_XEventDispatcher.js
+++ b/0.6.x/js/01_core/15_XEventDispatcher.js
@@ -15,7 +15,7 @@
*
dispatch ä¸ãï¼ããã«ã¤ã³ã¹ã¿ã³ã¹èªèº«ã® dispatch ããã¹ãããå ´åããã®æ·±ããè¨æ¶ãã¾ãã
* 2:RESERVES Array
* ã¤ãã³ãçºç«ä¸ã« listen() ãå¼ã°ããå ´åã«å¼æ°ãèããå®äºæ(DISPATCHING===0)ã«å度 listen() ããããã®ä¸æã¹ãã¢ã§ãã
- * 3:UNLISTENS Array
+ * 3:UNLISTENS Object
* ã¤ãã³ãçºç«ä¸ã« unlisten() ãå¼ã°ããå ´åã«å¯¾è±¡ãªã¹ããè¨æ¶ãããªã¹ããå¼ã°ããªãããã«ãã¾ããå®äºæ(DISPATCHING===0)ã«å度 unlisten() ãã¾ãã
* 4:KILL_RESERVED boolean
* dispatch ä¸ã« kill() ãå¼ã°ããå ´åã«ä¸æ¦ kill ããã£ã³ã»ã«ããå®äºæ(DISPATCHING===0)ã«å度 kill() ããããã®ãã©ã°ã§ãã
@@ -26,37 +26,37 @@
*/
var X_Listeners_;
-var /** @const */
- X_LISTENERS_ACTUAL_HANDLER = 0,
- /** @const */
+var X_LISTENERS_ACTUAL_HANDLER = 0,
X_LISTENERS_DISPATCHING = 1,
- /** @const */
X_LISTENERS_RESERVES = 2,
- /** @const */
X_LISTENERS_UNLISTENS = 3,
- /** @const */
X_LISTENERS_KILL_RESERVED = 4; // X.Event ã§ãã¤ãã³ãIDã 5 ããå§ãã¦ããã®ã§æ³¨æã
// ------------------------------------------------------------------------- //
// ------------ local variables -------------------------------------------- //
// ------------------------------------------------------------------------- //
+var X_EventDispatcher_EVENT_TARGET_OTHER = 0,
+ X_EventDispatcher_EVENT_TARGET_XHR = 1,
+ X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT = 2;
-var X_EventDispatcher_once = false,
- X_EventDispatcher_lock = false,
- X_EventDispatcher_unlock = false,
- X_EventDispatcher_needsIndex = false,
+var X_EventDispatcher_once = false,
+ X_EventDispatcher_lock = false,
+ X_EventDispatcher_unlock = false,
+ X_EventDispatcher_needsIndex = false,
X_EventDispatcher_safariPreventDefault = false, // Safari3-
+
+ X_EventDispatcher_LAZY_TIMERS = {},// Object. number 㯠timerID
- /* @const */
- X_EventDispatcher_EVENT_TARGET_OTHER = 0,
- /* @const */
- X_EventDispatcher_EVENT_TARGET_XHR = 1,
- /* @const */
- X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT = 2,
-
- X_EventDispatcher_LAZY_TIMERS = {}; // Object. number 㯠timerID
+ // iOS 㨠MacOSX Iron36 ã§çºçãé£ç¶ãã¦ã¢ãã¡ã¼ã·ã§ã³ãèµ·ããã¨ãã¯ãã¼ã¸ã£ã®æç¸ããã obj ã¸ã®ã¢ã¯ã»ã¹ã«å¤±æãããWin ã§ã¯èµ·ããªã?
+ // ããããMacOSX ã®ãã©ã¦ã¶å
¨è¬ã§èµ·ãã??
+ X_EventDispatcher_ANIME_EVENTS = ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) && {
+ 'transitionend' : true, 'webkitTransitionEnd' : true, 'mozTransitionEnd' : true, 'oTransitionEnd' : true, 'otransitionEnd' : true,
+ 'animationend' : true, 'webkitAnimationEnd' : true, 'oAnimationEnd' : true,
+ 'animationstart' : true, 'webkitAnimationStart' : true, 'oAnimationStart' : true,
+ 'animationiteration' : true, 'webkitAnimationIteration' : true, 'oAnimationIteration' : true
+ };
// ------------------------------------------------------------------------- //
// --- interface ----------------------------------------------------------- //
@@ -98,7 +98,9 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] =
{
/**
- * OTHER(Node,window,document,Image,Audio), XHR, Silverlight
+ * EventDispatcher ãã©ãããã¦ãã EventTarget ãªãã¸ã§ã¯ãã®ã¿ã¤ãã§ãã
+ * X_EventDispatcher_actualAddEvent ã§ä½¿ç¨ããã¾ãã
+ * OTHER:0(node,window,document,Image,Audio), XHR:1, Silverlight:2
* @private
* @type {number}
*/
@@ -106,7 +108,7 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] =
/**
* ã¤ãã³ããªã¹ããã¤ãã³ãåæååãæ°å¤(5以ä¸ããã¬ã¼ã ã¯ã¼ã¯å
ã§å®ç¾©)ããã¼ã¨ããArrayã§è¨æ¶ãã¾ãã
- * Arrayã«ã¯ã{kind:種é¡,context:ã³ã³ããã¹ã(thisObject),func:ã³ã¼ã«ããã¯é¢æ°,supplement:ãµããªã¡ã³ãããå¼æ°ã®é
å} ã¨ããããã·ã¥ãã¾ãã¯é¢æ°ãèãããã¦ãã¾ãã
+ * Arrayã«ã¯ã{cbKind:種é¡,context:ã³ã³ããã¹ã(thisObject),func:ã³ã¼ã«ããã¯é¢æ°,supplement:ãµããªã¡ã³ãããå¼æ°ã®é
å} ã¨ããããã·ã¥ãã¾ãã¯é¢æ°ãèãããã¦ãã¾ãã
*
* @private
* @type {__Listeners__}
@@ -181,22 +183,23 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] =
if( !listeners || !( list = listeners[ opt_type ] ) ) return false;
if( opt_arg1 === undefined ) return X_EventDispatcher_needsIndex ? 0 : true;
- // TODO callbackHash ãï¼å¤å®ãä¸ååï¼
- if( opt_arg1.kind ){
+ // TODO callbackHash ãï¼å¤å®ãä¸ååï¼ skipConvertion
+ if( opt_arg1.cbKind ){
cbHash = opt_arg1;
} else {
- cbHash = X_Callback_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );
+ cbHash = X_Closure_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );
};
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.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ) return false;
+ if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.funcName === cbHash.funcName && 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.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ){
+ if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.funcName === cbHash.funcName && f.supplement === cbHash.supplement && f.lock === lock ) ){
// index ãè¦æ±ãããå ´åãlock ããã¦ããªããã¾ã㯠unlock ãªã index ãè¿ã
return X_EventDispatcher_needsIndex ? i : true;
};
@@ -220,6 +223,9 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] =
e = delay;
delay = 0;
};
+ //{+dev
+ delay === undefined && eval( 'throw "asyncDispatch 㧠undefined ã¤ãã³ããæå®ããã¾ãã"' );
+ //}+dev
timerID = X_Timer_add( delay, 1, this, X_EventDispatcher_dispatch, [ e ] );
X_EventDispatcher_LAZY_TIMERS[ timerID ] = this;
return timerID;
@@ -242,11 +248,11 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] =
*/
function X_EventDispatcher_dispatch( e ){
var listeners = this[ '_listeners' ],
- ret = X_Callback_NONE,
+ ret = X_CALLBACK_NONE,
type = e[ 'type' ],
- list, unlistens, i, l, args, f, r, sysOnly, timerID;
+ list, unlistens, i, l, args, f, r, sysOnly, timerID, k;
- if( !listeners || !( list = listeners[ type || e ] ) ) return X_Callback_NONE;
+ if( !listeners || !( list = listeners[ type || e ] ) ) return X_CALLBACK_NONE;
// æ°å¤, æåã渡ãããå ´å
if( !type ){
@@ -260,22 +266,24 @@ function X_EventDispatcher_dispatch( e ){
} else {
listeners[ X_LISTENERS_DISPATCHING ] = 1;
};
-
- // todo:
- // type ãä¿å
- listeners[ X_LISTENERS_UNLISTENS ] = listeners[ X_LISTENERS_UNLISTENS ] || {};
- unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ];
+
+ //listeners[ X_LISTENERS_UNLISTENS ] = listeners[ X_LISTENERS_UNLISTENS ] || {};
+ //unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ];
for( i = 0; i < list.length; ++i ){
f = list[ i ];
+ // TODO removed ãã©ã°ã¯?
+ if( f.removed ) continue;
+ /*
if( !unlistens ){
unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ];
};
if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;
+ */
- r = X_Callback_proxyCallback( f, args || ( args = [ e ] ) ) || 0;
+ r = X_Closure_proxyCallback( f, args || ( args = [ e ] ) );
- if( f.once || r & X_Callback_UN_LISTEN ){
+ if( f.once || ( r & X_CALLBACK_UN_LISTEN ) ){
// dispatch ä¸ã« unlisten ãä½ããããã¨ããã
if( !unlistens ){
unlistens = listeners[ X_LISTENERS_UNLISTENS ] || ( listeners[ X_LISTENERS_UNLISTENS ] = {} );
@@ -285,7 +293,7 @@ function X_EventDispatcher_dispatch( e ){
};
ret |= X_Type_isFinite( r ) ? r : 0;
- if( ( r & X_Callback_STOP_NOW ) === X_Callback_STOP_NOW ){ // iOS ã§ã¯ ( & ) æ¬å¼§ãç¡ãã¨å¤å®ã誤ã
+ if( ( r & X_CALLBACK_STOP_NOW ) === X_CALLBACK_STOP_NOW ){ // iOS ã§ã¯ ( & ) æ¬å¼§ãç¡ãã¨å¤å®ã誤ã
sysOnly = true;
break;
};
@@ -315,14 +323,14 @@ function X_EventDispatcher_dispatch( e ){
// _unlistens ã«å
¥ã£ã¦ãã callbackHash ã¯ãlock ãã¯ãªã¢ãã¦ãã
X_EventDispatcher_unlock = true;
- for( type in unlistens ){
- //if( X_EMPTY_OBJECT[ type ] ) continue;
- list = unlistens[ type ];
+ for( k in unlistens ){
+ //if( X_EMPTY_OBJECT[ k ] ) continue;
+ list = unlistens[ k ];
for( i = list.length; i; ){
- this[ 'unlisten' ]( type, list[ --i ] );
+ this[ 'unlisten' ]( k, list[ --i ] );
};
list.length = 0;
- delete unlistens[ type ];
+ delete unlistens[ k ];
};
X_EventDispatcher_unlock = false;
};
@@ -365,10 +373,6 @@ function X_EventDispatcher_dispatch( e ){
* this[ 'listen' ]( [ 'open', 'close', 'ready' ], onUpdate );
*
* @alias EventDispatcher.prototype.listen
- * @param {string|number|Array.} type é
åãæå®ããå ´åãè¤æ°ã®ã¤ãã³ãã¿ã¤ãã«å¯¾ãã¦åãã³ã¼ã«ããã¯ãç»é²ããã
- * @param {listener|function|Array} [opt_arg1=]
- * @param {function|Array} [opt_arg2=]
- * @param {Array} [opt_arg3=] ã³ã¼ã«ããã¯æã®å¼æ°ãé
åã«å
¥ãããå¼æ°ãã²ã¨ã¤ã§ãé
åã使ç¨ãããçç¥ããå ´åå¼æ°ãªãã
* @return {EventDispatcher} ãã§ã¤ã³ã¡ã½ãã
*/
function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
@@ -400,7 +404,7 @@ function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
add && X_EventDispatcher_actualAddEvent( this, type, raw, list );
- f = X_Callback_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );
+ f = X_Closure_classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );
list[ list.length ] = f;
f.once = X_EventDispatcher_once;
f.lock = X_EventDispatcher_lock;
@@ -418,17 +422,15 @@ function X_EventDispatcher_systemListen( that, type, opt_arg1, opt_arg2, opt_arg
};
/**
- * ã¤ãã³ããªã¹ãã®è§£é¤ãè¡ããç»é²æã¨åãå¼æ°ãä¸ããå¿
è¦ããããkill() ã§ãã¹ã¦ã®ã¤ãã³ãã解é¤ãããã®ã§ãéä¸ã§è§£é¤ãããã¤ãã³ã以å¤ã¯ kill() ã«ä»»ãã¦ãã¾ã£ã¦ããã
+ * ã¤ãã³ããªã¹ãã®è§£é¤ãè¡ããç»é²æã¨åãå¼æ°ãä¸ããå¿
è¦ããããkill() ã§èªä¿¡ã«ç»é²ããããã¹ã¦ã®ã¤ãã³ãã解é¤ãããã®ã§ãéä¸ã§è§£é¤ãããã¤ãã³ã以å¤ã¯ kill() ã«ä»»ãã¦ãã¾ã£ã¦ããã
+ * ä»äººã«ç»é²ããã¤ãã³ãã解é¤ããã« kill ããã®ã¯ NGã
* @alias EventDispatcher.prototype.unlisten
* @return {EventDispatcher}
- * @param {string|number|Array.} opt_type ã¤ãã³ãID, ã¤ãã³ãåãã¾ãã¯ãã®é
å
- * @param {listener|function|Array} opt_arg1
- * @param {function|Array} opt_arg2
- * @param {Array} opt_arg3
*/
function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
var listeners = this[ '_listeners' ],
list, reserves, unlistens, i, f, raw, k, empty;
+
if( !listeners ) return this;
if( X_Type_isArray( opt_type ) ){
@@ -459,13 +461,17 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
f = ( list = listeners[ opt_type ] )[ i ];
- if( unlistens = listeners[ X_LISTENERS_UNLISTENS ] ){
+ if( listeners[ X_LISTENERS_DISPATCHING ] ){
+ unlistens = listeners[ X_LISTENERS_UNLISTENS ] || ( listeners[ X_LISTENERS_UNLISTENS ] = {} );
// _unlistens ã«å
¥ã£ã¦ãã callbackHash ã¯ãlock ã®ãã§ãã¯ã¯æ¸ãã§ãã
( unlistens = unlistens[ opt_type ] ) ?
( unlistens[ unlistens.length ] = f ) :
( listeners[ X_LISTENERS_UNLISTENS ][ opt_type ] = [ f ] );
+ f.removed = true;
} else {
- delete f.once;
+ //delete f.once;
+ X_Object_clear( f );
+
if( list.length !== 1 ){
list.splice( i, 1 );
} else {
@@ -518,6 +524,7 @@ function X_EventDispatcher_unlistenAll( that ){
function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
var i, f;
+
X_EventDispatcher_lock || ( type = X_Event_Rename[ type ] || type );
if( X_Type_isArray( type ) ){
@@ -534,28 +541,22 @@ function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
if( X_UA_EVENT.W3C ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
- list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
+ list.slcallback = X_Closure_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
list.sltoken = raw[ 'AddEventListener' ]( type, list.slcallback );
break;
case X_EventDispatcher_EVENT_TARGET_XHR :
if( X_UA[ 'Opera' ] < 12 ){
// Opera11- ã® XHR 㯠event ãªãã¸ã§ã¯ããè¿ããªããã, eventType æ¯ã« callback ãæå®ãã addEventListener ããªã
- raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] );
+ raw[ 'on' + type ] = X_Closure_create( that, X_EventDispatcher_dispatch, [ type ] );
break;
};
default :
- // iOS 㨠MacOSX Iron36 ã§çºçãé£ç¶ãã¦ã¢ãã¡ã¼ã·ã§ã³ãèµ·ããã¨ãã¯ãã¼ã¸ã£ã®æç¸ããã obj ã¸ã®ã¢ã¯ã»ã¹ã«å¤±æãããWin ã§ã¯èµ·ããªã?
- // ããããMacOSX ã®ãã©ã¦ã¶å
¨è¬ã§èµ·ãã??
- if( ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) &&
- ( type === 'webkitTransitionEnd' || type === 'transitionend' ||
- type === 'animationend' || type === 'webkitAnimationEnd' ||
- type === 'animationstart' || type === 'webkitAnimationStart' ||
- type === 'animationiteration' || type === 'webkitAnimationIteration' ) ){
+ if( X_EventDispatcher_ANIME_EVENTS && X_EventDispatcher_ANIME_EVENTS[ type ] ){
raw.addEventListener( type, X_EventDispatcher_iOSTransitionEndDispatch, false );
} else {
- f = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) );
+ f = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Closure_create( that, X_EventDispatcher_actualHandleEvent ) );
if( raw.addEventListener ){
raw.addEventListener( type, f, false );
@@ -569,18 +570,18 @@ function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
if( X_UA_EVENT.IE ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
- list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
+ list.slcallback = X_Closure_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
list.sltoken = raw[ 'AddEventListener' ]( type, list.slcallback );
break;
case X_EventDispatcher_EVENT_TARGET_XHR :
console.log( 'XHR addEvent ' + type );
// ie8- ã® XHR 㯠window.event ãæ´æ°ãããªããã, eventType æ¯ã« callback ãæå®ãã
- raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] );
+ raw[ 'on' + type ] = X_Closure_create( that, X_EventDispatcher_dispatch, [ type ] );
break;
default :
- f = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) );
+ f = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Closure_create( that, X_EventDispatcher_actualHandleEvent ) );
if( raw.attachEvent ){
raw.attachEvent( 'on' + type, f );
@@ -593,17 +594,17 @@ function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
// DOM0 㧠Silverlight ã£ã¦ããã® -> ie4 mobile?
- list.slcallback = X_Callback_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
+ list.slcallback = X_Closure_create( that, X_EventDispatcher_sliverLightDispatch, [ type ] );
list.sltoken = raw[ 'AddEventListener' ]( type, list.slcallback );
break;
case X_EventDispatcher_EVENT_TARGET_XHR :
// ie4 mobile 㯠XHR ããµãã¼ãï¼
- raw[ 'on' + type ] = X_Callback_create( that, X_EventDispatcher_dispatch, [ type ] );
+ raw[ 'on' + type ] = X_Closure_create( that, X_EventDispatcher_dispatch, [ type ] );
break;
default :
- raw[ 'on' + type ] = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) );
+ raw[ 'on' + type ] = that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] || ( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] = X_Closure_create( that, X_EventDispatcher_actualHandleEvent ) );
break;
};
}
@@ -613,7 +614,7 @@ function X_EventDispatcher_actualAddEvent( that, type, raw, list ){
/*
* iOS ã® webkitTransitionEnd ãé£ç¶ãã¦èµ·ããå ´åã
- * ã³ã¼ã«ããã¯ã®(that[ X_LISTENERS_ACTUAL_HANDLER ])ã¯ãã¼ã¸ã£å
ã®å®éã®ã³ã¼ã«ããã¯(X_Callback_actualClosure:obj._)ã
+ * ã³ã¼ã«ããã¯ã®(that[ X_LISTENERS_ACTUAL_HANDLER ])ã¯ãã¼ã¸ã£å
ã®å®éã®ã³ã¼ã«ããã¯(X_Closure_actualClosure:obj._)ã
* åç
§ã§ãã¦ããªãåé¡ã«ééãããiOS3.1.3 & iOS6.1.5 ã§ç¢ºèª
* animation ãæªããããã
*/
@@ -631,6 +632,7 @@ function X_EventDispatcher_sliverLightDispatch( sender, e, type ){
function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
var i;
+
X_EventDispatcher_unlock || ( type = X_Event_Rename[ type ] || type );
if( X_Type_isArray( type ) ){
@@ -642,7 +644,7 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
raw[ 'RemoveEventListener' ]( type, list.sltoken ); // token
- X_Callback_correct( list.slcallback );
+ X_Closure_correct( list.slcallback );
delete list.sltoken;
delete list.slcallback;
break;
@@ -650,19 +652,15 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
case X_EventDispatcher_EVENT_TARGET_XHR :
if( X_UA[ 'Opera' ] < 12 ){
// Opera11- ã® XHR 㯠event ãªãã¸ã§ã¯ããè¿ããªããã, eventType æ¯ã« callback ãæå®ãã addEventListener ããªã
- X_Callback_correct( raw[ 'on' + type ] );
+ X_Closure_correct( raw[ 'on' + type ] );
raw[ 'on' + type ] = '';
break;
};
default :
- if( ( X_UA[ 'WebKit' ] || X_UA[ 'Blink' ] ) &&
- ( type === 'webkitTransitionEnd' || type === 'transitionend' ||
- type === 'animationend' || type === 'webkitAnimationEnd' ||
- type === 'animationstart' || type === 'webkitAnimationStart' ||
- type === 'animationiteration' || type === 'webkitAnimationIteration' ) ){
+ if( X_EventDispatcher_ANIME_EVENTS && X_EventDispatcher_ANIME_EVENTS[ type ] ){
raw.removeEventListener( type, X_EventDispatcher_iOSTransitionEndDispatch, false );
- } else
+ } else
if( raw.addEventListener ){
raw.removeEventListener( type, that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ], false );
} else {
@@ -670,7 +668,7 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
};
if( !skip && that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] ){
- X_Callback_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
+ X_Closure_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
delete that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ];
};
};
@@ -679,13 +677,13 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
raw[ 'RemoveEventListener' ]( type, list.sltoken ); // token
- X_Callback_correct( list.slcallback );
+ X_Closure_correct( list.slcallback );
delete list.sltoken;
delete list.slcallback;
break;
case X_EventDispatcher_EVENT_TARGET_XHR :
- X_Callback_correct( raw[ 'on' + type ] );
+ X_Closure_correct( raw[ 'on' + type ] );
raw[ 'on' + type ] = X_emptyFunction;
raw[ 'on' + type ] = '';
console.log( 'XHR rmEvent ' + type );
@@ -694,13 +692,14 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
default :
if( raw.attachEvent ){
raw.detachEvent( 'on' + type, that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
+ console.log( 'raw rmEvent ' + type );
} else {
raw[ 'on' + type ] = X_emptyFunction;
raw[ 'on' + type ] = '';
};
if( !skip ){
- X_Callback_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
+ X_Closure_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
delete that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ];
};
};
@@ -708,13 +707,13 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
switch( that[ '_rawType' ] ){
case X_EventDispatcher_EVENT_TARGET_SILVER_LIGHT :
raw[ 'RemoveEventListener' ]( type, list.sltoken ); // token
- X_Callback_correct( list.slcallback );
+ X_Closure_correct( list.slcallback );
delete list.sltoken;
delete list.slcallback;
break;
case X_EventDispatcher_EVENT_TARGET_XHR :
- X_Callback_correct( raw[ 'on' + type ] );
+ X_Closure_correct( raw[ 'on' + type ] );
raw[ 'on' + type ] = X_emptyFunction;
raw[ 'on' + type ] = '';
break;
@@ -724,7 +723,7 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
raw[ 'on' + type ] = '';
if( !skip ){
- X_Callback_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
+ X_Closure_correct( that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ] );
delete that[ '_listeners' ][ X_LISTENERS_ACTUAL_HANDLER ];
};
};
@@ -734,6 +733,7 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
// TODO ãã©ã¦ã¶ããã®å¼ã³åºãã®æå¾ã«ç»é²ãããé¢æ°ãå¼ã³åºãæ©è½(ä¾ãã°ç»é¢ã®æ´æ°)
+var X_EventDispatcher_CURRENT_EVENTS = [];
// handleEvent ãæ¡å¼µå¯è½ã«ããããã«ãã¯ãã¼ã¸ã£ã«ç§»åãã
// Is this in regard to the Safari 1.x preventDefault bug on click/dblclick?
@@ -741,14 +741,19 @@ function X_EventDispatcher_actualRemoveEvent( that, type, raw, list, skip ){
var X_EventDispatcher_actualHandleEvent =
X_UA_EVENT.IE4 || X_UA_EVENT.IE ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4
(function(){
- var e = event, ret;
+ var e = event, ret,
+ ev = new X_DomEvent( e, this, this[ '_rawObject' ] );
+
+ X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length ] = ev;
- ret = this[ 'dispatch' ]( new X_DomEvent( e, this, this[ '_rawObject' ] ) );
+ ret = this[ 'dispatch' ]( ev );
- if( ret & X_Callback_STOP_PROPAGATION ){
+ --X_EventDispatcher_CURRENT_EVENTS.length;
+
+ if( ret & X_CALLBACK_STOP_PROPAGATION ){
e.cancelBubble = true;
};
- if( ret & X_Callback_PREVENT_DEFAULT ){
+ if( ret & X_CALLBACK_PREVENT_DEFAULT ){
this[ '_tag' ] === 'A' && this[ '_rawObject' ].blur();
return e.returnValue = false;
};
@@ -756,14 +761,16 @@ var X_EventDispatcher_actualHandleEvent =
//X_UA_EVENT.W3C || X_UA_EVENT.DOM0
(function( e ){
var ev = new X_DomEvent( e, this ),
- ret = X_Callback_NONE,
+ ret = X_CALLBACK_NONE,
i, l;
- //console.log( '>>>>>>>>>> ' + e.type );
+
+ X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length ] = ev;
+
// touch event -> pointer
if( X_Type_isArray( ev ) ){
if( ev.length === 0 ){
// TouchEvent ã®å¾ã«çºçãã MouseEvent ã®ï½·ï½¬ï¾ï½¾ï¾
- ret = X_Callback_STOP_PROPAGATION | X_Callback_PREVENT_DEFAULT;
+ 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 );
@@ -774,10 +781,12 @@ var X_EventDispatcher_actualHandleEvent =
ret = this[ 'dispatch' ]( ev );
};
- if( ret & X_Callback_STOP_PROPAGATION ){
+ --X_EventDispatcher_CURRENT_EVENTS.length;
+
+ if( ret & X_CALLBACK_STOP_PROPAGATION ){
e.stopPropagation();
};
- if( ret & X_Callback_PREVENT_DEFAULT ){
+ if( ret & X_CALLBACK_PREVENT_DEFAULT ){
this[ '_tag' ] === 'A' && this[ '_rawObject' ].blur();
e.preventDefault();
if( X_UA[ 'WebKit' ] < 525.13 ){ // Safari3-
@@ -810,7 +819,6 @@ function X_EventDispatcher_toggleAllEvents( that, add ){
if( !list || !raw ) return;
for( type in list ){
//if( X_EMPTY_OBJECT[ type ] ) continue;
- //if( type <= X_LISTENERS_KILL_RESERVED ) continue;
// æ°åã¤ãã³ãã®é¤å¤
if( !X_String_isNumberString( type ) ){
// TODO type rename ã¯ãã