@ -8,7 +8,11 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
_defaultConfig : function ( ) {
return BI . extend ( BI . TextAreaEditor . superclass . _defaultConfig . apply ( ) , {
baseCls : "bi-textarea-editor" ,
value : ""
value : "" ,
errorText : "" ,
validationChecker : function ( ) {
return true ;
} ,
} ) ;
} ,
@ -38,15 +42,15 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
} ) ;
this . content . element . on ( "input propertychange" , function ( e ) {
self . _checkError ( ) ;
self . _checkWaterMark ( ) ;
self . fireEvent ( BI . TextAreaEditor . EVENT _CHANGE ) ;
} ) ;
this . content . element . focus ( function ( ) {
if ( self . isValid ( ) ) {
self . _checkError ( ) ;
self . _focus ( ) ;
self . fireEvent ( BI . TextAreaEditor . EVENT _FOCUS ) ;
}
BI . Widget . _renderEngine . createElement ( document ) . bind ( "mousedown." + self . getName ( ) , function ( e ) {
if ( BI . DOM . isExist ( self ) && ! self . element . _ _isMouseInBounds _ _ ( e ) ) {
BI . Widget . _renderEngine . createElement ( document ) . unbind ( "mousedown." + self . getName ( ) ) ;
@ -55,10 +59,9 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
} ) ;
} ) ;
this . content . element . blur ( function ( ) {
if ( self . isValid ( ) ) {
self . _setErrorVisible ( false ) ;
self . _blur ( ) ;
self . fireEvent ( BI . TextAreaEditor . EVENT _BLUR ) ;
}
BI . Widget . _renderEngine . createElement ( document ) . unbind ( "mousedown." + self . getName ( ) ) ;
} ) ;
if ( BI . isKey ( o . value ) ) {
@ -112,6 +115,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
}
} ,
_checkError : function ( ) {
this . _setErrorVisible ( this . isEnabled ( ) && ! this . options . validationChecker ( this . getValue ( ) ) ) ;
} ,
_focus : function ( ) {
this . content . element . addClass ( "textarea-editor-focus" ) ;
this . _checkWaterMark ( ) ;
@ -122,6 +129,20 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
this . _checkWaterMark ( ) ;
} ,
_setErrorVisible : function ( b ) {
var o = this . options ;
var errorText = o . errorText ;
if ( BI . isFunction ( errorText ) ) {
errorText = errorText ( BI . trim ( this . getValue ( ) ) ) ;
}
if ( ! this . disabledError && BI . isKey ( errorText ) ) {
BI . Bubbles [ b ? "show" : "hide" ] ( this . getName ( ) , errorText , this , {
adjustYOffset : 2
} ) ;
return BI . Bubbles . get ( this . getName ( ) ) ;
}
} ,
focus : function ( ) {
this . _focus ( ) ;
this . content . element . focus ( ) ;
@ -138,6 +159,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
setValue : function ( value ) {
this . content . element . val ( value ) ;
this . _checkError ( ) ;
this . _checkWaterMark ( ) ;
} ,