X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F20_ui%2F17_Text.js;h=40877beba8f9ae5c294ee5885fd7e318a1bb99c9;hb=HEAD;hp=ceb896c67158e46c3bc0e5688373ed17e8b5e048;hpb=83a329e3210a40f383282389a48a33ea34ccfa1f;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/20_ui/17_Text.js b/0.6.x/js/20_ui/17_Text.js index ceb896c..40877be 100644 --- a/0.6.x/js/20_ui/17_Text.js +++ b/0.6.x/js/20_ui/17_Text.js @@ -1,19 +1,58 @@ -X.UI._Text = X.UI._AbstractUINode.inherits( +var X_UI_Text_SUPPORT_ATTRS = { + content : [ '' , XUI_Dirty.CONTENT, XUI_Attr_USER.UINODE, XUI_Attr_Type.STRING ], + bgColor : [ NaN, XUI_Dirty.PAINT, XUI_Attr_USER.XNODE, XUI_Attr_Type.COLOR ] +}, + +X_UI_Text_usableAttrs = XUI_Attr_createAttrDef( XUI_AbstractUINode.prototype.usableAttrs, X_UI_Text_SUPPORT_ATTRS ); + +var XUI_Text = XUI_AbstractUINode.inherits( '_Text', - X_Class.PRIVATE_DATA, + X_Class.NONE, { - content : null, + content : '', + + usableAttrs : __textAttrs = X_UI_Text_usableAttrs, - Constructor : function( content ){ - if( !( this.User[ 'instanceOf' ]( X.UI.Text ) ) ){ + attrClass : XUI_Attr_preset( XUI_AbstractUINode.prototype.attrClass, X_UI_Text_usableAttrs ), + + Constructor : function( user, content ){ + if( !( user[ 'instanceOf' ]( X.UI.Text ) ) ){ alert( 'Text を継承したインスタンスだけが _Text のオーナーになれます' ); }; - this.xnode = X_Doc_create( 'div' ); + this.User = user; + this.xnode = X_Doc_create( 'div' ); - if( X_Type_isString( content ) && content ){ - this.content = content; + if( content != null ){ + this.content = '' + content; + }; + }, + + creationComplete : function(){ + if( X_Type_isString( this.content ) && this.content ){ this.xnode[ 'text' ]( this.content ); - this.dirty = X.UI.Dirty.CONTENT; + this.dirty = XUI_Dirty.CONTENT; + }; + + XUI_AbstractUINode.prototype.creationComplete.apply( this, arguments ); + }, + + setContent : function( v ){ + if( this.content !== v ){ + this.content = v; + this.xnode && this.xnode[ 'text' ]( v ); + this.rootData.reserveCalc(); + if( this.dirty < XUI_Dirty.CONTENT ) this.dirty = XUI_Dirty.CONTENT; + }; + return this; + }, + + setItemData : function( itemData ){ + if( this.itemData === itemData ) return; + + XUI_AbstractUINode.prototype.setItemData.apply( this, arguments ); + + if( X_Type_isObject( itemData = this.itemData ) && itemData[ this.dataFeild ] != null ){ + this.setContent( '' + itemData[ this.dataFeild ] ); }; } } @@ -21,20 +60,23 @@ X.UI._Text = X.UI._AbstractUINode.inherits( X.UI.Text = X.UI.AbstractUINode.inherits( 'Text', - X_Class.SUPER_ACCESS, - X.UI._Text, + X_Class.NONE, { - Constructor : function( opt_content, opt_cssObj ){ - X_Class_newPrivate( this, opt_content ); - X_Type_isObject( opt_cssObj = opt_cssObj || opt_content ) && this[ 'attr' ]( opt_cssObj ); + Constructor : function( opt_content, opt_attrObj ){ + X_Pair_create( this, XUI_Text( this, opt_content ) ); + + X_Type_isObject( opt_attrObj = opt_attrObj || opt_content ) && this[ 'attr' ]( opt_attrObj ); }, content : function( v ){ - var data = X_Class_getPrivate( this ); - if( data.content !== v ){ - data.xnode && data.xnode[ 'text' ]( v ); - data.rootData.reserveCalc(); - if( data.dirty < X.UI.Dirty.CONTENT ) data.dirty = X.UI.Dirty.CONTENT; + var data = X_Pair_get( this ), + content = data.content; + + if( v === undefined ){ + return content; }; + v += ''; + content !== v && data.setContent( v ); + return this; } } ); \ No newline at end of file