OSDN Git Service

Version 0.6.82, X.Timer.remove() work well while onTimeout.
[pettanr/clientJs.git] / 0.6.x / js / 00_core / 06_XEventDispatcher.js
index 152c63e..4f1f136 100644 (file)
@@ -34,32 +34,34 @@ X.Event = {
 // ------------------------------------------------------------------------- //\r
 // ------------ local variables -------------------------------------------- //\r
 // ------------------------------------------------------------------------- //\r
-var x_eventdispatcher_once       = false,\r
-       x_eventdispatcher_needsIndex = false,\r
-       x_eventdispatcher_temp       = {};\r
+var X_EventDispatcher_once       = false,\r
+       X_EventDispatcher_needsIndex = false,\r
+       X_EventDispatcher_temp       = {},\r
+       \r
+       X_EventDispatcher_safariPreventDefault = false; //  // Safari3-\r
 \r
 if( X.UA.MacIE ){\r
-       x_eventdispatcher_temp.DOM_W3C    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_W3C    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( X.UA.IE4 ){ // ie4 & iemobi4\r
-       x_eventdispatcher_temp.DOM_IE4    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_IE4    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( document.getElementById ){\r
-       x_eventdispatcher_temp.DOM_W3C = true;\r
+       X_EventDispatcher_temp.DOM_W3C = true;\r
        if( document.addEventListener ){\r
-               x_eventdispatcher_temp.EVENT_W3C = true;\r
+               X_EventDispatcher_temp.EVENT_W3C = true;\r
        } else\r
        if( document.attachEvent ){\r
-               x_eventdispatcher_temp.EVENT_IE = true;\r
+               X_EventDispatcher_temp.EVENT_IE = true;\r
        } else {\r
-               x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+               X_EventDispatcher_temp.EVENT_DOM0 = true;\r
        };\r
 } else\r
 if( document.all ){\r
-       x_eventdispatcher_temp.DOM_IE4    = true;\r
-       x_eventdispatcher_temp.EVENT_DOM0 = true;\r
+       X_EventDispatcher_temp.DOM_IE4    = true;\r
+       X_EventDispatcher_temp.EVENT_DOM0 = true;\r
 } else\r
 if( document.layers ){\r
        \r
@@ -72,7 +74,7 @@ if( document.layers ){
 // ------------------------------------------------------------------------- //\r
 \r
 /**\r
- * イベントターゲットをラップする場合(widnow, document, Image, XHR 等)、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor}\r
+ * イベントターゲット(widnow, document, Image, XHR 等)をラップする場合、通常は new 時に渡します。参照:コンストラクタ実体 {@link X.EventDispatcher.Constructor}\r
  * アプリケーション独自のイベントをやり取りしたいだけ、という場合、イベントターゲットは不要です。\r
  * @class\r
  * @classdesc EventTarget オブジェクトをラップしたり、アプリケーションで独自に定義したイベントを発信するためのクラスです。\r
@@ -164,12 +166,20 @@ X.EventDispatcher =
                                };\r
                        },\r
 \r
+               /**\r
+                * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。\r
+                * @this {X.EventDispatcher}\r
+                * @return {number}\r
+                * @param {(eventHash|string|number)} e\r
+                */     \r
+                       dispatch : X_EventDispatcher_dispatch,\r
+\r
            /**\r
             * \r
             * @this {X.EventDispatcher}\r
             */\r
-                       on     : x_eventdispatcher_listen,\r
-                       listen : x_eventdispatcher_listen,\r
+                       on     : X_EventDispatcher_listen,\r
+                       listen : X_EventDispatcher_listen,\r
                \r
                /**\r
                 * 一度 dispatch された時に自動で unlisten されるフラグを立てて listen する。\r
@@ -181,14 +191,14 @@ X.EventDispatcher =
                 * @param {Array=} opt_arg3\r
                 */\r
                        listenOnce : function( type, opt_arg1, opt_arg2, opt_arg3 ){\r
-                               x_eventdispatcher_once = true;\r
+                               X_EventDispatcher_once = true;\r
                                this.listen( type, opt_arg1, opt_arg2, opt_arg3 );\r
-                               x_eventdispatcher_once = false;\r
+                               X_EventDispatcher_once = false;\r
                                return this;\r
                        },\r
                        \r
-                       off      : x_eventdispatcher_unlisten,\r
-                       unlisten : x_eventdispatcher_unlisten,\r
+                       off      : X_EventDispatcher_unlisten,\r
+                       unlisten : X_EventDispatcher_unlisten,\r
 \r
                /**\r
                 * イベントリスナの登録状況を真偽値で返す。戻り値が数値(index)の場合もあるが、これは内部のみで使用。\r
@@ -224,104 +234,12 @@ X.EventDispatcher =
                                };\r
                                for( i = list.length; i; ){\r
                                        f = list[ --i ];\r
-                                       if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return x_eventdispatcher_needsIndex ? i : true;\r
+                                       if( f === hash || ( f.x === hash.x && f.f === hash.f && f.s === hash.s ) ) return X_EventDispatcher_needsIndex ? i : true;\r
                                };\r
                                return false;\r
                        },\r
 \r
                /**\r
-                * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。\r
-                * @this {X.EventDispatcher}\r
-                * @return {number}\r
-                * @param {(eventHash|string|number)} e\r
-                */     \r
-                       dispatch : function( e ){\r
-                               // dispatch 中の listen は?\r
-                               var list  = this[ '_listeners' ],\r
-                                       ret   = X.Callback.NONE,\r
-                                       type  = e[ 'type' ],\r
-                                       unlistens, i, l, f, r, sysOnly;\r
-                               \r
-                               if( !list || !( list = list[ type || e ] ) ) return ret;\r
-                               \r
-                               // 数値, 文字が渡された場合\r
-                               if( !type ){\r
-                                       e = { type : type = e };\r
-                               };\r
-                               e.target = e.target || this;\r
-                               \r
-                               ++this._dispatching;\r
-                               \r
-                               // todo:\r
-                               // type も保存\r
-                               this._unlistens = this._unlistens || {};\r
-                               unlistens = this._unlistens[ type ];\r
-                               \r
-                               for( i = 0; i < list.length; ++i ){\r
-                                       f = list[ i ];\r
-                                       if( !unlistens ){\r
-                                               unlistens = this._unlistens[ type ];\r
-                                       };\r
-                                       if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;\r
-                                       \r
-                                       r = X.Callback.NONE;\r
-                                       if( f.k ){\r
-                                               f.a = [ e ];\r
-                                               r = X.Callback._proxyCallback( f );\r
-                                       } else {\r
-                                               r = f.call( this, e );\r
-                                       };\r
-                                       \r
-                                       if( f.once || r & X.Callback.UN_LISTEN ){\r
-                                               // dispatch 中に unlisten が作られることがある\r
-                                               if( !unlistens ){\r
-                                                       unlistens = this._unlistens || ( this._unlistens = {} );\r
-                                                       unlistens = unlistens[ type ] || ( unlistens[ type ] = [] );\r
-                                               };\r
-                                               unlistens.indexOf( f ) === -1 && ( unlistens[ unlistens.length ] = f );\r
-                                       };\r
-\r
-                                       if( r & X.Callback.STOP_NOW ){\r
-                                               sysOnly = true;\r
-                                       };\r
-                                       ret |= r;\r
-                               };\r
-                               \r
-                               if( ( --this._dispatching ) === 0 ){\r
-                                       // dispatch 中に unlisten された要素の削除\r
-                                       unlistens = this._unlistens;\r
-                                       delete this._dispatching;\r
-                                       delete this._unlistens;                                 \r
-                                       \r
-                                       for( type in unlistens ){\r
-                                               list = unlistens[ type ];\r
-                                               for( i = list.length; i; ){\r
-                                                       this.unlisten( type, list[ --i ] );\r
-                                               };\r
-                                               list.length = 0;\r
-                                               delete unlistens[ type ];\r
-                                       };\r
-                                       \r
-                                       if( this._killReserved ){\r
-                                               this.kill();\r
-                                       } else\r
-                                       if( list = this._reserves ){\r
-                                               for( i = 0, l = list.length; i < l; ++i ){\r
-                                                       f = list[ i ];\r
-                                                       x_eventdispatcher_once = f[ 4 ];\r
-                                                       this.listen( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] );\r
-                                                       x_eventdispatcher_once = false;\r
-                                                       f.length = 0;\r
-                                               };\r
-                                               list.length = 0;\r
-                                               delete this._reserves;\r
-                                       };\r
-                               };\r
-                               \r
-                               return ret;\r
-                       },\r
-\r
-               /**\r
                 * delay(ミリ秒)後にイベントを dispatch する。戻り値は uid = X.Timer.add() のタイマーID(数値)。X.Timer.remove(uid) でタイマーを解除して dispatch を中止できる。\r
                 * @this {X.EventDispatcher}\r
                 * @return {number}\r
@@ -339,6 +257,97 @@ X.EventDispatcher =
 // ------------------------------------------------------------------------- //\r
 \r
 /**\r
+ * 登録されたイベントリスナを呼び出す。イベントリスナの返り値(数値)を OR したものを返す。イベントハッシュでなく、string|number を渡すと内部でイベントハッシュを作る\r
+ * @this {X.EventDispatcher}\r
+ * @return {number} X.Callback で定義された数値\r
+ * @param {(eventHash|string|number)} e\r
+ */\r
+function X_EventDispatcher_dispatch( e ){\r
+       var list  = this[ '_listeners' ],\r
+               ret   = X.Callback.NONE,\r
+               type  = e[ 'type' ],\r
+               unlistens, i, l, f, r, sysOnly;\r
+       \r
+       if( !list || !( list = list[ type || e ] ) ) return ret;\r
+       \r
+       // 数値, 文字が渡された場合\r
+       if( !type ){\r
+               e = { type : type = e };\r
+       };\r
+       e.target = e.target || this;\r
+       \r
+       ++this._dispatching;\r
+       \r
+       // todo:\r
+       // type も保存\r
+       this._unlistens = this._unlistens || {};\r
+       unlistens = this._unlistens[ type ];\r
+       \r
+       for( i = 0; i < list.length; ++i ){\r
+               f = list[ i ];\r
+               if( !unlistens ){\r
+                       unlistens = this._unlistens[ type ];\r
+               };\r
+               if( unlistens && unlistens.indexOf( f ) !== -1 ) continue;\r
+               \r
+               r = X.Callback.NONE;\r
+               if( f.k ){\r
+                       f.a = [ e ];\r
+                       r = X.Callback._proxyCallback( f );\r
+               } else {\r
+                       r = f.call( this, e );\r
+               };\r
+               \r
+               if( f.once || r & X.Callback.UN_LISTEN ){\r
+                       // dispatch 中に unlisten が作られることがある\r
+                       if( !unlistens ){\r
+                               unlistens = this._unlistens || ( this._unlistens = {} );\r
+                               unlistens = unlistens[ type ] || ( unlistens[ type ] = [] );\r
+                       };\r
+                       unlistens.indexOf( f ) === -1 && ( unlistens[ unlistens.length ] = f );\r
+               };\r
+\r
+               if( r & X.Callback.STOP_NOW ){\r
+                       sysOnly = true;\r
+               };\r
+               ret |= r;\r
+       };\r
+       \r
+       if( ( --this._dispatching ) === 0 ){\r
+               // dispatch 中に unlisten された要素の削除\r
+               unlistens = this._unlistens;\r
+               delete this._dispatching;\r
+               delete this._unlistens;                                 \r
+               \r
+               for( type in unlistens ){\r
+                       list = unlistens[ type ];\r
+                       for( i = list.length; i; ){\r
+                               this.unlisten( type, list[ --i ] );\r
+                       };\r
+                       list.length = 0;\r
+                       delete unlistens[ type ];\r
+               };\r
+               \r
+               if( this._killReserved ){\r
+                       this.kill();\r
+               } else\r
+               if( list = this._reserves ){\r
+                       for( i = 0, l = list.length; i < l; ++i ){\r
+                               f = list[ i ];\r
+                               X_EventDispatcher_once = f[ 4 ];\r
+                               this.listen( f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ] );\r
+                               X_EventDispatcher_once = false;\r
+                               f.length = 0;\r
+                       };\r
+                       list.length = 0;\r
+                       delete this._reserves;\r
+               };\r
+       };\r
+       \r
+       return ret;\r
+};\r
+\r
+/**\r
  * \r
  * @this {X.EventDispatcher}\r
  * @return {X.EventDispatcher}\r
@@ -347,13 +356,13 @@ X.EventDispatcher =
  * @param {(function|Array=} opt_arg2\r
  * @param {Array=} opt_arg3\r
  */\r
-function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){\r
+function X_EventDispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){\r
        var list = this._listeners,\r
                i, r, f;\r
        \r
        if( this._dispatching ){\r
                if( !this._reserves ) this._reserves = [];\r
-               this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, x_eventdispatcher_once ];\r
+               this._reserves[ this._reserves.length ] = [ type, opt_arg1, opt_arg2, opt_arg3, X_EventDispatcher_once ];\r
                return this;\r
        };\r
        \r
@@ -364,7 +373,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
                return this;\r
        };\r
        \r
-       ( !list || !list[ type ] ) && X.Type.isString( type ) && x_eventdispatcher_actualAddEvent( this, type );\r
+       ( !list || !list[ type ] ) && X.Type.isString( type ) && X_EventDispatcher_actualAddEvent( this, type );\r
        \r
        if( this.listening( type, opt_arg1, opt_arg2, opt_arg3 ) ) return this;\r
 \r
@@ -373,7 +382,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
        \r
        f = X.Callback._classifyCallbackArgs( opt_arg1, opt_arg2, opt_arg3, this );\r
        list[ list.length ] = f;\r
-       f.once = x_eventdispatcher_once;\r
+       f.once = X_EventDispatcher_once;\r
        \r
        return this;\r
 };\r
@@ -387,7 +396,7 @@ function x_eventdispatcher_listen( type, opt_arg1, opt_arg2, opt_arg3 ){
  * @param {(function|Array=} opt_arg2\r
  * @param {Array=} opt_arg3\r
  */\r
-function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){\r
+function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){\r
        var list = this._listeners,\r
                _list, reserves, unlistens, i, f;\r
        if( !list ) return this;\r
@@ -430,9 +439,9 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                };\r
        };\r
        \r
-       x_eventdispatcher_needsIndex = true;\r
+       X_EventDispatcher_needsIndex = true;\r
        i = this.listening( opt_type, opt_arg1, opt_arg2, opt_arg3 );\r
-       x_eventdispatcher_needsIndex = false;\r
+       X_EventDispatcher_needsIndex = false;\r
        if( i === false ) return this;\r
 \r
        f = ( _list = list[ opt_type ] )[ i ];\r
@@ -446,7 +455,7 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
                _list.splice( i, 1 );\r
                if( !_list.length ){\r
                        delete this._listeners[ opt_type ];\r
-                       X.Type.isString( opt_type ) && x_eventdispatcher_actualRemoveEvent( this, opt_type );\r
+                       X.Type.isString( opt_type ) && X_EventDispatcher_actualRemoveEvent( this, opt_type );\r
                        if( X.isEmptyObject( this._listeners ) ) delete this._listeners;\r
                };\r
        };\r
@@ -454,15 +463,15 @@ function x_eventdispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
 };\r
 \r
 \r
-var x_eventdispatcher_actualAddEvent =\r
+var X_EventDispatcher_actualAddEvent =\r
        // Days on the Moon DOM Events とブラウザの実装 \r
        // http://nanto.asablo.jp/blog/2007/03/23/1339502\r
        // Safari 2 では関数オブジェクトしか EventListener として使えませんが、Safari のナイトリービルドでは handleEvent メソッドを持つオブジェクトも EventListener として使えるようです。\r
-       x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
+       X_EventDispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return; \r
-                       that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                       that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                        type = X.Dom.Event.Rename[ type] || type;\r
                        if( raw.addEventListener ){\r
                                raw.addEventListener( type, that._handleEvent, false );\r
@@ -471,14 +480,14 @@ var x_eventdispatcher_actualAddEvent =
                                raw[ 'on' + type ] = that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_W3C ?\r
+       X_EventDispatcher_temp.EVENT_W3C ?\r
                (function( that, type ){\r
                        if( that._rawObject ){\r
-                               that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                               that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                                that._rawObject.addEventListener( X.Dom.Event.Rename[ type ] || type, that._handleEvent, false );\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_IE ?\r
+       X_EventDispatcher_temp.EVENT_IE ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -488,9 +497,9 @@ var x_eventdispatcher_actualAddEvent =
                        //};\r
                        if( that._isXHR ){\r
                                // ie8- の XHR は window.event が更新されないため, eventType 毎に callback を指定する\r
-                               raw[ 'on' + type ] = X.Callback.create( that, X.EventDispatcher.prototype.dispatch, [ type ] );\r
+                               raw[ 'on' + type ] = X.Callback.create( that, X_EventDispatcher_dispatch, [ type ] );\r
                        } else {\r
-                               that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                               that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                                \r
                                if( raw.attachEvent ){\r
                                        raw.attachEvent( 'on' + type, that._handleEvent );\r
@@ -503,12 +512,12 @@ var x_eventdispatcher_actualAddEvent =
                (function( that, type ){\r
                        var raw = that._rawObject || ( that._ie4getRawNode && that._ie4getRawNode() );\r
                        if( !raw ) return;\r
-                       raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that, x_eventdispatcher_actualHandleEvent );\r
+                       raw[ 'on' + ( X.Dom.Event.Rename[ type ] || type ) ] = that._handleEvent = that._handleEvent || X.Callback.create( that, X_EventDispatcher_actualHandleEvent );\r
                });\r
 \r
 \r
-var x_eventdispatcher_actualRemoveEvent =\r
-       x_eventdispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
+var X_EventDispatcher_actualRemoveEvent =\r
+       X_EventDispatcher_temp.EVENT_W3C && ( X.UA.WebKit < 525.13 || X.UA.Opera7 || X.UA.NetFront < 4 ) ? // Safari3-\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -524,7 +533,7 @@ var x_eventdispatcher_actualRemoveEvent =
                                delete that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_W3C ?\r
+       X_EventDispatcher_temp.EVENT_W3C ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -534,7 +543,7 @@ var x_eventdispatcher_actualRemoveEvent =
                                delete that._handleEvent;\r
                        };\r
                }) :\r
-       x_eventdispatcher_temp.EVENT_IE ?\r
+       X_EventDispatcher_temp.EVENT_IE ?\r
                (function( that, type ){\r
                        var raw = that._rawObject;\r
                        if( !raw ) return;\r
@@ -576,7 +585,7 @@ var x_eventdispatcher_actualRemoveEvent =
 // handleEvent を拡張可能にするために、クロージャに移動した\r
 // Is this in regard to the Safari 1.x preventDefault bug on click/dblclick?\r
 // https://groups.google.com/forum/#!msg/comp.lang.javascript/uYEuCHjHxnw/yKoHtZJPa1QJ\r
-var x_eventdispatcher_actualHandleEvent =\r
+var X_EventDispatcher_actualHandleEvent =\r
        X.UA.IE4 || X.UA.IE5678 ? // ie45678 EVENT_IE & EVENT_DOM0 for ie4\r
                (function(){\r
                        var ret;\r
@@ -585,7 +594,7 @@ var x_eventdispatcher_actualHandleEvent =
                                //type = 'readystatechange';\r
                        };\r
                        \r
-                       ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawObject ) );\r
+                       ret = X_EventDispatcher_dispatch.call( this, new X.Dom.Event( event, this, this._rawObject ) );\r
 \r
                        if( ret & X.Callback.STOP_PROPAGATION ){\r
                                event.cancelBubble = true;\r
@@ -597,7 +606,7 @@ var x_eventdispatcher_actualHandleEvent =
                }) :\r
        //X.Dom.EVENT_W3C & EVENT_DOM0\r
                (function( e ){\r
-                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) );\r
+                       var ret = X_EventDispatcher_dispatch.call( this, new X.Dom.Event( e, this ) );\r
                        \r
                        if( ret & X.Callback.STOP_PROPAGATION ){\r
                                e.stopPropagation();\r
@@ -607,33 +616,43 @@ var x_eventdispatcher_actualHandleEvent =
                                e.preventDefault();\r
                                if( X.UA.WebKit < 525.13 ){ // Safari3-\r
                                        if( e.type === 'click' || e.type === 'dbclick' ){\r
-                                               X.Dom._safariPreventDefault = true;\r
+                                               X_EventDispatcher_safariPreventDefault = true;\r
                                        };\r
                                };\r
                                return false;\r
                        };\r
                });\r
 \r
+if( X.UA.WebKit < 525.13 ){ // Safari3-\r
+       document.documentElement.onclick =\r
+       document.documentElement.ondbclick = function( e ){\r
+                       if( X_EventDispatcher_safariPreventDefault ){\r
+                               X_EventDispatcher_safariPreventDefault = false;\r
+                               e.preventDefault();\r
+                               return false;\r
+                       };\r
+               };\r
+};\r
 \r
 // イベントの退避、dom が画面から抜かれる場合に実施しておく\r
-X.EventDispatcher.prototype._migrateEvent = function(){\r
-       var hash = this._listeners,\r
+function X_EventDispatcher_migrateEvent( that ){\r
+       var hash = that._listeners,\r
                type;\r
        if( !hash ) return;\r
        for( type in hash ){\r
                // 数字イベントの除外\r
-               '' + parseFloat( type ) !== type && x_eventdispatcher_actualRemoveEvent( this, type );\r
+               '' + parseFloat( type ) !== type && X_EventDispatcher_actualRemoveEvent( that, type );\r
        };\r
 };\r
 \r
 // 退避したイベントの復帰\r
-X.EventDispatcher.prototype._restoreEvent = function(){\r
-       var hash = this._listeners,\r
+function X_EventDispatcher_restoreEvent( that ){\r
+       var hash = that._listeners,\r
                type;\r
        if( !hash ) return;\r
        for( type in hash ){\r
                // 数字イベントの除外\r
-               '' + parseFloat( type ) !== type && x_eventdispatcher_actualAddEvent( this, type );\r
+               '' + parseFloat( type ) !== type && X_EventDispatcher_actualAddEvent( that, type );\r
        };\r
 };\r
 \r