OSDN Git Service

Version 0.6.111, rename files.
[pettanr/clientJs.git] / 0.6.x / js / 02_dom / 03_XDomEvent.js
index 540ed81..3b1c59e 100644 (file)
@@ -23,13 +23,25 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                var originalType = e.type,\r
                        type, pointerType,\r
                        touches, events,\r
-                       altKey, ctrlKey, metaKey, shiftKey, target, related,\r
+                       altKey, ctrlKey, metaKey, shiftKey, target, related, force,\r
                        elm, i, n, time, touch, ev;\r
                \r
                //this._event        = e;\r
                this.type          = type = X_Event_RenameTo[ originalType ] || originalType;\r
                \r
-               console.log( 'original : ' + originalType + ' > ' + type );\r
+               switch( type ){\r
+                       case 'message' :\r
+                               this.data   = e.data;\r
+                               this.origin = e.origin;\r
+                               this.source = e.source;\r
+                               break;\r
+                       case 'progress' :\r
+                               this.loaded = e.loaded;\r
+                               this.total  = e.total;\r
+                               break;\r
+               };\r
+               \r
+               //console.log( 'original : ' + originalType + ' > ' + type );\r
                // http://msdn.microsoft.com/ja-jp/library/ie/dn304886%28v=vs.85%29.aspx\r
                // ポインター イベントの更新\r
                if( e.pointerType ){\r
@@ -88,9 +100,11 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                } else\r
                if( pointerType = X_Event_toPointer[ originalType ] ){\r
                        // Touch or Mouse\r
+                       //console.log( originalType + ' => ' + pointerType );\r
                        \r
                        /* e.constructor === window.TouchEvent -> e.touches for iOS3.13 */\r
                        if( touches = e.changedTouches ){\r
+                               //console.log( originalType + ' => ' + pointerType );\r
                                if( touches.length === 0 ){\r
                                        alert( 'e.changedTouches.length === 0' );\r
                                };\r
@@ -102,6 +116,7 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                                metaKey  = e.metaKey;\r
                                shiftKey = e.shiftKey;\r
                                time     = X_Timer_now();\r
+                               force    = originalType === 'touchend' || originalType === 'touchcancel' ? 0 : 0.5;\r
                                for( i = touches.length; i; ){\r
                                        touch   = touches[ --i ];\r
                                        target  = touch.target;\r
@@ -111,11 +126,11 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                                                pointerType   : 'touch',\r
                                                target        : X_Node_getXNode( target.nodeType === 3 ? target.parentNode : target ),// defeat Safari bug // xnodetouch.target,\r
                                                currentTarget : xnode,\r
-                                               relatedTarget : X_Node_getXNode( related.nodeType === 3 ? related.parentNode : related ), // xnode\r
+                                               relatedTarget : related && X_Node_getXNode( related.nodeType === 3 ? related.parentNode : related ), // xnode iOS3 には relatedTarget がない\r
                                                isPrimary     : true,\r
                                                hwTimestamp   : time,\r
                                                timestamp     : time,\r
-                                               buttons       : e.button,\r
+                                               button        : e.button,\r
                                                buttons       : e.buttons || e.button,\r
                                                altKey        : altKey,\r
                                                ctrlKey       : ctrlKey,\r
@@ -133,7 +148,7 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                                                radiusX       : touch.radiusX || 0,\r
                                                radiusY       : touch.radiusY || 0,\r
                                                rotationAngle : touch.rotationAngle || 0,\r
-                                               pressure      : touch.force || touch.webkitForce || ( isEnd ? 0 : 0.5 ),\r
+                                               pressure      : touch.force || touch.webkitForce || force,\r
                                                width         : touch.width || 0,\r
                                                height        : touch.height || 0\r
                                        };\r
@@ -254,6 +269,19 @@ if( !X_UA.IE || 9 <= X_UA.IE ){
                this.ctrlKey       = e.ctrlKey;\r
                this.shiftKey      = e.shiftKey;                \r
 \r
+               \r
+               switch( this.type ){\r
+                       case 'message' :\r
+                               this.data   = e.data;\r
+                               this.origin = e.origin;\r
+                               this.source = e.source;\r
+                               break;\r
+                       case 'progress' :\r
+                               this.loaded = e.loaded;\r
+                               this.total  = e.total;\r
+                               break;\r
+               };\r
+\r
                // http://www.programming-magic.com/20090127231544/\r
                switch( originalType ){\r
                        case 'click'    :\r
@@ -411,11 +439,11 @@ if( !navigator.pointerEnabled ){
        } else\r
        if( X_UA_HID.TOUCH ){\r
                // touch のみ(iOS でも脱獄したら?)、 touch と mouse(Android), mouse のみ\r
-               X_Event_Rename[ 'pointerdown'     ] = [ 'touchdown', 'mousedown' ];\r
-               X_Event_Rename[ 'pointerup'       ] = [ 'touchup',   'mouseup' ];\r
-               X_Event_Rename[ 'pointermove'     ] = [ 'touchmove', 'mousemove' ];\r
+               X_Event_Rename[ 'pointerdown'     ] = [ 'touchstart', 'mousedown' ];\r
+               X_Event_Rename[ 'pointerup'       ] = [ 'touchend',   'mouseup' ];\r
+               X_Event_Rename[ 'pointermove'     ] = [ 'touchmove',  'mousemove' ];\r
                X_Event_Rename[ 'pointercancel'   ] = 'touchcancel';\r
-               // X_Event_Rename[ 'click'           ] = [ 'touchdown', 'touchmove', 'touchup' ]; // ループになってしまう!直した!直ってない!\r
+               // X_Event_Rename[ 'click'           ] = [ 'touchstart', 'touchmove', 'touchend' ]; // ループになってしまう!直した!直ってない!\r
        } else {\r
                X_Event_Rename[ 'pointerdown'     ] = 'mousedown';\r
                X_Event_Rename[ 'pointerup'       ] = 'mouseup';\r