OSDN Git Service

version 0.5.24, fixed target element capcher of PonitingDeviceEventTree.
authoritozyun <itozyun@gmail.com>
Sun, 25 Nov 2012 03:35:11 +0000 (12:35 +0900)
committeritozyun <itozyun@gmail.com>
Sun, 25 Nov 2012 03:35:11 +0000 (12:35 +0900)
0.5.x/javascripts/peta.apps.js
0.5.x/javascripts/system.js

index 86b4f89..b132e1d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR peta.apps.js
- *   version 0.5.23
+ *   version 0.5.24
  *   
  * author:
  *   itozyun
@@ -3542,11 +3542,11 @@ var Editor = gOS.registerApplication( function(){
                this.flipH    = data.width  < 0 ? -1 : 1;
                this.rPicture = data.resource_picture;
                this.artistID = this.rPicture.artist_id || this.rPicture.artist.id || -1;
-               this.reversibleImage = null;
        };
        ImageElementClass.prototype = Util.extend(
                new AbstractPanelElement( PANEL_ELEMENT_TYPE_IMAGE ),
                {
+                       reversibleImage : null,
                        init : function(){
                                this._updateResourcePicture( this.rPicture );
                                this.resize( this.data.x, this.data.y, Math.abs( this.data.width ), Math.abs( this.data.height ) );
@@ -3814,9 +3814,9 @@ var Editor = gOS.registerApplication( function(){
 
                        },
                        close: function(){
-                               var _comicElm;
-                               while( _comicElm = PANEL_ELEMENT_ARRAY.shift() ){
-                                       _comicElm.destroy();
+                               var panelElm;
+                               while( panelElm = PANEL_ELEMENT_ARRAY.shift() ){
+                                       panelElm.destroy();
                                };
                        },
                        remove: function( _panelElement ){
index bd202d2..b822f41 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR system.js
- *   version 0.5.23
+ *   version 0.5.24
  *
  * gadgetOS
  *   author:
@@ -1282,33 +1282,47 @@ var PointingDeviceEventTree = ( function(){
                        type = e.type,
                        list = hoverList,
                        i    = 0,
-                       hit, parent;
-               ++c;
+                       ret, systemOnly = false, addClass, removeClass,
+                       parent;
                if( data && data.dispatchEvent( e, type, true ) === true ) return false;
-               //if( p = targetNodeData ) while( p = p.parentData ) delete p.hitChild;
-
-               currentRootData !== null && currentRootData._eventRellay( x, y, e, type );
                
-               if( c > 20 ) c = 0;
+               targetNodeData = currentRootData;
+               currentRootData._capcher( x, y );
+               targetNodeData.apiuser.updateCoursor( targetNodeData._cursor );
+               data = targetNodeData;
+               while( data ){
+                       ret = data.dispatchEvent( e, type, true, systemOnly );
+                       if( ret === true || ret === false ) break; // systemOnly = true;
+                       data = data.parentData;
+               };
                
+               addClass    = Util.addClass;
+               removeClass = Util.removeClass;
                for( ; i < list.length; ){
                        parent = data = list[ i ];
                        while( parent.parentData && parent === parent.parentData.hitChild ){
                                parent = parent.parentData;
                        };
                        if( parent !== currentRootData ){
-                       //if( data.parentData && data.parentData.hitChild !== data ){
-                               data.hover === true && Util.removeClass( data.elm, data.hoverClass );
+                               data.hover === true && removeClass( data.elm, data.hoverClass );
                                delete data.isHover;
                                data.events && data.events.mouseout && data.fire( e, 'mouseout', false );
                                delete data.hitSelf;
                                list.splice( i, 1 );
-                       } else {
-                               ++i;
+                               continue;
+                       };
+                       if( data.hover === true && data.isHover === false ){
+                               addClass( data.elm, data.hoverClass );
+                               data.isHover = true;
+                       };
+                       if( data.hitSelf === false ){
+                               data.events && data.events.mouseover && data.fire( e, 'mouseover', true );
+                               data.hitSelf = true;
                        };
+                       ++i;
                };
                return false;
-       };
+       };      
        
        var NodeClass = function( apiuser, rootData, /*parentLayer,*/ parentData, rangeOrElm, through, clip, hover, cursor, scroll, dragdrop ){
                ( new NodePrivateData() ).init( apiuser, rootData, /*parentLayer,*/ parentData, this, rangeOrElm, through, clip, hover, cursor, scroll, dragdrop );
@@ -1689,7 +1703,6 @@ var PointingDeviceEventTree = ( function(){
                        list = this.events[ eventType ];
                        if( !list ){
                                list = this.events[ eventType ] = [];
-                               // node[ eventType ] = this._eventRellay;
                        } else {
                                for( i = list.length; i; ){
                                        if( list[ --i ].match( eventType, handler ) === true ){
@@ -1738,52 +1751,30 @@ var PointingDeviceEventTree = ( function(){
                                };
                        };
                },
-               _eventRellay : function( x, y, e, eventType ){
-                       if( this._disabled === true ) return false; 
-                       var nodes, child, _x, _y, //  = this.hitChild,
-                               hit, i;                 
-                       x -= this.x;
-                       y -= this.y;
-                       /**
-                       if( c > 20 || eventType !== 'mousemove' ){
-                               var depth = 0, p = this;
-                               while( p = p.parentData ){ ++depth; };
-                               console.log( '-'.repeat( depth ) + this.nodeIndex() + '\t\t' + eventType + '\tx:' + x + '\ty:' + y + '\tcX:' + e.clientX + '\tcY:' + e.clientY + ' nodes:' + this.numNode() + ' N.x:' + this.x + ' N.y:' + this.y + ' N.w' + this.w + ' N.h' + this.h + ' N.l' + this.l + ' N.t' + this.t + ' N.r' + this.r + ' N.b' + this.b );
-                       }; */
-                       
-                       delete this.hitChild;
-                       
-                       if( nodes = this.childData ){
-                               _x = x - this._scrollX;
-                               _y = y - this._scrollY;
+               _capcher : function( x, y ){
+                       var t = this, nodes, child, _x, _y, hit, i;
+                       if( t._disabled === true ) return false;
+                       delete t.hitChild;
+                       x -= t.x;
+                       y -= t.y;
+                       if( nodes = t.childData ){
+                               _x = x - t._scrollX;
+                               _y = y - t._scrollY;
                                for( i = nodes.length; i; ){
                                        child = nodes[ --i ];
-                                       if( child._disabled === false && child._hitRect( _x, _y ) === true && child._eventRellay( _x, _y, e, eventType ) === true ){
-                                               this.hitChild = child;
+                                       if( child._disabled === false && child.l <= _x && _x < child.r && child.t <= _y && _y < child.b && child._capcher( _x, _y ) === true ){
+                                               t.hitChild = child;
                                                break;
                                        };
                                };
-                       };              
-
-                       if( this.through === true ) return !!this.hitChild;
-                       
-                       hit = this._hitNode( x, y );
+                       };
+                       if( t.through === true ) return !!t.hitChild;
+                       hit = 0 <= x && x < t.w && 0 <= y && y < t.h;
                        if( hit === true ){
-                               if( this.hitChild === null ){
-                                       this.apiuser.updateCoursor( this._cursor );
-                                       targetNodeData = this;
-                               };
-                               if( this.hover === true && this.isHover === false ){
-                                       Util.addClass( this.elm, this.hoverClass );
-                                       this.isHover = true;
-                               };
-                               this.hitSelf === false && hoverList.push( this ) && this.events && this.events.mouseover && this.fire( e, 'mouseover', true );
+                               t.hitSelf === false && hoverList.push( t );
+                               if( t.hitChild === null ) targetNodeData = t;
                        };
-                       this.hitSelf = hit || !!this.hitChild;
-                       
-                       if( this.hitSelf === false ) return false;
-                       if( !this.events || !this.events[ eventType ] ) return true;
-                       return this.dispatchEvent( e, eventType, true );
+                       return hit || !!t.hitChild;
                },
                fire : function( e, eventType, hit ){
                        var list = this.events[ eventType ],
@@ -1793,36 +1784,20 @@ var PointingDeviceEventTree = ( function(){
                        // console.log( eventType + ' x:' + x + ' y:' + y );
                },
                dispatchEvent : function( e, eventType, hit ){
-                       var ret, list, i, p;
-                       if( !this.events || !( list = this.events[ eventType ] ) ) return hit;
+                       var ret, list, i, p, child;
+                       if( !this.events || !( list = this.events[ eventType ] ) ) return;
                        
+                       child = !!this.hitChild;
                        e = NodePrivateData.createEvent( e, eventType, this, hit );
                        for( i = list.length; i; ){
-                               if( list[ --i ].fire( e ) === true ) ret = true;
-                       };
-                       if( this.hitChild ) return true;
-                       // target
-                       if( ret === true ){
-                               forceNodeData  = this;
-                               // targetNodeData = this;
-                               this.apiuser.updateCoursor( this._cursor );
-                               return true;
-                       };
-                       if( hit === true ){
-                               forceNodeData  = null;
-                               // targetNodeData = this;
-                               this.apiuser.updateCoursor( this._cursor );
-                               return true;
+                               ret = list[ --i ].fire( e );
+                               if( ret === true && child === false ){
+                                       forceNodeData = this;
+                                       return true;
+                               };
+                               if( ret === false ) return false;
                        };
                        forceNodeData  = null;
-                       targetNodeData = null;
-                       return false;
-               },
-               _hitRect : function( x, y ){
-                       return this.l <= x && x < this.r && this.t <= y && y < this.b;
-               },
-               _hitNode : function( x, y ){
-                       return ( 0 <= x && x < this.w && 0 <= y && y < this.h ) || ( this === currentRootData );
                },
                onScrollReady : function( e ){
                        ScrollBarManager.show( this );
@@ -1843,7 +1818,9 @@ var PointingDeviceEventTree = ( function(){
                        ScrollBarManager.hide( this );
                },
                scrollTo : function( x, y ){
-       
+                       this._scrollX = x;
+                       this._scrollY = y;
+                       ScrollBarManager.update( this );
                },
                scrollX : function( v ){
                        if( Type.isFinite( v ) === true ){
@@ -2006,7 +1983,7 @@ var PointingDeviceEventTree = ( function(){
                                        data.elmScroller.style.top = y + 'px';
                                };
                                if( data.scrollingY === data._scrollY ){
-                                       smoothList.splice( i, 1 );
+                                       list.splice( i, 1 );
                                } else {
                                        ++i;
                                };