@@ -31,12 +31,7 @@ function BugForm() {
31
31
// image should be valid by default because it's optional
32
32
'valid' : true ,
33
33
'helpText' : 'Image must be one of the following: jpg, png, gif, or bmp.' ,
34
- } ,
35
- 'img_too_big' : {
36
- 'el' : $ ( '#image' ) ,
37
- // image should be valid by default because it's optional
38
- 'valid' : true ,
39
- 'helpText' : 'Please choose a smaller image (< 4MB)'
34
+ 'altHelpText' : 'Please choose a smaller image (< 4MB)'
40
35
} ,
41
36
'browser' : {
42
37
'el' : $ ( '#browser' ) ,
@@ -118,7 +113,7 @@ function BugForm() {
118
113
// The limit is 4MB (which is crazy big!), so let the user know if their
119
114
// file is unreasonably large at this point (after 1 round of downsampling)
120
115
if ( this . screenshotData > this . UPLOAD_LIMIT ) {
121
- this . makeInvalid ( 'img_too_big' ) ;
116
+ this . makeInvalid ( 'image' , { altHelp : true } ) ;
122
117
return ;
123
118
}
124
119
@@ -220,15 +215,18 @@ function BugForm() {
220
215
}
221
216
} ;
222
217
223
- this . makeInvalid = function ( id ) {
218
+ /* makeInvalid can take an {altHelp: true} options argument to select
219
+ alternate helpText to display */
220
+ this . makeInvalid = function ( id , opts ) {
224
221
// Early return if inline help is already in place.
225
222
if ( this . inputs [ id ] . valid === false ) {
226
223
return ;
227
224
}
228
225
229
226
var inlineHelp = $ ( '<span></span>' , {
230
227
'class' : 'wc-Form-helpMessage' ,
231
- 'text' : this . inputs [ id ] . helpText
228
+ 'text' : opts && opts . altHelp ? this . inputs [ id ] . altHelpText :
229
+ this . inputs [ id ] . helpText
232
230
} ) ;
233
231
234
232
this . inputs [ id ] . valid = false ;
@@ -244,7 +242,7 @@ function BugForm() {
244
242
inlineHelp . appendTo ( '.wc-Form-information' ) ;
245
243
}
246
244
247
- if ( id === 'image' || id === 'img_too_big' ) {
245
+ if ( id === 'image' ) {
248
246
// hide the error in case we already saw one
249
247
$ ( '.wc-Form-helpMessage--imageUpload' ) . remove ( ) ;
250
248
@@ -274,8 +272,7 @@ function BugForm() {
274
272
275
273
if ( this . inputs [ 'url' ] . valid &&
276
274
this . inputs [ 'problem_type' ] . valid &&
277
- this . inputs [ 'image' ] . valid &&
278
- this . inputs [ 'img_too_big' ] . valid ) {
275
+ this . inputs [ 'image' ] . valid ) {
279
276
this . enableSubmits ( ) ;
280
277
}
281
278
} ;
@@ -330,7 +327,7 @@ function BugForm() {
330
327
var removeBanner = $ ( '.wc-UploadForm-button' ) ;
331
328
var uploadWrapper = $ ( '.wc-UploadForm-wrapper' ) ;
332
329
333
- // hide img_too_big errors (this will no-op if the user never saw one)
330
+ // hide upload image errors (this will no-op if the user never saw one)
334
331
$ ( '.wc-Form-helpMessage--imageUpload' ) . remove ( ) ;
335
332
$ ( '.wc-UploadForm-label' ) . show ( ) ;
336
333
0 commit comments