-/**
- * 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
- 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;
- };
-
- 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, n = 0, xnodes, s;
- r.appendTo = r.appendToRoot = r.before = r.after = r.clone = r.remove = r.destroy = r.prevNode = r.nextNode = new Function( 'return this' );
-
- createTree =
- body.childNodes ?
- (function( xnode, childNodes, skipCleanup ){
- var i = 0,
- l,
- j = 0,
- child, _xnode, f, tag, text, _xtext, ary = [];
- //Array.prototype.push.apply( ary, childNodes );
- ary = X.copyArray( childNodes );
- childNodes = ary;
- l = childNodes.length;
- //xnode._dirtychildNodes = true;
- for( ; i < l; ++i ){
- child = childNodes[ i ];
- if( ( child.nodeType !== 1 && child.nodeType !== 3 ) || child.tagName === '!' ){
- child.parentNode.removeChild( child );
- continue;
- };
- //if( child.tagName === '!' ) continue;
- f = false;
- while( xnode._xnodes && j < xnode._xnodes.length ){
- _xnode = xnode._xnodes[ j ];
- _xnode.parent = xnode;
-
- if( _xnode._xnodeType === 1 ){
- _xtext = null;
- if( child.nodeType !== 1 ){
- if( !( text = child.data ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' || !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;
- child.UID = _xnode._uid;
- if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) ){
- //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() ) );
- };
- 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;
-
- 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;
- if( _xnode._xnodeType === 3 ){
- if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- console.log( '[' +xnode._tag + '>' + _xnode._uid + '] destroy ... ' );
- _xnode.destroy();
- ++n;
- continue;
- };
- };
- ++j;
- };
- }) :
- body.children ?
- (function( xnode, children, skipCleanup ){
- var i = 0,
- l = children.length,
- j = 0,
- flag = 0,
- child, _xnode, tag, text;
-
- xnode._dirtyChildren = true;
- for( ; i < l; ++i ){
- child = children[ i ];
- if( child.tagName === '!' ) continue;
- while( j < xnode._xnodes.length ){
- _xnode = xnode._xnodes[ j ];
- _xnode.parent = xnode;
-
- if( _xnode._xnodeType === 1 ){
- tag = child.tagName;
- if( _xnode._tag !== tag ){
- alert( _xnode._tag + ' !== ' + child.tagName + ' * ' + child.outerHTML );
- } else {
- _xnode._rawNode = child;
- !_xnode._id && child.setAttribute( 'id', ( _xnode._ie4uid = 'ie4uid' + _xnode._uid ) );
- child.setAttribute( 'UID', '' + _xnode._uid );
- if( 0 <= X.Dom.cleanupTagNames.indexOf( tag.toLowerCase() ) ){
- _xnode.destroy();
- ++n;
- continue;
- } else {
- child.children.length && createTree( _xnode, child.children, skipCleanup || 0 <= X.Dom.skipCleanupTagNames.indexOf( tag.toLowerCase() ) );
- tag === 'INPUT' && ( !_xnode._attrs || !_xnode._attrs.type ) && ( _xnode._attrs.type = 'text' );
- };
- flag |= 3;
- ++j;
- break;
- };
- } else
- if( _xnode._xnodeType === 3 ){
- flag |= 4;
- if( !skipCleanup ){
- if( !( text = _xnode._text ) || ( text = X.Dom.cleanupWhiteSpace( text ) ) === ' ' ){
- _xnode.destroy();
- ++n;
- continue;
- };
- _xnode.text( text );
- };
- };
- ++j;
- };
- if( !( flag & 1 ) ) alert( '**** ' + child.outerHTML );
- flag &= 6;
- };
- // textNode がある
- ( flag & 4 ) && ( xnode._dirty |= X.Dom.Dirty.IE4_TEXTNODE_FIX );
- }) :
- (function(){});
-
- 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.children );
-
- //r.width = new Function( 'return X.Dom.getSize()[ 0 ]' );
- //r.height = new Function( 'return X.Dom.getSize()[ 1 ]' );
- 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( 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
+};\r
+\r
+if( window.onwebkittransitionend !== undefined && window.ontransitionend === undefined ){\r
+ X.Dom.Event.Rename[ 'transitionend' ] = 'webkitTransitionEnd';\r
+ X.Dom.Event.RenameTo[ 'webkitTransitionEnd' ] = 'transitionend';\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 ?\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._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 ?\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();\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.DOM_W3C ){\r
+ 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
+// 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
+ /* for other browsers */\r
+ Node._window.listenOnce( 'load', X.Dom._init ); \r
+\r
+\r
+\r
+\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.listenOnce( X.Dom.Event.VIEW_RESIZED, function(e){ console.log( 'X.Dom VIEW_RESIZED ' + e.w + 'x' + e.h ); } );\r
+\r