summaryrefslogtreecommitdiffstats
path: root/extensions/REMO/web
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/REMO/web')
-rw-r--r--extensions/REMO/web/js/moz_reps.js87
-rw-r--r--extensions/REMO/web/styles/moz_reps.css5
2 files changed, 92 insertions, 0 deletions
diff --git a/extensions/REMO/web/js/moz_reps.js b/extensions/REMO/web/js/moz_reps.js
new file mode 100644
index 000000000..88c60df51
--- /dev/null
+++ b/extensions/REMO/web/js/moz_reps.js
@@ -0,0 +1,87 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0. */
+
+$(document).ready(function() {
+ 'use strict';
+
+ var first_time = $("#first_time");
+ first_time.prop("checked", true);
+ first_time.change(function(evt) {
+ if (!this.checked) {
+ $("#prior_bug").show();
+ $("#prior_bug label").addClass("required");
+ }
+ else {
+ $("#prior_bug").hide();
+ $("#prior_bug label").removeClass("required");
+ }
+ }).change();
+
+ $("#underage").change(function(evt) {
+ if (this.checked) {
+ $('#underage_warning').show();
+ $('#submit').prop("disabled", true);
+ }
+ else {
+ $('#underage_warning').hide();
+ $('#submit').prop("disabled", false);
+ }
+ }).change();
+
+ $("#privacy").change(function(evt) {
+ if (this.checked) {
+ $('#submit').prop("disabled", false);
+ }
+ else {
+ $('#submit').prop("disabled", true);
+ }
+ }).change();
+
+ $('#tmRequestForm').submit(function (event) {
+ var mozillian_re = /^https?:\/\/(www\.)?mozillians.org\/([^\/]+\/)?u\/[^\/]+$/i;
+ var errors = [];
+ var missing = false;
+
+ $('label.required').each(function (index) {
+ var id = $(this).attr("for");
+ var input = $("#" + id);
+
+ if (id == 'mozillian') {
+ if (!input.val().match(mozillian_re)) {
+ input.addClass("missing");
+ errors.push("The Mozillian Account URL is invalid");
+ event.preventDefault();
+ }
+ else {
+ input.removeClass("missing");
+ }
+ }
+ else {
+ if (input.val() == "") {
+ input.addClass("missing");
+ missing = true;
+ event.preventDefault();
+ }
+ else {
+ input.removeClass("missing");
+ }
+ }
+ });
+
+ if (missing) {
+ errors.push("There are missing required fields");
+ }
+
+ if (errors.length) {
+ alert(errors.join("\n"));
+ }
+
+ $('#short_desc').val(
+ "Application Form: " + $('#first_name').val() + ' ' + $('#last_name').val()
+ );
+ });
+});
diff --git a/extensions/REMO/web/styles/moz_reps.css b/extensions/REMO/web/styles/moz_reps.css
index 216bdd234..884dc5896 100644
--- a/extensions/REMO/web/styles/moz_reps.css
+++ b/extensions/REMO/web/styles/moz_reps.css
@@ -32,6 +32,11 @@
font-size: 80%;
}
+label.required:before {
+ content: "* ";
+ color: red;
+}
+
#reps-form .missing {
box-shadow: #FF0000 0 0 1.5px 1px;
}