OSDN Git Service

Version 0.6.190, fix X.UI.ScrollBox & X.UI.Gesture.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 06_AbstractUINode.js
index 63bddf4..16f8234 100644 (file)
@@ -88,7 +88,7 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                        if( attr ){\r
                                for( k in usableAttrs ){\r
                                        def = usableAttrs[ k ];\r
-                                       if( def[ 2 ] === XUI_Attr_USER.XNODE && X_Object_inObject( def.No, attr ) && attr[ k ] !== def[ 0 ] ){\r
+                                       if( def[ 2 ] === XUI_Attr_USER.XNODE && X_Object_inObject( def.No, attr ) && attr[ def.No ] !== def[ 0 ] ){\r
                                                this.xnode[ 'css' ]( XUI_Attr_Rename[ k ] || k, XUI_AbstractUINode_createCssText( this, k ) );\r
                                        };\r
                                };\r
@@ -165,8 +165,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                if( v.indexOf( ' ' ) !== -1 ){\r
                                        v = v.split( ' ' );\r
                                } else\r
-                               if( color && X_Type_isNumber( _v = X_Node_CSS_objToIEFilterText( v ) ) ){\r
-                                       v = _v;\r
+                               if( color && X_Type_isNumber( _v = X_Node_CSS_parseColor( v ) ) ){\r
+                                       v = _v; \r
                                } else {\r
                                        // bad\r
                                        return;\r
@@ -185,7 +185,7 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                        ( minusPct  && -1 <= v && v < 0 ) ||\r
                                    ( numerical && 0 <= v ) ||\r
                                    ( auto      && v === XUI_Attr_AUTO ) ||\r
-                                   ( color     && 0 <= v && v <= 0xFFFFFF ) ||\r
+                                   ( color     && ( 0 <= v && v <= 0xFFFFFF ) || ( v !== v ) ) || // isNaN\r
                                    ( list      && list[ v ] )\r
                                ){\r
                                        // good\r
@@ -705,12 +705,13 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                        if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){\r
                                !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this );\r
                                this.rootData.targetNodeData = this;\r
+                               //console.log( 'hit ' + this.xnode.className() )\r
                                return true;\r
                        };\r
                },\r
                \r
                /*\r
-                * context を明示しない場合、User が context になる!\r
+                * TODO context を明示しない場合、User が context になる! の処理は User 側へ\r
                 */\r
                listen : function( type, arg1, arg2, arg3 ){\r
                        var root, events, counter, f;\r
@@ -721,6 +722,12 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                        events[ events.length ] = [ type, arg1, arg2, arg3 ];\r
                                        return this;\r
                                };\r
+                               \r
+                               if( this[ 'listening' ]( type, arg1, arg2, arg3 ) ){\r
+                                       console.log( '. listening' )\r
+                                       return this;\r
+                               };\r
+                               \r
                                if( XUI_Event._START_XUI_EVENT < type && type < XUI_Event._END_XUI_EVENT ){\r
                                        if( !this.gesture ){\r
                                                this.gesture = new Hammer( this.rootData, this, type );\r
@@ -735,28 +742,23 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                                ++counter[ type ];\r
                                        } else {\r
                                                counter[ type ] = 1;                            \r
-                                               root.xnodeInteractiveLayer[ 'listen' ]( XUI_Event.IdToName[ type ], X_UI_eventRellay );\r
+                                               XUI_xnodeIneraction[ 'listen' ]( XUI_Event.IdToName[ type ], X_UI_eventRellay );\r
                                        };\r
+                                       if( type === XUI_Event._POINTER_UP ) console.log( '...    addEvent ' + counter[ type ] );\r
                                };\r
                        };\r
                        \r
-                       arg1 && arg1.cbKind ? ( f = arg1 ) : ( f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 ) );\r
-                       if( !f.cbKind ){\r
-                               return X_EventDispatcher_listen.call( this, type, this.User, f );\r
-                       } else\r
-                       if( f.cbKind === X_CLOSURE_FUNC_ONLY ){\r
-                               return X_EventDispatcher_listen.call( this, type, this.User, f.func, f.supplement );\r
-                       };\r
                        return X_EventDispatcher_listen.apply( this, arguments );\r
                },\r
                unlisten : function( type, arg1, arg2, arg3 ){\r
-                       var root, events, i, ev, counter, f;\r
+                       var root, events, i, ev, counter;\r
+                       \r
                        if( XUI_Event._START_POINTER <= type && type <= XUI_Event._END_POINTER ){\r
                                if( this.phase < 3 ){\r
                                        if( !( events = this.reserveEvents ) ) return this;\r
                                        for( i = events.length; i; ){\r
                                                ev = events[ --i ];\r
-                                               if( ev[ 0 ] === type && ev[ 1 ] === arg1 && ev[ 2 ] === arg2 ){\r
+                                               if( ev[ 0 ] === type && ev[ 1 ] === arg1 && ev[ 2 ] === arg2 && ev[ 3 ] === arg3 ){\r
                                                        events.split( i, 1 );\r
                                                        return this;\r
                                                };\r
@@ -764,44 +766,52 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                        return this;\r
                                };\r
 \r
+                               if( !this[ 'listening' ]( type, arg1, arg2, arg3 ) ){\r
+                                       return this;\r
+                               };\r
+                               \r
                                if( XUI_Event._START_XUI_EVENT < type && type < XUI_Event._END_XUI_EVENT ){\r
                                        this.gesture && this.gesture[ 'unlisten' ]( type );\r
                                } else {\r
                                        root    = this.rootData;\r
                                        counter = root.eventCounter;\r
-                                       if( !counter[ type ] ) return this;\r
-                                       --counter[ type ];\r
-                                       if( counter[ type ] === 0 ){\r
-                                               root.xnodeInteractiveLayer[ 'unlisten' ]( XUI_Event.IdToName[ type ], X_UI_eventRellay );\r
-                                               delete counter[ type ];\r
+                                       \r
+                                       if( !counter[ type ] ){\r
+                                               console.log( '... no event ... ' + counter[ type ] );\r
+                                       };\r
+                                       \r
+                                       if( type === XUI_Event._POINTER_UP ) console.log( '... removeEvent ' + counter[ type ] );\r
+                                       \r
+                                       if( counter[ type ] === 1 ){\r
+                                               XUI_xnodeIneraction[ 'unlisten' ]( XUI_Event.IdToName[ type ], X_UI_eventRellay );\r
+                                               counter[ type ] = 0;\r
+                                       } else\r
+                                       if( counter[ type ] ){\r
+                                               --counter[ type ];\r
                                        };\r
                                };\r
                        };\r
-                       arg1 && arg1.cbKind ? ( f = arg1 ) : ( f = X_Closure_classifyCallbackArgs( arg1, arg2, arg3 ) );\r
-                       if( !f.cbKind ){\r
-                               return X_EventDispatcher_unlisten.apply( this, [ type, this.User, f ] );\r
-                       } else\r
-                       if( f.cbKind === X_CLOSURE_FUNC_ONLY ){\r
-                               return X_EventDispatcher_unlisten.apply( this, [ type, this.User, f.func, f.supplement ] );\r
-                       };\r
+\r
                        return X_EventDispatcher_unlisten.apply( this, arguments );\r
                },\r
                \r
+               /*\r
                dispatch : function( e ){\r
                        //console.log( e.type + ' ' + ( this[ '_listeners' ] && this[ '_listeners' ][ e.type ] ) );\r
-                       var xve  = XUI_Event,\r
-                               ret  = X_EventDispatcher_dispatch.call( this, e ),\r
+                       var ret  = X_EventDispatcher_dispatch.call( this, e ),\r
                                type = e.type || e;\r
                        \r
                        // TODO captureEvent PointerEvent\r
-                       if( ret & X_CALLBACK_CAPTURE_POINTER && !this.hitChildData && XUI_Event._POINTER_MOVE === type ){\r
+                       if( ret & X_CALLBACK_CAPTURE_POINTER ){\r
                                this.rootData.monopolyNodeData = this;\r
                                return ret;\r
                        };\r
-                       this.rootData.monopolyNodeData = null;\r
-                       if( xve._START_BUBLEUP < type && this.parentData && !( ret & X_CALLBACK_STOP_PROPAGATION ) && !( ret & X_CALLBACK_STOP_NOW ) ) return this.parentData[ 'dispatch' ]( e );\r
+                       if( this.rootData.monopolyNodeData === this ) this.rootData.monopolyNodeData = null;\r
+                       if( XUI_Event._START_BUBLEUP < type && this.parentData && !( ret & X_CALLBACK_STOP_PROPAGATION ) ){\r
+                               return this.parentData[ 'dispatch' ]( e );\r
+                       };\r
                        return ret;\r
-               },\r
+               }, */\r
                \r
                setItemData : function( itemData ){\r
                        if( this.itemData === itemData ) return;\r
@@ -878,13 +888,16 @@ function XUI_AbstractUINode_createCssValue( v, type, list ){
        \r
        if( X_Type_isNumber( v ) ){\r
                if( auto && v === XUI_Attr_AUTO ) return 'auto';\r
-               if( length || minusLen ) return v + 'em';\r
+               if( length || minusLen ) return v ? v + 'em' : 0;\r
                if( numerical ) return v;\r
                if( list && list[ v ] ) return list[ v ];\r
                if( color ){\r
                        if( v < 0x100000 ){\r
                                v = '00000' + v.toString( 16 );\r
                                return '#' + v.substr( v.length - 6 );\r
+                       } else\r
+                       if( v !== v ){ // iSNaN\r
+                               return 'none';\r
                        };\r
                        return '#' + v.toString( 16 );\r
                };\r
@@ -971,7 +984,15 @@ X.UI.AbstractUINode = X_Class_create(
                },\r
                \r
                listen : function( type, arg1, arg2, arg3 ){\r
-                       X_Pair_get( this )[ 'listen' ]( type, arg1, arg2, arg3 );\r
+                       var pair = X_Pair_get( this );\r
+                       \r
+                       ( !arg1 || !arg1.cbKind ) && ( arg1 = X_Closure_classifyCallbackArgs( arg1, arg2, arg3, this ) );\r
+                       \r
+                       if( arg1.cbKind === X_CLOSURE_FUNC_ONLY ){\r
+                               pair[ 'listen' ].apply( pair, [ type, this, arg1.func, arg1.supplement ] );\r
+                       } else {\r
+                               pair[ 'listen' ]( type, arg1.context, arg1.func, arg1.supplement );\r
+                       };\r
                        return this;\r
                },\r
                listenOnce : function( type, arg1, arg2, arg3 ){\r
@@ -982,7 +1003,15 @@ X.UI.AbstractUINode = X_Class_create(
                        return X_Pair_get( this )[ 'listening' ]( type, arg1, arg2, arg3 );\r
                },\r
                unlisten : function( type, arg1, arg2, arg3 ){\r
-                       X_Pair_get( this )[ 'unlisten' ]( type, arg1, arg2, arg3 );\r
+                       var pair = X_Pair_get( this );\r
+                       \r
+                       ( !arg1 || !arg1.cbKind ) && ( arg1 = X_Closure_classifyCallbackArgs( arg1, arg2, arg3, this ) );\r
+                       \r
+                       if( arg1.cbKind === X_CLOSURE_FUNC_ONLY ){\r
+                               pair[ 'unlisten' ].apply( pair, [ type, this, arg1.func, arg1.supplement ] );\r
+                       } else {\r
+                               pair[ 'unlisten' ]( type, arg1.context, arg1.func, arg1.supplement );\r
+                       };\r
                        return this;\r
                },\r
                dispatch : function( e ){\r