Ewl » Canonical The canonical version of EWL Read More
Clone URL:  
Pushed to 3 repositories · View In Graph Contained in tip and canonical

Added disableTrimming parameter to TextControlSetup.

Changeset 6db69c8e83bc

Parent 5a2f67bd4aa7

by Profile picture of William GrossWilliam Gross

Changes to 6 files · Browse files at 6db69c8e83bc Showing diff from parent 5a2f67bd4aa7 Diff from another changeset...

 
31
32
33
 
34
35
36
 
72
73
74
 
75
76
77
 
102
103
104
 
105
106
107
 
31
32
33
34
35
36
37
 
73
74
75
76
77
78
79
 
104
105
106
107
108
109
110
@@ -31,6 +31,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   null, @@ -72,6 +73,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   autoCompleteResource, @@ -102,6 +104,7 @@
  true,   classes,   false, + false,   "",   "",   null,
 
31
32
33
 
34
35
36
 
75
76
77
 
78
79
80
 
106
107
108
 
109
110
111
 
31
32
33
34
35
36
37
 
76
77
78
79
80
81
82
 
108
109
110
111
112
113
114
@@ -31,6 +31,7 @@
  null,   false,   classes, + false,   true,   placeholder,   autoFillTokens, @@ -75,6 +76,7 @@
  null,   false,   classes, + false,   true,   placeholder,   autoFillTokens, @@ -106,6 +108,7 @@
  null,   true,   classes, + false,   true,   "",   "",
 
31
32
33
 
34
35
36
 
72
73
74
 
75
76
77
 
102
103
104
 
105
106
107
 
31
32
33
34
35
36
37
 
73
74
75
76
77
78
79
 
104
105
106
107
108
109
110
@@ -31,6 +31,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   null, @@ -72,6 +73,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   autoCompleteResource, @@ -102,6 +104,7 @@
  true,   classes,   false, + false,   "",   "",   null,
 
26
27
28
29
30
31
32
33
34
35
 
36
37
38
 
26
27
28
 
 
 
 
 
 
 
29
30
31
32
@@ -26,13 +26,7 @@
  allowEmpty,   null,   maxLength, - ( postBackValue, validator ) => { - var errorHandler = new ValidationErrorHandler( "text" ); - var validatedValue = maxLength.HasValue - ? validator.GetString( errorHandler, postBackValue, allowEmpty, maxLength.Value ) - : validator.GetString( errorHandler, postBackValue, allowEmpty ); - return errorHandler.LastResult != ErrorCondition.NoError ? null : validatedValue; - }, + ( postBackValue, validator ) => postBackValue,   validationMethod );   }   }
 
49
50
51
 
52
53
54
 
61
62
63
64
65
 
 
66
67
68
 
70
71
72
 
73
74
75
 
91
92
93
 
94
95
96
 
104
105
106
107
108
109
110
 
 
 
 
111
112
113
114
115
116
 
117
118
119
 
146
147
148
 
149
150
151
 
184
185
186
 
187
188
189
 
203
204
205
206
207
208
 
 
 
209
210
211
 
221
222
223
224
 
225
226
227
 
315
316
317
318
 
319
320
321
 
341
342
343
344
345
346
347
 
 
 
 
 
 
348
349
350
 
49
50
51
52
53
54
55
 
62
63
64
 
 
65
66
67
68
69
 
71
72
73
74
75
76
77
 
93
94
95
96
97
98
99
 
107
108
109
 
 
 
 
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
150
151
152
153
154
155
156
 
189
190
191
192
193
194
195
 
209
210
211
 
 
 
212
213
214
215
216
217
 
227
228
229
 
230
231
232
233
 
321
322
323
 
324
325
326
327
 
347
348
349
 
 
 
 
350
351
352
353
354
355
356
357
358
@@ -49,6 +49,7 @@
  /// <param name="displaySetup"></param>   /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param>   /// <param name="classes">The classes on the control.</param> + /// <param name="disableTrimming">Pass true to disable white-space trimming.</param>   /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param>   /// <param name="autoFillTokens">A list of auto-fill detail tokens (see   /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill @@ -61,8 +62,8 @@
  /// <param name="validationPredicate"></param>   /// <param name="validationErrorNotifier"></param>   public static TextControlSetup Create( - DisplaySetup displaySetup = null, int numberOfRows = 1, ElementClassSet classes = null, string placeholder = "", string autoFillTokens = "", - bool? checksSpellingAndGrammar = null, FormAction action = null, FormAction valueChangedAction = null, + DisplaySetup displaySetup = null, int numberOfRows = 1, ElementClassSet classes = null, bool disableTrimming = false, string placeholder = "", + string autoFillTokens = "", bool? checksSpellingAndGrammar = null, FormAction action = null, FormAction valueChangedAction = null,   PageModificationValue<string> pageModificationValue = null, Func<bool, bool> validationPredicate = null, Action validationErrorNotifier = null ) {   return new TextControlSetup(   displaySetup, @@ -70,6 +71,7 @@
  numberOfRows,   false,   classes, + disableTrimming,   false,   placeholder,   autoFillTokens, @@ -91,6 +93,7 @@
  /// <param name="displaySetup"></param>   /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param>   /// <param name="classes">The classes on the control.</param> + /// <param name="disableTrimming">Pass true to disable white-space trimming.</param>   /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param>   /// <param name="autoFillTokens">A list of auto-fill detail tokens (see   /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill @@ -104,16 +107,17 @@
  /// <param name="validationPredicate"></param>   /// <param name="validationErrorNotifier"></param>   public static TextControlSetup CreateAutoComplete( - ResourceInfo autoCompleteResource, DisplaySetup displaySetup = null, int numberOfRows = 1, ElementClassSet classes = null, string placeholder = "", - string autoFillTokens = "", bool? checksSpellingAndGrammar = null, FormAction action = null, bool triggersActionWhenItemSelected = false, - FormAction valueChangedAction = null, PageModificationValue<string> pageModificationValue = null, Func<bool, bool> validationPredicate = null, - Action validationErrorNotifier = null ) { + ResourceInfo autoCompleteResource, DisplaySetup displaySetup = null, int numberOfRows = 1, ElementClassSet classes = null, bool disableTrimming = false, + string placeholder = "", string autoFillTokens = "", bool? checksSpellingAndGrammar = null, FormAction action = null, + bool triggersActionWhenItemSelected = false, FormAction valueChangedAction = null, PageModificationValue<string> pageModificationValue = null, + Func<bool, bool> validationPredicate = null, Action validationErrorNotifier = null ) {   return new TextControlSetup(   displaySetup,   numberOfRows == 1 ? "text" : "",   numberOfRows,   false,   classes, + disableTrimming,   false,   placeholder,   autoFillTokens, @@ -146,6 +150,7 @@
  true,   classes,   false, + false,   "",   "",   null, @@ -184,6 +189,7 @@
  null,   false,   classes, + true,   false,   placeholder,   autoFillTokens, @@ -203,9 +209,9 @@
  LabelerAndComponentAndValidationGetter;     internal TextControlSetup( - DisplaySetup displaySetup, string inputElementType, int? numberOfRows, bool isReadOnly, ElementClassSet classes, bool requiresNumericValue, - string placeholder, string autoFillTokens, ResourceInfo autoCompleteResource, bool? checksSpellingAndGrammar, FormAction action, - bool? triggersActionWhenItemSelected, FormAction valueChangedAction, PageModificationValue<string> pageModificationValue, + DisplaySetup displaySetup, string inputElementType, int? numberOfRows, bool isReadOnly, ElementClassSet classes, bool disableTrimming, + bool requiresNumericValue, string placeholder, string autoFillTokens, ResourceInfo autoCompleteResource, bool? checksSpellingAndGrammar, + FormAction action, bool? triggersActionWhenItemSelected, FormAction valueChangedAction, PageModificationValue<string> pageModificationValue,   PageModificationValue<long?> numericPageModificationValue, Func<bool, bool> validationPredicate, Action validationErrorNotifier ) {   var labeler = new FormControlLabeler();   action = action ?? FormState.Current.DefaultAction; @@ -221,7 +227,7 @@
  maxLength.HasValue && rawValue.Length > maxLength.Value ? PostBackValueValidationResult<string>.CreateInvalid() :   PostBackValueValidationResult<string>.CreateValid( rawValue ) );   - formValue.AddPageModificationValue( pageModificationValue, v => v ); + formValue.AddPageModificationValue( pageModificationValue, v => disableTrimming ? v : v.Trim() );   if( numericPageModificationValue != null )   formValue.AddPageModificationValue(   numericPageModificationValue, @@ -315,7 +321,7 @@
  context.Id,   "setTimeout( function() { " + valueChangedAction.GetJsStatements() + " }, 0 );" )   : "", - pageModificationValue.GetJsModificationStatements( "$( this ).val()" ) + pageModificationValue.GetJsModificationStatements( "$( this ).val()" + ( disableTrimming ? "" : ".trim()" ) )   .ConcatenateWithSpace(   numericPageModificationValue?.GetJsModificationStatements( "Number( {0} )".FormatWith( "$( this ).val()" ) ) ?? "" )   .Surround( "$( '#{0}' ).change( function() {{ ".FormatWith( context.Id ), " } );" ), @@ -341,10 +347,12 @@
  return;     string validatedValue; - if( inputElementType != "password" ) - validatedValue = internalValidationMethod( postBackValue.Value, validator ); - else if( postBackValue.Value.Any() || allowEmpty ) - validatedValue = postBackValue.Value; + if( inputElementType != "password" ? postBackValue.Value.Trim().Any() : postBackValue.Value.Any() ) + validatedValue = internalValidationMethod( + disableTrimming ? postBackValue.Value : postBackValue.Value.Trim(), + validator ); + else if( allowEmpty ) + validatedValue = "";   else {   validatedValue = null;   validator.NoteErrorAndAddMessage( "Please enter a value." );
 
31
32
33
 
34
35
36
 
72
73
74
 
75
76
77
 
102
103
104
 
105
106
107
 
31
32
33
34
35
36
37
 
73
74
75
76
77
78
79
 
104
105
106
107
108
109
110
@@ -31,6 +31,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   null, @@ -72,6 +73,7 @@
  false,   classes,   false, + false,   placeholder,   autoFillTokens,   autoCompleteResource, @@ -102,6 +104,7 @@
  true,   classes,   false, + false,   "",   "",   null,