X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F03_XDomEvent.js;h=391cdb9667a891f2a009ae13ca72454e6281acd3;hb=475df4df9670f042764a99c80d7716e994d28033;hp=6ba81c89d8d6bee59d21272222db461f7fd7f772;hpb=42e0982b02a99c71702ce8cd8740645aefdc8097;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/02_dom/03_XDomEvent.js b/0.6.x/js/02_dom/03_XDomEvent.js index 6ba81c8..391cdb9 100644 --- a/0.6.x/js/02_dom/03_XDomEvent.js +++ b/0.6.x/js/02_dom/03_XDomEvent.js @@ -1,4 +1,4 @@ -/** +/* * use X.Callback * * http://d.hatena.ne.jp/uupaa/20100430/1272561922 @@ -42,6 +42,14 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ this[ 'loaded' ] = e.loaded; this[ 'total' ] = e.total; break; + case 'dragstart' : + case 'dragenter' : + case 'dragover' : + case 'dragleave' : + case 'drop' : + case 'dragend' : + this[ 'dataTransfer' ] = e.dataTransfer; + break; }; //console.log( 'original : ' + originalType + ' > ' + type ); @@ -133,17 +141,17 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ 'isPrimary' : true, 'hwTimestamp' : time, 'timestamp' : time, - 'button' : e.button, - 'buttons' : e.buttons || e.button, + 'button' : /*e.button ||*/ ( force ? 0 : -1 ), + 'buttons' : /*e.buttons || e.button ||*/ ( force ? 1 : 0 ), 'altKey' : altKey, 'ctrlKey' : ctrlKey, 'metaKey' : metaKey, 'shiftKey' : shiftKey, - 'pointerId' : touch.identifier + 2, + 'pointerId' : touch.identifier + 2, // iOS4 は 変換が必要! //screenX : touch.screenX, //screenY : touch.screenY, - 'clientX' : touch.clientX, - 'clientY' : touch.clientY, + 'clientX' : touch.clientX || ( touch.pageX - X_ViewPort_scrollX ), // iOS4以下は clientX が undefined, コードでは入れ子のスクロールに対応できない + 'clientY' : touch.clientY || ( touch.pageY - X_ViewPort_scrollY ), 'pageX' : touch.pageX, 'pageY' : touch.pageY, 'offsetX' : touch.offsetX, // 要素上の座標を取得 @@ -155,6 +163,7 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ 'width' : touch.width || 0, 'height' : touch.height || 0 }; + console.log( 'e.pointerId = ' + touch.identifier ); }; return events.length === 1 ? events[ 0 ] : events; } else { @@ -196,7 +205,7 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ // http://www.programming-magic.com/20090127231544/ // Opera で button==2の場合、コンテキストメニューイベントを発火 「ツール」->「設定」->「詳細設定」->「コンテンツ」->「Javascriptオプション」で「右クリックを制御するスクリプトを許可する」 if( originalType === 'mousedown' && this[ 'button' ] === 2 && X_UA[ 'Opera' ] ){ - events = [ X_Object_clone( this ), X_Object_clone( this ) ]; + events = [ X_Object_copy( this ), X_Object_copy( this ) ]; events[ 1 ].type = 'contextmenu'; return events; }; @@ -204,11 +213,12 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ } else { // Other - this[ 'keyCode' ] = e.keyCode || e.which; - this[ 'altKey' ] = e.altKey; - this[ 'ctrlKey' ] = e.ctrlKey; - this[ 'shiftKey' ] = e.shiftKey; - this[ 'metaKey' ] = e.metaKey; + this[ 'keyCode' ] = X_Type_isFinite( e.keyCode ) ? e.keyCode : X_Type_isFinite( e.charCode ) ? e.charCode : e.which; + this[ 'charCode' ] = X_Type_isFinite( e.charCode ) ? e.charCode : e.which; + this[ 'altKey' ] = e.altKey || !!( e.modifiers & 1 ); + this[ 'ctrlKey' ] = e.ctrlKey || !!( e.modifiers & 2 ); + this[ 'shiftKey' ] = e.shiftKey || !!( e.modifiers & 4 ); + this[ 'metaKey' ] = e.metaKey || !!( e.modifiers & 8 );; this[ 'button' ] = e.button !== undefined ? e.button : e.which !== undefined ? e.which - 1 : -1; @@ -263,9 +273,11 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ if( this[ 'target' ] && !this[ 'target' ][ '_tag' ] ) this[ 'target' ] = this[ 'target' ].parent; // ie4 の fake Textnode がヒットしていないか? this[ 'currentTarget' ] = xnode; // xnode this[ 'relatedTarget' ] = X_Node_getXNode( e.formElement || e.toElement ); // xnode + this[ 'relatedTarget' ] && console.dir( 'relatide...' ); this[ 'eventPhase' ] = e.srcElement === element ? 2: 3; this[ 'keyCode' ] = e.keyCode; + this[ 'charCode' ] = e.keyCode; this[ 'altKey' ] = e.altKey; this[ 'ctrlKey' ] = e.ctrlKey; this[ 'shiftKey' ] = e.shiftKey; @@ -435,11 +447,10 @@ if( !navigator.pointerEnabled ){ X_Event_Rename[ 'pointerdown' ] = 'mousedown'; X_Event_Rename[ 'pointerup' ] = 'mouseup'; X_Event_Rename[ 'pointermove' ] = 'mousemove'; - X_Event_Rename[ 'pointercancel' ] = 'mouseleave';//?? + X_Event_Rename[ 'pointercancel' ] = document.documentElement.onmouseleave !== undefined ? 'mouseleave' : 'mouseout';//?? // Opera は ブラウザ設定から右クリックの通知を許可すると mousedown で e.button==2 が返る,キャンセルは可能?? - X_UA[ 'Opera' ] && ( - X_Event_Rename[ 'contextmenu' ] = 'mousedown' ); + X_UA[ 'Opera' ] && ( X_Event_Rename[ 'contextmenu' ] = 'mousedown' ); /* * buttons の無いブラウザには mouseup, mousedown を監視して、buttons フラグを更新し続ける