X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F02_dom%2F03_XDomEvent.js;h=5a8069fb075cdfaaa45530e5165783920a126398;hb=b28fd52ddc41a1c927f92fa7eeeb6891c41e55d9;hp=cba1424a4817f5cc6ac3b649526d12784bdd81dd;hpb=6c4c72f7e862c9f950bfb3562adda24c39498abd;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 cba1424..5a8069f 100644 --- a/0.6.x/js/02_dom/03_XDomEvent.js +++ b/0.6.x/js/02_dom/03_XDomEvent.js @@ -11,8 +11,10 @@ */ // http://msdn.microsoft.com/ja-jp/library/ie/dn255104%28v=vs.85%29.aspx -var X_Dom_Event_devicePixelRatio = window.devicePixelRatio || ( window.screen.deviceXDPI / window.screen.logicalXDPI ), - X_Dom_Event_convertMSPointerType = window.MSPointerEvent && [ 0, 0, 'touch', 'pen', 'mouse' ],/*{ +var X_Dom_Event_devicePixelRatio = window.devicePixelRatio || ( window.screen.deviceXDPI / window.screen.logicalXDPI ) || 1, + + X_Dom_Event_convertMSPointerType = ( !window.PointerEvent && window.MSPointerEvent ) && [ 0, 0, 'touch', 'pen', 'mouse' ], // WP8.1 は PointerEvent と MSPointerEvent 両方ある + /*{ '2' : 'touch', '3' : 'pen', '4' : 'mouse' @@ -20,6 +22,12 @@ var X_Dom_Event_devicePixelRatio = window.devicePixelRatio || ( window.screen.de X_Dom_Event_CANCEL_MOUSE = {}, X_DomEvent; +if( X_Dom_Event_devicePixelRatio !== 1 ){ + X_UA_classNameForHTML += ' dpr' + X_Dom_Event_devicePixelRatio; + + X_UA[ 'dpr' ] = X_Dom_Event_devicePixelRatio; +}; + if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ X_DomEvent = function( e, xnode ){ var originalType = e.type, @@ -42,6 +50,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 ); @@ -54,7 +70,7 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ this[ 'pressure' ] = e.pressure || ( e.button !== -1 ? 0.5 : 0 ); // ポインターの接触形状の スクリーン ピクセル単位の幅と高さ なので変換。(多分、、、) this[ 'width' ] = e.width / X_Dom_Event_devicePixelRatio; - this[ 'height' ] = e.height / X_Dom_Event_devicePixelRatio; + this[ 'height' ] = e.height / X_Dom_Event_devicePixelRatio; } else { this[ 'pointerType' ] = e.pointerType; this[ 'pressure' ] = e.pressure; @@ -197,7 +213,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; }; @@ -205,11 +221,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; @@ -264,9 +281,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; @@ -309,6 +328,7 @@ if( !X_UA[ 'IE' ] || 9 <= X_UA[ 'IE' ] ){ if( type = X_Event_toPointer[ originalType ] ){ this[ 'type' ] = type; + this[ 'pointerType' ] = 'mouse'; this[ 'clientX' ] = e.clientX; this[ 'clientY' ] = e.clientY; //this[ 'screenX' ] = e.screenX; @@ -439,7 +459,7 @@ if( !navigator.pointerEnabled ){ 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 フラグを更新し続ける