-/**
- * use X.Callback
- *
- * http://d.hatena.ne.jp/uupaa/20100430/1272561922
- *
- */
-
-if( window.addEventListener ){
- X.Dom.Event = function( e, xnode ){
- //this._event = e;
- this.type = e.type;
-
- //http://www.quirksmode.org/js/events_properties.html
- this.target = Node._getXNode( e.target.nodeType === 3 ? e.target.parentNode : e.target );// defeat Safari bug // xnode
-
- this.currentTarget = xnode; // xnode
- this.relatedTarget = Node._getXNode( 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.metaKey = e.metaKey;
- } 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, xnode, element ){
- var btn;
-
- //this._event = e;
- this.type = e.type;
- this.target = Node._getXNode( e.srcElement ); // xnode
- if( this.target && this.target._xnodeType === 3 ) this.target = this.target.parent; // ie4 の fake Textnode がヒットしていないか?
- this.currentTarget = xnode; // xnode
- this.relatedTarget = Node._getXNode( 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;
-
- // DOMAssistant 2.8.1
- //event.pageX = DOMAssistant.def(e.pageX)? e.pageX : (event.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0));
- //event.pageY = DOMAssistant.def(e.pageY)? e.pageY : (event.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0));
- };
-
-
-
- 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 = !this._dispatching && list && type !== undefined && list[ type ] && list[ type ].length;
-
- X.EventDispatcher.prototype.unlisten.apply( this, arguments );
-
- 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, this ) );
-
- 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, 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 ) :
- document.getElementsByTagName ?
- new Node( document.getElementsByTagName( 'html' )[ 0 ] ) :
- document.all ?
- new Node( document.all.tags( 'html' )[ 0 ] ) :
- null;
-
- var r = Node.root = new Node( document.body ),
- body = r._rawNode,
- createTree, xnodes, s, i, n = 0;
- r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
-
- r._root = Node._html._root = r;
- r.parent = Node._html;
- //r.width = new Function( 'return X.Dom.getSize()[ 0 ]' );
- //r.height = new Function( 'return X.Dom.getSize()[ 1 ]' );
-
- // todo: cleanup tree
-
- body.childNodes && (function( elm, skip, head ){
- var me = arguments.callee,
- moveToHead = 'style,bgsound,area,base,meta'.split( ',' ),
- remove = 'script,noscript,noframes,comment,!,noembed,nolayer'.split( ',' ),
- noncleanup = 'pre,textarea,code,kbd,samp,xmp,plaintext,listing'.split( ',' ),
- nodes = elm.childNodes,
- i = 0,
- node, tag, textNode, content;
- for( ; i < nodes.length; ){
- node = nodes[ i ];
- switch( node.nodeType ){
- case 1 :
- tag = node.tagName.toLowerCase();
- if( moveToHead.indexOf( tag ) !== -1 ){
- head = head || document.getElementsByTagName( 'head' )[ 0 ];
- head.appendChild( node );
- continue;
- } else
- if( remove.indexOf( tag ) !== -1 ){
- node.parentNode.removeChild( node );
- continue;
- } else {
- // pre タグ以下はスペースの置換は行わない
- me( node, skip || noncleanup.indexOf( tag ) !== -1, head );
- };
- textNode = false;
- ++i;
- break;
- case 3 :
- content = skip ? node.data : X.Dom.cleanupWhiteSpace( node.data );
- //console.log( 'Delete space ' + node.data.length + ' => ' + content.length );
- if( !textNode && content !== ' ' && content.length ){
- node.data = content;
- textNode = node;
- ++i;
- break;
- } else
- if( textNode ){
- textNode.data += content; // 直前が TextNode の場合 一本化して削除
- };
- // ブロック要素直下のスペースだけは削除??
- default :
- //console.log( 'Remove type: ' + node.nodeType + ' value: ' + node.nodeValue );
- elm.removeChild( node );
- //++count;
- };
- };
- })( body );
-
- createTree =
- body.childNodes ?
- (function( xnode, childNodes, skipCleanup ){
- var i = 0,
- j = 0,
- child, _xnode, f, tag, text, _xtext;
- childNodes = X.copyArray( childNodes );
-
- for( ; i < childNodes.length; ++i ){
- child = childNodes[ i ];
- if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || child.tagName === '!' ){
- child.parentNode.removeChild( child );
- continue;
- };
- f = false;
- while( xnode._xnodes && j < xnode._xnodes.length ){
- _xnode = xnode._xnodes[ j ];
- _xnode.parent = xnode;
-
- if( _xnode._xnodeType === 1 ){
- if( child.nodeType !== 1 ){
- if( !( text = child.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- child.parentNode.removeChild( child );
- break;
- };
- alert( '[' +xnode._tag + '>' +_xnode._tag + '] !== ' + child.nodeType + '\n' + child.data );
- ++j;
- continue;
- };
- tag = child.tagName;
- if( _xnode._tag.toUpperCase() !== tag ){
- alert( '[' +xnode._tag + '>' +_xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] !== ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + '\n' + child.outerHTML );
- ++j;
- continue;
- } else {
- _xnode._rawNode = child;
- _xnode._root = xnode._root;
- child.UID = _xnode._uid;
- if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){ // ie で body 内の script が2度よばれるのに対処
- //alert( '[' +xnode._tag + '>' + _xnode._tag + '] remove ... ' );
- _xnode.destroy();
- ++n;
- continue;
- } else {
- //alert( '[' +xnode._tag + '>' + _xnode._tag + ' ' + (_xnode._xnodes ? _xnode._xnodes.length : '' ) + '] === ' + child.tagName + ' ' + (child.childNodes ? child.childNodes.length : '' ) + ' Hit\n' + child.outerHTML );
- child.childNodes.length && createTree( _xnode, child.childNodes, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
- };
- _xtext = null;
- f = true;
- ++j;
- break;
- };
- } else
- if( _xnode._xnodeType === 3 ){
- if( child.nodeType !== 3 ){
- if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
- _xnode.destroy();
- ++n;
- continue;
- };
- alert( xnode._tag + '>' + '"' + _xnode._text + '" !== ' + child.tagName + '\n' + child.outerHTML );
- ++j;
- continue;
- };
-
- _xnode._rawNode = child;
- _xnode._root = xnode._root;
- if( !skipCleanup ){
- if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
- _xnode.destroy();
- ++n;
- continue;
- };
- if( _xtext ){
- _xtext.text( _xtext._text + text );
- console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );
- _xnode.destroy();
- ++n;
- continue;
- } else {
- //alert( xnode._tag + '>' + '"' + text + '"\n' + child.data );
- _xnode.text( text );
- };
- } else
- if( _xtext ){
- _xtext.text( _xtext._text + _xnode.text );
- console.log( '[' +xnode._tag + '>' + _xnode._uid + '] xtext,destroy ... ' );
- _xnode.destroy();
- ++n;
- continue;
- };
- _xtext = _xtext || _xnode;
- ++j;
- break;
- } else {
- alert( 'no hit!' );
- };
- ++j;
-
- };
- //if( !f ) alert( '**** ' + child.outerHTML );
- };
- while( xnode._xnodes && j < xnode._xnodes.length ){
- _xnode = xnode._xnodes[ j ];
- _xnode.parent = xnode;
- _xnode.destroy();
- ++n;
- continue;
- };
- }) :
- body.children ?
- (function( xnode, children, skipCleanup ){
- var parent = xnode,
- xnodes = parent._xnodes,
- l = xnodes && xnodes.length,
- m = children.length,
- i = 0, j = 0, flag = 0,
- elm, tag, xtext, text;
- //children = X.copyArray( children );
-
- for( ; i < xnodes.length; ++i ){
- xnode = xnodes[ i ];
- xnode.parent = parent;
-
- if( xnode._xnodeType === 3 ){
- //alert( X.Dom.cleanupWhiteSpace( xnode._text ) );
- if( !skipCleanup ){
- if( !( text = xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- xnode.destroy();
- --i;
- } else
- if( xtext ){
- //alert( 'xtext ' + text.charCodeAt( 0 ) + ' : ' + text.length );
- xtext.text( xtext._text + text );
- xnode.destroy();
- --i;
- } else {
- //alert( 'xnode ' + text.charCodeAt( 0 ) + ' : ' + text.length );
- xnode.text( text );
- };
- } else
- if( xtext ){
- //alert( 'skip ' + text.charCodeAt( 0 ) + ' : ' + text.length );
- xtext.text( xtext._text + xnode._text );
- xnode.destroy();
- --i;
- };
- flag |= 4;
- xtext = xtext || xnode;
- continue;
- };
-
- if( xnode._xnodeType !== 1 ){
- //alert( xnode._xnodeType )
- continue;
- };
-
- for( ; j < m; ++j ){
- elm = children[ j ];
- tag = elm.tagName;
-
- if( tag === '!' ){
- continue;
- } else
- if( xnode._tag !== tag ){
- alert( xnode._tag + ' ' + xnode._xnodeType + ' !== ' + tag + '\n' + elm.outerHTML );
- } else {
- xnode._rawNode = elm;
- xnode._root = parent._root;
- if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) || tag === 'SCRIPT' ){
- xnode.destroy();
- --i;
- break;
- } else {
- xnode._xnodes && xnode._xnodes.length && createTree( xnode, elm.children, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
-
- !xnode._id && ( elm.id = 'ie4uid' + xnode._uid );
- elm.setAttribute( 'UID', xnode._uid );
-
- tag === 'INPUT' && (
- !xnode._attrs ?
- ( xnode._attrs = { type : 'text' } ) :
- ( !xnode._attrs.type ) || ( xnode._attrs.type = 'text' )
- );
- flag |= 3;
- xtext = null;
- break;
- };
- };
- };
- // for
- if( !xnode._rawNode ){
- alert( xnode._tag + ' ' + xnode._id + ' !== none...' );
- --i;
- };
- ++j;
- flag &= 6;
- };
- // textNode がある
- ( flag & 6 ) && ( parent._dirty |= X.Dom.Dirty.IE4_TEXTNODE_FIX );
- //( flag & 4 ) && ( parent._state |= X.Dom.Dirty.ONLY_TEXTNODE );
- }) : 0;
-
- r._xnodes = xnodes = [];
- // body の属性値の取得
-
- Node.skipCreate = true;
- /*
- * http://support.microsoft.com/kb/812417/ja
- * PRB: outerHTML の HTML 要素のプロパティは、既定の属性は表示されません。
- *
- * body.innerHTML でなく、 body.outerHTML にはできなかった、、、
- */
- xnodes.push.apply( xnodes, X.Dom.parse( body.innerHTML, true ) );
- delete Node.skipCreate;
-
- //alert(n + ' ' + body.innerHTML);
-
- createTree( r, body.childNodes || body.children );
- //r._dirty = X.Dom.Dirty.IE4_TEXTNODE_FIX;
-
- i = xnodes.length;
- Node._systemNode = s = r.create( 'div' ).className( 'hidden-sysyem-node' );
- //alert( i + ' -> ' + xnodes.length );
-
- r._startUpdate();
-
- xnodes.splice( xnodes.indexOf( s ), 1 ); // hide from api user
-
- //alert(n + ' ' + body.innerHTML);
-} );
-
-
+/**\r
+ * use X.Callback\r
+ * \r
+ * http://d.hatena.ne.jp/uupaa/20100430/1272561922\r
+ * \r
+ */\r
+\r
+if( window.addEventListener ){\r
+ X.Dom.Event = function( e, xnode ){\r
+ //this._event = e;\r
+ this.type = e.type;\r
+ \r
+ //http://www.quirksmode.org/js/events_properties.html\r
+ this.target = Node._getXNode( e.target.nodeType === 3 ? e.target.parentNode : e.target );// defeat Safari bug // xnode\r
+ \r
+ this.currentTarget = xnode; // xnode\r
+ this.relatedTarget = Node._getXNode( e.relatedTarget ); // 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
+ 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
+\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 ] ) && 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
+ X.Dom.EVENT_W3C ?\r
+ (function( type ){\r
+ this._rawNode && this._rawNode.addEventListener( 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._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 ] && this._removeEvent( type );\r
+ \r
+ return this;\r
+};\r
+\r
+X.Dom.Node.prototype._removeEvent =\r
+ X.Dom.EVENT_W3C ?\r
+ (function( type ){\r
+ var elm = this._rawNode;\r
+ if( !elm ) return;\r
+ elm.removeEventListener( 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();\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
+\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
+ 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
+\r
+/* -----------------------------------------------\r
+ * Document Ready\r
+ * Dean Edwards/Matthias Miller/John Resig\r
+ */\r
+/* for ie9+/Mozilla/Opera9 */\r
+if( X.Dom.DOM_W3C ){\r
+ X.Dom.Node._document.listenOnce( 'DOMContentLoaded', X.Dom._init );\r
+} else\r
+if( 5 <= 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
+ this.readyState === 'complete' && X.Dom._init();\r
+ };\r
+} else\r
+if( X.UA.WebKit ){ // 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
+X.Dom.Node._window.listenOnce( 'load', X.Dom._init );\r
+\r
+//\r
+X.Dom.listenOnce( X.Dom.Event.XDOM_READY, function(e){ console.log( 'X.Dom XDomReady ' + X.Dom.readyState ); } );\r
+\r
+X.Dom.listenOnce( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ); } );\r
+\r