|
4 | 4 |
|
5 | 5 | function BugForm() {
|
6 | 6 | this.form = $('#js-ReportForm form');
|
7 |
| - this.descField = $('#description'); |
8 | 7 | this.submitButtons = $('#js-ReportForm .js-Button');
|
9 | 8 | this.loadingIndicator = $('.js-Loader');
|
10 | 9 | this.reportButton = $('#js-ReportBug');
|
@@ -50,6 +49,7 @@ function BugForm() {
|
50 | 49 | this.problemType = this.inputs.problem_type.el;
|
51 | 50 | this.uploadField = this.inputs.image.el;
|
52 | 51 | this.urlField = this.inputs.url.el;
|
| 52 | + this.descField = $('#description'); |
53 | 53 |
|
54 | 54 | this.init = function() {
|
55 | 55 | this.checkParams();
|
@@ -250,29 +250,34 @@ function BugForm() {
|
250 | 250 | .removeClass('is-validated js-no-error')
|
251 | 251 | .addClass('is-error js-form-error');
|
252 | 252 |
|
253 |
| - if (id === 'url') { |
254 |
| - inlineHelp.insertAfter('label[for=' + id + ']'); |
255 |
| - } |
256 |
| - |
257 |
| - if (id === 'problem_type') { |
258 |
| - inlineHelp.appendTo('.wc-Form-information'); |
259 |
| - } |
260 |
| - |
261 |
| - if (id === 'image') { |
262 |
| - // hide the error in case we already saw one |
263 |
| - $('.wc-Form-helpMessage--imageUpload').remove(); |
264 |
| - |
265 |
| - inlineHelp.removeClass('wc-Form-helpMessage') |
266 |
| - .addClass('wc-Form-helpMessage--imageUpload') |
267 |
| - .insertAfter('.js-image-upload-label'); |
268 |
| - |
269 |
| - $('.wc-UploadForm-label').hide(); |
270 |
| - // "reset" the form field, because the file would get rejected |
271 |
| - // from the server anyways. |
272 |
| - this.uploadField.val(this.uploadField.get(0).defaultValue); |
273 |
| - // return early because we just cleared out the input. |
274 |
| - // someone might decide to just not select an image. |
275 |
| - return; |
| 253 | + switch (id) { |
| 254 | + case 'os': |
| 255 | + case 'browser': |
| 256 | + // remove error classes, because these inputs are optional |
| 257 | + this.inputs[id].el.parents('.js-Form-group') |
| 258 | + .removeClass('is-error js-form-error'); |
| 259 | + break; |
| 260 | + case 'url': |
| 261 | + inlineHelp.insertAfter('label[for=' + id + ']'); |
| 262 | + break; |
| 263 | + case 'problem_type': |
| 264 | + inlineHelp.appendTo('.wc-Form-information'); |
| 265 | + break; |
| 266 | + case 'image': |
| 267 | + // hide the error in case we already saw one |
| 268 | + $('.wc-Form-helpMessage--imageUpload').remove(); |
| 269 | + |
| 270 | + inlineHelp.removeClass('wc-Form-helpMessage') |
| 271 | + .addClass('wc-Form-helpMessage--imageUpload') |
| 272 | + .insertAfter('.js-image-upload-label'); |
| 273 | + |
| 274 | + $('.wc-UploadForm-label').hide(); |
| 275 | + // "reset" the form field, because the file would get rejected |
| 276 | + // from the server anyways. |
| 277 | + this.uploadField.val(this.uploadField.get(0).defaultValue); |
| 278 | + // return early because we just cleared out the input. |
| 279 | + // someone might decide to just not select an image. |
| 280 | + return; |
276 | 281 | }
|
277 | 282 |
|
278 | 283 | this.disableSubmits();
|
|
0 commit comments