OSDN Git Service

Version 0.6.137, fix X.EventDispatcher.unlisten & remove X.Node.destroy.
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 13_XEventDispatcher.js
index 121525b..946cbfc 100644 (file)
@@ -105,7 +105,7 @@ var X_EventDispatcher_once       = false,
  * @constructs EventDispatcher\r
  * @extends {__ClassBase__}\r
  */\r
-var X_EventDispatcher = X.EventDispatcher =\r
+var X_EventDispatcher = X[ 'EventDispatcher' ] =\r
        X_Class_create(\r
                'EventDispatcher',\r
                \r
@@ -434,13 +434,11 @@ function X_EventDispatcher_systemListen( that, type, opt_arg1, opt_arg2, opt_arg
        X_EventDispatcher_lock = false;\r
 };\r
 \r
-// TODO this[ 'listen' ](type) は this リスナの登録なのに、this[ 'unlisten' ](type)は全てのtypeの削除、と不一致\r
-\r
 /**\r
  * イベントリスナの解除を行う。登録時と同じ引数を与える必要がある。kill() ですべてのイベントが解除されるので、途中で解除されるイベント以外は kill() に任せてしまってよい。\r
  * @alias EventDispatcher.prototype.unlisten\r
  * @return {EventDispatcher}\r
- * @param {string|number|Array.<string,number>} opt_type\r
+ * @param {string|number|Array.<string,number>} opt_type イベントID, イベント名、またはその配列\r
  * @param {listener|function|Array} opt_arg1\r
  * @param {function|Array} opt_arg2\r
  * @param {Array} opt_arg3\r
@@ -459,29 +457,7 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                };\r
                return this;\r
        };\r
-       \r
-       if( opt_type === undefined ){\r
-               // 全て削除\r
-               for( opt_type in listeners ){\r
-                       //if( X_EMPTY_OBJECT[ opt_type ] ) continue;\r
-                       if( opt_type < X_Listeners_.KILL_RESERVED ) continue;\r
-                       list = listeners[ opt_type ];\r
-                       for( i = list.length; i; ){\r
-                               this[ 'unlisten' ]( opt_type, list[ --i ] ); // override されていることがあるので、必ず unlisten を使用\r
-                       };\r
-                       // this[ 'unlisten' ]( opt_type ); これは無茶!\r
-               };\r
-               return this;\r
-       } else\r
-       if( opt_arg1 === undefined ){\r
-               // 同一タイプを全て削除\r
-               if( list = listeners[ opt_type ] ){\r
-                       for( i = list.length; i; ){\r
-                               this[ 'unlisten' ]( opt_type, list[ --i ] ); // override されていることがあるので、必ず unlisten を使用\r
-                       };\r
-               };\r
-               return this;\r
-       } else\r
+\r
        if( reserves = listeners[ X_Listeners_.RESERVES ] ){\r
                for( i = reserves.length; i; ){\r
                        f = reserves[ --i ];\r
@@ -515,7 +491,7 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                        // TODO カウンター\r
                        empty = true;\r
                        for( k in listeners ){\r
-                               if( k < X_Listeners_.KILL_RESERVED ) continue;\r
+                               if( k <= X_Listeners_.KILL_RESERVED ) continue;\r
                                empty = false;\r
                                break;\r
                        };\r
@@ -537,6 +513,21 @@ function X_EventDispatcher_systemUnlisten( that, type, opt_arg1, opt_arg2, opt_a
        X_EventDispatcher_unlock = false;\r
 };\r
 \r
+function X_EventDispatcher_unlistenAll( that ){\r
+       var listeners = that[ '_listeners' ],\r
+               type, list, i;\r
+       if( !listeners ) return;\r
+       \r
+       for( type in listeners ){\r
+               //if( X_EMPTY_OBJECT[ opt_type ] ) continue;\r
+               if( type <= X_Listeners_.KILL_RESERVED ) continue;\r
+               list = listeners[ type ];\r
+               for( i = list.length; i; ){\r
+                       that[ 'unlisten' ]( type, list[ --i ] );\r
+               };\r
+       };\r
+};\r
+\r
 function X_EventDispatcher_addEvent( that, type, raw, list ){\r
        var i;\r
        X_EventDispatcher_lock || ( type = X_Event_Rename[ type ] || type );\r
@@ -840,7 +831,7 @@ function X_EventDispatcher_toggleAllEvents( that, add ){
        if( !list || !raw ) return;\r
        for( type in list ){\r
                //if( X_EMPTY_OBJECT[ type ] ) continue;\r
-               //if( type < X_Listeners_.KILL_RESERVED ) continue;\r
+               //if( type <= X_Listeners_.KILL_RESERVED ) continue;\r
                // 数字イベントの除外\r
                if( !X_String_isNumberString( type ) ){\r
                        // TODO type rename はここ\r