File tree Expand file tree Collapse file tree 3 files changed +31
-23
lines changed Expand file tree Collapse file tree 3 files changed +31
-23
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,20 @@ var Base = function () {
88Base . prototype = {
99 asyncSupport : true , // Deprecated
1010
11- _pipeAccordingToValidationResult : function ( ) {
12- var pipe = ( ) => {
13- var r = $ . Deferred ( ) ;
14- if ( true !== this . validationResult )
15- r . reject ( ) ;
16- return r . resolve ( ) . promise ( ) ;
17- } ;
18- return [ pipe , pipe ] ;
11+ _pipeAccordingToValidationResult : function ( deferred ) {
12+ return $ . Deferred ( ( newDefer ) => {
13+ const handle = ( ) => {
14+ var r = true === this . validationResult ?
15+ $ . Deferred ( ) . resolve ( ) :
16+ $ . Deferred ( ) . reject ( ) ;
17+ r . promise ( )
18+ . progress ( newDefer . notify )
19+ . done ( newDefer . resolve )
20+ . fail ( newDefer . reject )
21+ }
22+ deferred . done ( handle )
23+ deferred . fail ( handle )
24+ } )
1925 } ,
2026
2127 actualizeOptions : function ( ) {
Original file line number Diff line number Diff line change @@ -62,12 +62,13 @@ Field.prototype = {
6262 // Field Validate event. `this.value` could be altered for custom needs
6363 this . _trigger ( 'validate' ) ;
6464
65- return this . whenValid ( { force, value : this . value , _refreshed : true } )
66- . always ( ( ) => { this . _reflowUI ( ) ; } )
67- . done ( ( ) => { this . _trigger ( 'success' ) ; } )
68- . fail ( ( ) => { this . _trigger ( 'error' ) ; } )
69- . always ( ( ) => { this . _trigger ( 'validated' ) ; } )
70- . pipe ( ...this . _pipeAccordingToValidationResult ( ) ) ;
65+ return this . _pipeAccordingToValidationResult (
66+ this . whenValid ( { force, value : this . value , _refreshed : true } )
67+ . always ( ( ) => { this . _reflowUI ( ) ; } )
68+ . done ( ( ) => { this . _trigger ( 'success' ) ; } )
69+ . fail ( ( ) => { this . _trigger ( 'error' ) ; } )
70+ . always ( ( ) => { this . _trigger ( 'validated' ) ; } )
71+ ) ;
7172 } ,
7273
7374 hasConstraints : function ( ) {
Original file line number Diff line number Diff line change @@ -103,15 +103,16 @@ Form.prototype = {
103103 return $ . map ( this . fields , field => field . whenValidate ( { force, group} ) ) ;
104104 } ) ;
105105
106- return Utils . all ( promises )
107- . done ( ( ) => { this . _trigger ( 'success' ) ; } )
108- . fail ( ( ) => {
109- this . validationResult = false ;
110- this . focus ( ) ;
111- this . _trigger ( 'error' ) ;
112- } )
113- . always ( ( ) => { this . _trigger ( 'validated' ) ; } )
114- . pipe ( ...this . _pipeAccordingToValidationResult ( ) ) ;
106+ return this . _pipeAccordingToValidationResult (
107+ Utils . all ( promises )
108+ . done ( ( ) => { this . _trigger ( 'success' ) ; } )
109+ . fail ( ( ) => {
110+ this . validationResult = false ;
111+ this . focus ( ) ;
112+ this . _trigger ( 'error' ) ;
113+ } )
114+ . always ( ( ) => { this . _trigger ( 'validated' ) ; } )
115+ ) ;
115116 } ,
116117
117118 // Iterate over refreshed fields, and stop on first failure.
You can’t perform that action at this time.
0 commit comments