Skip to content

Commit 3f63808

Browse files
Mike Taylordeepthivenkat
Mike Taylor
authored andcommitted
Issue webcompat#1167. Add checkOptionalNonEmpty method for browser and os fields.
1 parent bf3cbc4 commit 3f63808

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

webcompat/static/js/lib/bugform.js

+16
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ function BugForm() {
5959
this.descField.on('focus', _.bind(this.checkProblemTypeValidity, this));
6060
this.problemType.on('change', _.bind(this.checkProblemTypeValidity, this));
6161
this.uploadField.on('change', _.bind(this.checkImageTypeValidity, this));
62+
this.osField.add(this.browserField)
63+
.on('blur input', _.bind(this.checkOptionalNonEmpty, this));
6264
this.submitButtons.on('click', _.bind(function(e) {
6365
if (e.target && e.target.value) {
6466
// store a reference to what report button was clicked
@@ -197,6 +199,19 @@ function BugForm() {
197199
}
198200
};
199201

202+
/* Check if Browser and OS are empty or not, only
203+
so we can set them to valid (there is no invalid state) */
204+
this.checkOptionalNonEmpty = function() {
205+
_.forEach([this.browserField, this.osField], _.bind(function(input) {
206+
var inputId = input.prop('id');
207+
if (input.val()) {
208+
this.makeValid(inputId);
209+
} else {
210+
this.makeInvalid(inputId);
211+
}
212+
}, this));
213+
};
214+
200215
this.checkForm = function() {
201216
// Run through and see if there's any user input in the
202217
// required inputs
@@ -208,6 +223,7 @@ function BugForm() {
208223
this.checkURLValidity();
209224
this.checkProblemTypeValidity();
210225
this.checkImageTypeValidity();
226+
this.checkOptionalNonEmpty();
211227
// and open the form, if it's not already open
212228
if (!this.reportButton.hasClass('is-open')) {
213229
this.reportButton.click();

0 commit comments

Comments
 (0)