OSDN Git Service

Version 0.6.57, fixed NS of X.UI & X.Class for __proto__.
[pettanr/clientJs.git] / 0.6.x / js / dom / 12_XDomEvent.js
index 781cd59..a3679a2 100644 (file)
-/**
- * use X.Callback
- * 
- * http://d.hatena.ne.jp/uupaa/20100430/1272561922
- * 
- */
-
-if( window.addEventListener ){
-       X.Dom.Event = function( e ){
-               //this._event        = e;
-               this.type          = e.type;
-               
-               //http://www.quirksmode.org/js/events_properties.html
-               this.target        = e.target.nodeType === 3 ? e.target.parentNode : e.target;// defeat Safari bug // xnode
-               
-               this.currentTarget = e.currentTarget; // xnode
-               this.relatedTarget = e.relatedTarget; // xnode
-               this.eventPhase    = e.eventPhase;
-               
-               this.clientX       = e.clientX;
-               this.clientY       = e.clientY;
-               //this.screenX       = e.screenX;
-               //this.screenY       = e.screenY;
-               this.pageX         = e.pageX;
-               this.pageY         = e.pageY;
-               this.offsetX       = e.offsetX || e.layerX;
-               this.offsetY       = e.offsetY || e.layerY;
-               
-               this.keyCode       = e.keyCode;
-               this.altKey        = e.altKey;
-               this.ctrlKey       = e.ctrlKey;
-               this.shiftKey      = e.shiftKey;
-               
-               // http://www.programming-magic.com/20090127231544/
-               this.which         = e.which || ( e.button + 1 ); // 左:1, 中:2, 右:3
-               
-               // https://developer.mozilla.org/ja/docs/DOM/DOM_event_reference/mousewheel
-               if( e.wheelDeltaY !== undefined ){
-                       this.wheelDeltaX = e.wheelDeltaX / 12;
-                       this.wheelDeltaY = e.wheelDeltaY / 12;
-               } else
-               if( e.wheelDelta !== undefined ){
-                       this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;
-               } else
-               if( e.detail !== undefined ){
-                       this.wheelDeltaX = this.wheelDeltaY = - e.detail * 3;
-               } else {
-                       this.wheelDeltaX = this.wheelDeltaY = 0;
-               };
-               
-               if( e.constructor === window.TouchEvent ){
-                       // TouchEvent
-                       this.touches        = e.touches;
-                       this.changedTouches = e.changedTouches;
-                       this.targetTouches  = e.targetTouches;
-                       //this.altKey         = e.altKey;
-                       //this.ctrlKey        = e.ctrlKey;
-                       this.metaKey        = e.metaKey;
-                       //this.shiftKey       = e.shiftKey;
-                       //this.type           = e.type;
-                       //this.target         = e.target;
-               } else
-               if( e.constructor === window.PointerEvent ){
-                       // PointerEvent;
-                       this.currentPoint  = e.currentPoint;
-                       this.width         = e.width;
-                       this.height        = e.height;
-                       this.timeStamp     = e.timeStamp;
-                       this.hwTimestamp   = e.hwTimestamp;
-                       this.intermediatePoints = e.intermediatePoints;
-                       this.isPrimary     = e.isPrimary;
-                       this.pointerId     = e.pointerId;
-                       this.pointerType   = e.pointerType;
-                       this.pressure      = e.pressure;
-                       this.tiltX         = e.tiltX;
-                       this.tiltY         = e.tiltY;
-               };
-       };
-} else {
-       X.Dom.Event = function( e, element ){
-               var btn;
-               
-               //this._event        = e;
-               this.type          = e.type;
-               this.target        = e.srcElement; // xnode
-               this.currentTarget = element; // xnode
-               this.relatedTarget = e.formElement ? e.formElement : e.toElement; // xnode
-               this.eventPhase    = e.srcElement === element ? 2: 3;
-               
-               this.clientX       = e.clientX;
-               this.clientY       = e.clientY;
-               //this.screenX       = e.screenX;
-               //this.screenY       = e.screenY;
-               
-               if( X.Dom._root ){ // uuu...
-                       this.pageX         = e.clientX + X.Dom._root.scrollLeft;
-                       this.pageY         = e.clientY + X.Dom._root.scrollTop;                 
-               };
-               
-               if( X.UA.IE && 5 <= X.UA.IE ){
-                       this.offsetX       = e.offsetX; // イベントターゲット左上からの座標
-                       this.offsetY       = e.offsetY;                 
-               } else {
-                       this.offsetX       = e.x - e.srcElement.offsetLeft; // e.x はイベントが発生要素の親要素を基準にした座標。
-                       this.offsetY       = e.y - e.srcElement.offsetTop;      
-               };
-               
-               this.keyCode       = e.keyCode;
-               this.altKey        = e.altKey;
-               this.ctrlKey       = e.ctrlKey;
-               this.shiftKey      = e.shiftKey;
-               
-               // http://www.programming-magic.com/20090127231544/
-               switch( this.type ){
-                       case 'click'    :
-                       case 'dblclick' :
-                               this.which = 1;
-                               break;
-                       case 'contextmenu' :
-                               this.which = 3;
-                               break;
-                       default :
-                               btn = e.button;
-                               this.which =
-                                       btn & 1 ? 1 :
-                                       btn & 4 ? 2 :
-                                       btn & 2 ? 3 : 0; // 左:1(click:0), 中:4, 右:2
-               };
-               this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;
-       };
-};
-
-X.Dom.Event.DOM_PRE_INIT        = 0;
-X.Dom.Event.DOM_INIT            = 1;
-X.Dom.Event.XDOM_READY          = 2;
-X.Dom.Event.VIEW_ACTIVATE       = 3;
-X.Dom.Event.VIEW_DEACTIVATE     = 4;
-X.Dom.Event.VIEW_RESIZED        = 5;
-// on_screen_keyboard_show
-// on_screen_keyboard_hide
-// before_commit_update
-X.Dom.Event.COMMIT_UPDATE       = 6;
-// hash_change
-// before_unload
-// X.Dom.Event.LOAD_BEFORE_STOP    = 7;
-X.Dom.Event.LOAD_ASSET_COMPLETE = 7;
-X.Dom.Event.LOAD_ASSET_ERROR    = 8;
-
-X.Dom.Event.ANIME_BEFORE_START  = 9;
-X.Dom.Event.ANIME_START         = 10;
-X.Dom.Event.ANIME               = 11;
-X.Dom.Event.ANIME_END           = 12;
-X.Dom.Event.ANIME_BEFORE_STOP   = 13; // xnode.stop() のみ、指定時間による停止では呼ばれない
-X.Dom.Event.ANIME_STOP          = 14;
-X.Dom.Event._LAST_EVENT         = 14; // ここに書いてあるイベントの最後の値 X.Dom.Event.ANIME_STOP と同じ値
-
-
-X.Dom.Node.prototype.listen = function( type, arg2, arg3, arg4 /* [ listener || ( context + function ) || function ][ arguments ] */ ){
-       var elm;
-       
-       if( this._xnodeType === 0 || this._xnodeType === 3 || !arg2 ) return this;
-       
-       ( !this._listeners || !this._listeners[ type ] ) && this._addEvent( type );
-       
-       return typeof arg2 === 'function' ?
-               X.EventDispatcher.prototype.listen.call( this, type, this, arg2, arg3 ) :
-               X.EventDispatcher.prototype.listen.apply( this, arguments );
-};
-
-X.Dom.Node.prototype._addEvent =
-       document.removeEventListener ?
-               (function( type ){
-                       this._rawNode && this._rawNode.addEventListener( type, this, false );
-               }) :
-       document.detachEvent ?
-               (function( type ){
-                       if( !this._rawNode ) return;
-                       this._handleEvent = this._handleEvent || X.Callback.create( this );
-                       this._rawNode.attachEvent( 'on' + type, this._handleEvent );
-               }) :
-               (function( type ){
-                       var elm = this._ie4getRawNode();
-                       if( !elm ) return;
-                       this._handleEvent = elm[ 'on' + type ] = this._handleEvent || X.Callback.create( this );
-               });
-
-
-X.Dom.Node.prototype.unlisten = function( type /* , arg2, arg3, arg4 */ ){
-       var list = this._listeners,
-               l    = list && type && list[ type ] && list[ type ].length;
-       
-       X.EventDispatcher.prototype.unlisten.apply( this, arguments );
-       
-       if( type !== undefined && !this._dispatching && l && !list[ type ] ){
-               this._removeEvent( type );
-       };
-       
-       return this;
-};
-
-X.Dom.Node.prototype._removeEvent =
-       document.removeEventListener ?
-               (function( type ){
-                       var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
-                       if( !elm ) return;
-                       elm.removeEventListener( type, this, false );
-               }) :
-       document.detachEvent ?
-               (function( type ){
-                       var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
-                       if( !elm ) return;
-                       elm.detachEvent( 'on' + type, this._handleEvent );
-                       if( !this._listeners ){
-                               X.Callback._correct( this._handleEvent );
-                               delete this._handleEvent;
-                       };
-               }) :
-               (function( type ){
-                       var elm = this._ie4getRawNode ? this._ie4getRawNode() : this._rawNode;
-                       if( !elm ) return;
-                       elm[ 'on' + type ] = X.emptyFunction;
-                       elm[ 'on' + type ] = '';
-                       if( !this._listeners ){
-                               X.Callback._correct( this._handleEvent );
-                               delete this._handleEvent;
-                       };
-               });
-
-
-X.Dom.Node.prototype.handleEvent =
-       document.removeEventListener ?
-               (function( e ){
-                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e ) );
-
-                       if( ret & X.Callback.STOP_PROPAGATION ){
-                               e.stopPropagation();
-                       };
-                       if( ret & X.Callback.PREVENT_DEFAULT ){
-                               e.preventDefault();
-                               return false;
-                       };
-               }) :
-               (function(){
-                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this._rawNode ) );
-
-                       if( ret & X.Callback.STOP_PROPAGATION ){
-                               event.cancelBubble = true;
-                       };
-                       if( ret & X.Callback.PREVENT_DEFAULT ){
-                               return event.returnValue = false;
-                       };
-               });
-
-
-// イベントの退避、dom が画面から抜かれる場合に実施しておく
-X.Dom.Node.prototype._migrateEvent = function(){
-       var hash = this._listeners,
-               type;
-       if( !hash ) return;
-       for( type in hash ){
-               this._removeEvent( type );
-       };
-};
-
-// 退避したイベントの復帰
-X.Dom.Node.prototype._restoreEvent = function(){
-       var hash = this._listeners,
-               type;
-       if( !hash ) return;
-       for( type in hash ){
-               this._addEvent( type );
-       };
-};
-
-
-
-/* -----------------------------------------------
- * Document Ready
- *  Dean Edwards/Matthias Miller/John Resig
- */
-/* for ie9+/Mozilla/Opera9 */
-if( document.addEventListener ){
-       X.Dom.Node._document.listenOnce( 'DOMContentLoaded', X.Dom._init );
-} else
-if( 5 <= X.UA.IE && X.inHead ){
-       // if this script in Head
-       document.write( "<script id=__ie_onload defer src=javascript:void(0)><\/script>" );
-       X.Dom._script = document.getElementById( "__ie_onload" );
-       X.Dom._script.onreadystatechange = function(){
-               this.readyState === 'complete' && X.Dom._init();
-       };
-} else
-if( X.UA.WebKit ){ // sniff
-       X.Timer.add( 10, function(){
-               if( !X.Dom._init ) return X.Callback.UN_LISTEN;
-               if( 'loaded|complete'.indexOf( document.readyState ) !== -1 ) return X.Dom._init();
-       });
-};
-
-/* for other browsers */
-X.Dom.Node._window.listenOnce( 'load', X.Dom._init );
-
-//
-X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){ console.log( 'X.Dom XDomReady ' + X.Dom.readyState ) } );
-
-X.Dom.listenOnce( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ) } );
-
-
-/* --------------------------------------
- *  load
- */
-X.Dom.listenOnce( X.Dom.Event.DOM_INIT, function(){
-       
-       Node._html = document.documentElement ? new Node( document.documentElement ) : null;
-       
-       var r    = Node.root = new Node( document.body ),
-               body = r._rawNode,
-               createTree, n = 0, s;
-       r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
-       
-       if( body.childNodes ){
-               /*
-                * body.innerHTML(可能なら outerHTML を使って属性を控える)
-                */
-               createTree = function( xnode, elm, skipCleanup ){
-                       var     children = elm.childNodes,
-                               i = 0,
-                               l = children.length,
-                               child, _xnode, text;
-                       for( ; i < children.length; ){
-                               child = children[ i ];
-                               switch( child.nodeType ){
-                                       case 1 :
-                                               if( !xnode._xnodes ) xnode._xnodes = [];
-                                               xnode._xnodes[ xnode._xnodes.length ] = _xnode = new Node( child );
-                                               // attr の取得
-                                               _xnode.parent = xnode;
-                                               child.childNodes.length && createTree( _xnode, child, skipCleanup || 0 <= X.skipCleanupTagNames.indexOf( child.tagName.toLowerCase() ) );
-                                               break;
-                                       case 3 :
-                                               if( skipCleanup || ( ( text = child.data ) && ( text = X.cleanupWhiteSpace( text ) ) !== ' ' ) ){
-                                                       if( !skipCleanup ) child.data = text;
-                                                       if( !xnode._xnodes ) xnode._xnodes = [];
-                                                       xnode._xnodes[ xnode._xnodes.length ] = _xnode = new Node( child );
-                                                       _xnode.parent = xnode;
-                                                       break;                                                  
-                                               };
-                                       default :
-                                               elm.removeChild( child );
-                                               ++n;
-                                               continue;                                                               
-                               };
-                               ++i;
-                       };
-               };
-               createTree( r, body );
-       } else
-       if( body.children ){
-               createTree = function( xnode, children, skipCleanup ){
-                       var i = 0,
-                               l = children.length,
-                               j = 0,
-                               child, _xnode, f, tag, text;
-
-                       xnode._ie4dirtyChildren = true;
-                       for( ; i < l; ++i ){
-                               child = children[ i ];
-                               if( child.tagName === '!' ) continue;
-                               f = false;
-                               while( j < xnode._xnodes.length ){
-                                       _xnode = xnode._xnodes[ j ];
-                                       _xnode.parent    = xnode;
-                                       _xnode._ie4dirty = true;
-                                       if( _xnode._xnodeType === 1 ){
-                                               tag = child.tagName.toLowerCase();
-                                               if( _xnode._tag !== tag ){
-                                                       alert( _xnode._tag + ' !== ' + child.tagName + ' * ' + child.outerHTML );
-                                               } else {
-                                                       _xnode._rawNode = child;
-                                                       !( _xnode._id = child.getAttribute( 'id' ) ) && child.setAttribute( 'id', ( _xnode._ie4uid = 'ie4uid' + _xnode._uid ) );
-                                                       child.setAttribute( 'UID', '' + _xnode._uid );
-                                                       child.children.length && createTree( _xnode, child.children, skipCleanup || 0 <= X.skipCleanupTagNames.indexOf( tag ) );
-                                                       f = true;
-                                                       ++j;
-                                                       break;
-                                               };
-                                       } else
-                                       if( _xnode._xnodeType === 3 ){
-                                               if( !skipCleanup && ( !( text = _xnode._text ) || ( text = X.cleanupWhiteSpace( text ) ) === ' ' ) ){
-                                                       _xnode.remove();
-                                                       ++n;
-                                                       continue;
-                                               };
-                                               if( !skipCleanup ) _xnode._text = text;
-                                       };
-                                       ++j;
-                               };
-                               if( !f ) alert( '**** ' + child.outerHTML );
-                       };
-               };
-               
-               r._xnodes = [];
-               Node.skipCreate = true;
-               /*
-                * http://support.microsoft.com/kb/812417/ja
-                * PRB: outerHTML の HTML 要素のプロパティは、既定の属性は表示されません。
-                * 
-                * body.innerHTML でなく、 body.outerHTML
-                */
-               r._xnodes.push.apply( r._xnodes, X.Dom.parse( body.innerHTML, true ) );
-               delete Node.skipCreate;
-               createTree( r, body.children );
-               r._ie4reserveUpdate();
-               //alert(n +  ' ' + body.innerHTML);
-               r._ie4startUpdate();
-               //alert(n +  ' ' + body.innerHTML);
-       } else {
-               
-       };
-       
-       //r.width  = new Function( 'return X.Dom.getSize()[ 0 ]' );
-       //r.height = new Function( 'return X.Dom.getSize()[ 1 ]' );
-       
-       Node._systemNode = r.create( 'div' ).className( 'hidden-sysyem-node' );
-       r._xnodes.splice( r._xnodes.indexOf( Node._systemNode ), 1 ); // hide from api user
-} );
-
-
+/**\r
+ * use X.Callback\r
+ * \r
+ * http://d.hatena.ne.jp/uupaa/20100430/1272561922\r
+ * \r
+ */\r
+\r
+if( X.Dom.EVENT_W3C ){\r
+       X.Dom.Event = function( e, xnode ){\r
+               //this._event        = e;\r
+               this.type          = X.Dom.Event.RenameTo[ e.type ] || e.type;\r
+               \r
+               //http://www.quirksmode.org/js/events_properties.html\r
+               if( e.target ){\r
+                       this.target        = Node._getXNode( e.target.nodeType === 3 ? e.target.parentNode : e.target );// defeat Safari bug // xnode\r
+               };\r
+               if( e.relatedTarget ){\r
+                       this.relatedTarget = Node._getXNode( e.relatedTarget.nodeType === 3 ? e.relatedTarget.parentNode : e.relatedTarget ); // xnode\r
+               };\r
+               \r
+               this.currentTarget = xnode; // xnode\r
+               this.eventPhase    = e.eventPhase;\r
+               \r
+               this.clientX       = e.clientX;\r
+               this.clientY       = e.clientY;\r
+               //this.screenX       = e.screenX;\r
+               //this.screenY       = e.screenY;\r
+               this.pageX         = e.pageX;\r
+               this.pageY         = e.pageY;\r
+               this.offsetX       = e.offsetX || e.layerX;\r
+               this.offsetY       = e.offsetY || e.layerY;\r
+               \r
+               this.keyCode       = e.keyCode;\r
+               this.altKey        = e.altKey;\r
+               this.ctrlKey       = e.ctrlKey;\r
+               this.shiftKey      = e.shiftKey;\r
+               \r
+               // http://www.programming-magic.com/20090127231544/\r
+               this.which         = e.which || ( e.button + 1 ); // 左:1, 中:2, 右:3\r
+               \r
+               // https://developer.mozilla.org/ja/docs/DOM/DOM_event_reference/mousewheel\r
+               \r
+               // TODO\r
+               // https://w3g.jp/blog/tools/wheelevent_crossbrowser\r
+               // ホイール系イベント2014年版クロスブラウザ\r
+               if( e.wheelDeltaY !== undefined ){\r
+                       this.wheelDeltaX = e.wheelDeltaX / 12;\r
+                       this.wheelDeltaY = e.wheelDeltaY / 12;\r
+               } else\r
+               if( e.wheelDelta !== undefined ){\r
+                       this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;\r
+               } else\r
+               if( e.detail !== undefined ){\r
+                       this.wheelDeltaX = this.wheelDeltaY = - e.detail * 3;\r
+               } else {\r
+                       this.wheelDeltaX = this.wheelDeltaY = 0;\r
+               };\r
+               \r
+               if( e.constructor === window.TouchEvent ){\r
+                       // TouchEvent\r
+                       this.touches        = e.touches;\r
+                       this.changedTouches = e.changedTouches;\r
+                       this.targetTouches  = e.targetTouches;\r
+                       this.metaKey        = e.metaKey;\r
+                       this.force          = e.force || e.webkitForce || 0;\r
+               } else\r
+               if( e.constructor === window.PointerEvent ){\r
+                       // PointerEvent;\r
+                       this.currentPoint  = e.currentPoint;\r
+                       this.width         = e.width;\r
+                       this.height        = e.height;\r
+                       this.timeStamp     = e.timeStamp;\r
+                       this.hwTimestamp   = e.hwTimestamp;\r
+                       this.intermediatePoints = e.intermediatePoints;\r
+                       this.isPrimary     = e.isPrimary;\r
+                       this.pointerId     = e.pointerId;\r
+                       this.pointerType   = e.pointerType;\r
+                       this.pressure      = e.pressure;\r
+                       this.tiltX         = e.tiltX;\r
+                       this.tiltY         = e.tiltY;\r
+               };\r
+       };\r
+} else {\r
+       X.Dom.Event = function( e, xnode, element ){\r
+               var btn;\r
+               \r
+               //this._event        = e;\r
+               this.type          = e.type;\r
+               this.target        = Node._getXNode( e.srcElement ); // xnode\r
+               if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか?\r
+               this.currentTarget = xnode; // xnode\r
+               this.relatedTarget = Node._getXNode( e.formElement ? e.formElement : e.toElement ); // xnode\r
+               this.eventPhase    = e.srcElement === element ? 2: 3;\r
+               \r
+               this.clientX       = e.clientX;\r
+               this.clientY       = e.clientY;\r
+               //this.screenX       = e.screenX;\r
+               //this.screenY       = e.screenY;\r
+               \r
+               if( X.Dom._root ){ // uuu...\r
+                       \r
+                       this.pageX         = e.clientX + X.Dom._root.scrollLeft;\r
+                       this.pageY         = e.clientY + X.Dom._root.scrollTop;\r
+                       \r
+                       // DOMAssistant 2.8.1\r
+                       //event.pageX = DOMAssistant.def(e.pageX)? e.pageX : (event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0));\r
+                       //event.pageY = DOMAssistant.def(e.pageY)? e.pageY : (event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0));                                                     \r
+               };\r
+               \r
+\r
+               \r
+               if( X.UA.IE && 5 <= X.UA.IE ){\r
+                       this.offsetX       = e.offsetX; // イベントターゲット左上からの座標\r
+                       this.offsetY       = e.offsetY;                 \r
+               }// else\r
+               //if( e.srcElement ){\r
+               //      this.offsetX       = e.x - e.srcElement.offsetLeft; // e.x はイベント発生要素の親要素を基準にした座標。\r
+               //      this.offsetY       = e.y - e.srcElement.offsetTop;      \r
+               //};\r
+               \r
+               this.keyCode       = e.keyCode;\r
+               this.altKey        = e.altKey;\r
+               this.ctrlKey       = e.ctrlKey;\r
+               this.shiftKey      = e.shiftKey;\r
+               \r
+               // http://www.programming-magic.com/20090127231544/\r
+               switch( this.type ){\r
+                       case 'click'    :\r
+                       case 'dblclick' :\r
+                               this.which = 1;\r
+                               break;\r
+                       case 'contextmenu' :\r
+                               this.which = 3;\r
+                               break;\r
+                       default :\r
+                               btn = e.button;\r
+                               this.which =\r
+                                       btn & 1 ? 1 :\r
+                                       btn & 4 ? 2 :\r
+                                       btn & 2 ? 3 : 0; // 左:1(click:0), 中:4, 右:2\r
+               };\r
+               this.wheelDeltaX = this.wheelDeltaY = e.wheelDelta / 12;\r
+       };\r
+};\r
+\r
+X.Dom.Event.DOM_PRE_INIT        = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.DOM_BUILDER_COMPLETE= ++X.Event._LAST_EVENT;\r
+X.Dom.Event.DOM_INIT            = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.XDOM_READY          = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.VIEW_ACTIVATE       = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.VIEW_DEACTIVATE     = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.VIEW_RESIZED        = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.BASE_FONT_RESIZED   = ++X.Event._LAST_EVENT;\r
+// same_page_jump\r
+// on_screen_keyboard_show\r
+// on_screen_keyboard_hide\r
+// X.Dom.Event.BEFORE_UPDATE       = ++X.Event._LAST_EVENT; // このイベントで要素のサイズを取得すると無限ループに!\r
+X.Dom.Event.AFTER_UPDATE        = ++X.Event._LAST_EVENT;\r
+// hash_change\r
+X.Dom.Event.BEFORE_UNLOAD       = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.UNLOAD              = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.LOAD_BEFORE_STOP    = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.LOAD_ASSET_STOP     = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.LOAD_ASSET_COMPLETE = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.LOAD_ASSET_ERROR    = ++X.Event._LAST_EVENT;\r
+\r
+X.Dom.Event.ANIME_BEFORE_START  = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.ANIME_START         = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.ANIME               = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.ANIME_END           = ++X.Event._LAST_EVENT;\r
+X.Dom.Event.ANIME_BEFORE_STOP   = ++X.Event._LAST_EVENT; // xnode.stop() のみ、指定時間による停止では呼ばれない\r
+X.Dom.Event.ANIME_STOP          = ++X.Event._LAST_EVENT;\r
+X.Dom.Event._LAST_EVENT         = X.Event._LAST_EVENT; // ここに書いてあるイベントの最後の値 X.Dom.Event.ANIME_STOP と同じ値\r
+\r
+X.Dom.Event.Rename = {};\r
+X.Dom.Event.RenameTo = {};\r
+// https://github.com/georgeadamson/jQuery.prefixfree-events/blob/master/jQuery.prefixfree-events.js\r
+\r
+if( window.onwebkitanimationend !== undefined && window.onanimationend === undefined ){\r
+         X.Dom.Event.Rename[ 'animationend' ]             = 'webkitAnimationEnd';\r
+       X.Dom.Event.RenameTo[ 'webkitAnimationEnd' ]       = 'animationend';\r
+         X.Dom.Event.Rename[ 'animationstart' ]           = 'webkitAnimationStart';\r
+       X.Dom.Event.RenameTo[ 'webkitAnimationStart' ]     = 'animationstart';\r
+         X.Dom.Event.Rename[ 'animationiteration' ]       = 'webkitAnimationIteration';\r
+       X.Dom.Event.RenameTo[ 'webkitAnimationIteration' ] = 'animationiteration';\r
+} else\r
+if( window.onoanimationend !== undefined && window.onanimationend === undefined ){\r
+         X.Dom.Event.Rename[ 'animationend' ]        = 'oAnimationEnd';\r
+       X.Dom.Event.RenameTo[ 'oAnimationEnd' ]       = 'animationend';\r
+         X.Dom.Event.Rename[ 'animationstart' ]      = 'oAnimationStart';\r
+       X.Dom.Event.RenameTo[ 'oAnimationStart' ]     = 'animationstart';\r
+         X.Dom.Event.Rename[ 'animationiteration' ]  = 'oAnimationIteration';\r
+       X.Dom.Event.RenameTo[ 'oAnimationIteration' ] = 'animationiteration';\r
+} else\r
+/*\r
+if( window.onmozanimationend !== undefined && window.onanimationend === undefined ){\r
+         X.Dom.Event.Rename[ 'animationend' ]          = 'mozAnimationEnd';\r
+       X.Dom.Event.RenameTo[ 'mozAnimationEnd' ]       = 'animationend';\r
+         X.Dom.Event.Rename[ 'animationstart' ]        = 'mozAnimationStart';\r
+       X.Dom.Event.RenameTo[ 'mozAnimationStart' ]     = 'animationstart';\r
+         X.Dom.Event.Rename[ 'animationiteration' ]    = 'mozAnimationIteration';\r
+       X.Dom.Event.RenameTo[ 'mozAnimationIteration' ] = 'animationiteration';\r
+} else*/\r
+if( document.documentElement && document.documentElement.style.msAnimation !== undefined && document.documentElement.style.animation === undefined ){ //document.documentElement.style.msAnimation \r
+         X.Dom.Event.Rename[ 'animationend' ]         = 'MSAnimationEnd';\r
+       X.Dom.Event.RenameTo[ 'MSAnimationEnd' ]       = 'animationend';\r
+         X.Dom.Event.Rename[ 'animationstart' ]       = 'MSAnimationStart';\r
+       X.Dom.Event.RenameTo[ 'MSAnimationStart' ]     = 'animationstart';\r
+         X.Dom.Event.Rename[ 'animationiteration' ]   = 'MSAnimationIteration';\r
+       X.Dom.Event.RenameTo[ 'MSAnimationIteration' ] = 'animationiteration';\r
+};\r
+// https://developer.mozilla.org/en-US/docs/Web/Events/transitionend\r
+// chrome1+, firefox4+, IE10+, Opera10.5+, Safari3.2+, Android2.1+\r
+if( window.onwebkittransitionend !== undefined && window.ontransitionend === undefined ){\r
+         X.Dom.Event.Rename[ 'transitionend' ]       = 'webkitTransitionEnd';\r
+       X.Dom.Event.RenameTo[ 'webkitTransitionEnd' ] = 'transitionend';\r
+} else\r
+if( window.onotransitionend !== undefined && window.ontransitionend === undefined ){\r
+       if( X.UA.Opera < 12 ){\r
+                 X.Dom.Event.Rename[ 'transitionend' ]  = 'oTransitionEnd';\r
+               X.Dom.Event.RenameTo[ 'oTransitionEnd' ] = 'transitionend';\r
+       } else {\r
+                 X.Dom.Event.Rename[ 'transitionend' ]  = 'otransitionEnd';\r
+               X.Dom.Event.RenameTo[ 'otransitionEnd' ] = 'transitionend';\r
+       };\r
+} else\r
+if( window.onmoztransitionend !== undefined && window.ontransitionend === undefined ){\r
+         X.Dom.Event.Rename[ 'transitionend' ]    = 'mozTransitionEnd';\r
+       X.Dom.Event.RenameTo[ 'mozTransitionEnd' ] = 'transitionend';\r
+};\r
+\r
+\r
+if( navigator.msPointerEnabled && !navigator.pointerEnabled ){\r
+         X.Dom.Event.Rename[ 'pointerdown'     ] = 'MSPointerDown';\r
+       X.Dom.Event.RenameTo[ 'MSPointerDown'   ] = 'pointerdown';\r
+         X.Dom.Event.Rename[ 'pointerup'       ] = 'MSPointerUp';\r
+       X.Dom.Event.RenameTo[ 'MSPointerUp'     ] = 'pointerup';\r
+         X.Dom.Event.Rename[ 'pointermove'     ] = 'MSPointerMove';\r
+       X.Dom.Event.RenameTo[ 'MSPointerMove'   ] = 'pointermove';\r
+         X.Dom.Event.Rename[ 'pointercancel'   ] = 'MSPointerCancel';\r
+       X.Dom.Event.RenameTo[ 'MSPointerCancel' ] = 'pointercancel';\r
+};\r
+\r
+\r
+\r
+X.Dom.Node.prototype.listen = function( type, arg1, arg2, arg3 /* [ listener || ( context + function ) || function ][ arguments ] */ ){\r
+       var elm;\r
+       \r
+       if( this._xnodeType === 0 || this._xnodeType === 3 || !arg1 ) return this;\r
+       \r
+       ( !this._listeners || !this._listeners[ type ] ) && X.Type.isString( type ) && this._addEvent( type );\r
+       \r
+       return typeof arg1 === 'function' ?\r
+               X.EventDispatcher.prototype.listen.call( this, type, this, arg1, arg2 ) :\r
+               X.EventDispatcher.prototype.listen.apply( this, arguments );\r
+};\r
+\r
+X.Dom.Node.prototype._addEvent =\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.Dom.EVENT_W3C && X.UA.Safari && X.UA.Safari < 3 ?\r
+               (function( type ){\r
+                       var raw = this._rawNode;\r
+                       if( !raw ) return;\r
+                       this._handleEvent = this._handleEvent || X.Callback.create( this );\r
+                       if( this._xnodeType === 4 ){ // Image\r
+                               raw[ 'on' + type ] = this._handleEvent;\r
+                       } else {\r
+                               raw.addEventListener( type, this._handleEvent, false );\r
+                       };\r
+               }) :\r
+       X.Dom.EVENT_W3C && X.UA.Opera7 ?\r
+               (function( type ){\r
+                       var raw = this._rawNode;\r
+                       if( !raw ) return;\r
+                       this._handleEvent = this._handleEvent || X.Callback.create( this );\r
+                       if( raw === window ){\r
+                               raw[ 'on' + type ] = this._handleEvent;\r
+                       } else {\r
+                               raw.addEventListener( type, this._handleEvent, false );\r
+                       };\r
+               }) :\r
+       X.Dom.EVENT_W3C ?\r
+               (function( type ){\r
+                       this._rawNode && this._rawNode.addEventListener( X.Dom.Event.Rename[ type ] || type, this, false );\r
+               }) :\r
+       X.Dom.EVENT_IE ?\r
+               (function( type ){\r
+                       if( !this._rawNode ) return;\r
+                       this._handleEvent = this._handleEvent || X.Callback.create( this );\r
+                       this._rawNode.attachEvent( 'on' + type, this._handleEvent );\r
+               }) :\r
+               (function( type ){\r
+                       var elm = this._rawNode || ( this._ie4getRawNode && this._ie4getRawNode() );\r
+                       if( !elm ) return;\r
+                       this._handleEvent = elm[ 'on' + type ] = this._handleEvent || X.Callback.create( this );\r
+               });\r
+\r
+\r
+X.Dom.Node.prototype.unlisten = function( type /* , arg1, arg2, arg3 */ ){\r
+       var list = this._listeners,\r
+               l    = !this._dispatching && list && type !== undefined && list[ type ] && list[ type ].length;\r
+       \r
+       X.EventDispatcher.prototype.unlisten.apply( this, arguments );\r
+       \r
+       l && !list[ type ] && X.Type.isString( type ) && this._removeEvent( type );\r
+       \r
+       return this;\r
+};\r
+\r
+X.Dom.Node.prototype._removeEvent =\r
+       X.Dom.EVENT_W3C && X.UA.Safari && X.UA.Safari < 3 ?\r
+               (function( type ){\r
+                       var raw = this._rawNode;\r
+                       if( !raw ) return;\r
+                       \r
+                       if( this._xnodeType === 4 ){ // Image\r
+                               raw[ 'on' + type ] = '';\r
+                       } else {\r
+                               raw.removeEventListener( type, this._handleEvent, false );\r
+                       };\r
+                       if( !this._listeners ){\r
+                               X.Callback._correct( this._handleEvent );\r
+                               delete this._handleEvent;\r
+                       };\r
+               }) :\r
+       X.Dom.EVENT_W3C && X.UA.Opera7 ?\r
+               (function( type ){\r
+                       var raw = this._rawNode;\r
+                       if( !raw ) return;\r
+                       \r
+                       if( raw === window ){\r
+                               raw[ 'on' + type ] = null;\r
+                       } else {\r
+                               raw.removeEventListener( type, this._handleEvent, false );\r
+                       };\r
+                       if( !this._listeners ){\r
+                               X.Callback._correct( this._handleEvent );\r
+                               delete this._handleEvent;\r
+                       };\r
+               }) :\r
+       X.Dom.EVENT_W3C ?\r
+               (function( type ){\r
+                       var elm = this._rawNode;\r
+                       if( !elm ) return;\r
+                       elm.removeEventListener( X.Dom.Event.Rename[ type ] || type, this, false );\r
+               }) :\r
+       X.Dom.EVENT_IE ?\r
+               (function( type ){\r
+                       var elm = this._rawNode;\r
+                       if( !elm ) return;\r
+                       elm.detachEvent( 'on' + type, this._handleEvent );\r
+                       if( !this._listeners ){\r
+                               X.Callback._correct( this._handleEvent );\r
+                               delete this._handleEvent;\r
+                       };\r
+               }) :\r
+               (function( type ){\r
+                       var elm = this._rawNode || ( this._ie4getRawNode && this._ie4getRawNode() );\r
+                       if( !elm ) return;\r
+                       elm[ 'on' + type ] = X.emptyFunction;\r
+                       elm[ 'on' + type ] = '';\r
+                       if( !this._listeners ){\r
+                               X.Callback._correct( this._handleEvent );\r
+                               delete this._handleEvent;\r
+                       };\r
+               });\r
+\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
+\r
+X.Dom.Node.prototype.handleEvent =\r
+       X.Dom.EVENT_W3C ?\r
+               (function( e ){\r
+                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( e, this ) );\r
+                       \r
+                       if( ret & X.Callback.STOP_PROPAGATION ){\r
+                               e.stopPropagation();\r
+                       };\r
+                       if( ret & X.Callback.PREVENT_DEFAULT ){\r
+                               this._tag === 'A' && this._rawNode.blur();\r
+                               e.preventDefault();\r
+                               if( X.UA.Safari && X.UA.Safari < 3 ){\r
+                                       if( e.type === 'click' || e.type === 'dbclick' ){\r
+                                               X.Dom._safariPreventDefault = true;\r
+                                       };\r
+                               };\r
+                               return false;\r
+                       };\r
+               }) :\r
+               (function(){\r
+                       var ret = X.EventDispatcher.prototype.dispatch.call( this, new X.Dom.Event( event, this, this._rawNode ) );\r
+\r
+                       if( ret & X.Callback.STOP_PROPAGATION ){\r
+                               event.cancelBubble = true;\r
+                       };\r
+                       if( ret & X.Callback.PREVENT_DEFAULT ){\r
+                               this._tag === 'A' && this._rawNode.blur();\r
+                               return event.returnValue = false;\r
+                       };\r
+               });\r
+\r
+\r
+// イベントの退避、dom が画面から抜かれる場合に実施しておく\r
+X.Dom.Node.prototype._migrateEvent = function(){\r
+       var hash = this._listeners,\r
+               type;\r
+       if( !hash ) return;\r
+       for( type in hash ){\r
+               this._removeEvent( type );\r
+       };\r
+};\r
+\r
+// 退避したイベントの復帰\r
+X.Dom.Node.prototype._restoreEvent = function(){\r
+       var hash = this._listeners,\r
+               type;\r
+       if( !hash ) return;\r
+       for( type in hash ){\r
+               this._addEvent( type );\r
+       };\r
+};\r
+\r
+/* -----------------------------------------------\r
+ * Document Ready\r
+ *  Dean Edwards/Matthias Miller/John Resig\r
+ */\r
+\r
+// SafariでJavaScriptのデバッグをする方法\r
+// safari1.3 可\r
+// http://shimax.cocolog-nifty.com/search/2006/09/safarijavascrip_c54d.html\r
+\r
+/* for ie9+/Mozilla/Opera9 */\r
+if( X.Dom.EVENT_W3C ){\r
+       Node._document.listenOnce( 'DOMContentLoaded', X.Dom._init );\r
+} else\r
+if( 6 <= X.UA.IE && X.inHead ){\r
+       // if this script in Head\r
+       document.write( "<script id=__ie_onload defer src=javascript:void(0)><\/script>" );\r
+       X.Dom._script = document.getElementById( "__ie_onload" );\r
+       X.Dom._script.onreadystatechange = function(){\r
+               var s = X.Dom._script;\r
+               if( s && s.readyState === 'complete' ){\r
+                       s.onreadystatechange = X.emptyFunction;\r
+                       s.onreadystatechange = null;\r
+                       s.parentNode.removeChild( s );\r
+                       delete X.Dom._script;\r
+                       X.Dom._init && X.Dom._init();\r
+               };\r
+       };\r
+};\r
+// Re: onLoad doesn't work with Safari?\r
+// http://lists.apple.com/archives/web-dev/2003/Oct/msg00036.html\r
+if( X.UA.WebKit || ( X.UA.Safari && X.UA.Safari < 3 ) ){ // sniff\r
+       X.Timer.add( 10, function(){\r
+               if( !X.Dom._init ) return X.Callback.UN_LISTEN;\r
+               if( 'loaded|complete'.indexOf( document.readyState ) !== -1 ) return X.Dom._init();\r
+       });\r
+};\r
+\r
+/* for other browsers */\r
+Node._window.listenOnce( 'load', X.Dom._init );\r
+//\r
+X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){\r
+       console.log( 'X.Dom XDomReady ' + X.Dom.readyState );\r
+} );\r
+\r
+if( X.UA.Safari && X.UA.Safari < 3 ){\r
+       document.documentElement.onclick =\r
+       document.documentElement.ondbclick = function( e ){\r
+                       if( X.Dom._safariPreventDefault ){\r
+                               X.Dom._safariPreventDefault = false;\r
+                               e.preventDefault();\r
+                               return false;\r
+                       };\r
+               };\r
+};\r
+\r
+X.Dom.listen( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ); } );\r
+\r