From ac997a9166d6ac7ab0822f6935679fa0394eeb58 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Wed, 18 Feb 2015 11:41:17 +0800 Subject: Bug 1118987: create a new bug form for discourse issues (based on form.reps.it) --- extensions/REMO/web/js/moz_csa_discourse.js | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 extensions/REMO/web/js/moz_csa_discourse.js (limited to 'extensions/REMO/web/js') diff --git a/extensions/REMO/web/js/moz_csa_discourse.js b/extensions/REMO/web/js/moz_csa_discourse.js new file mode 100644 index 000000000..a885588f6 --- /dev/null +++ b/extensions/REMO/web/js/moz_csa_discourse.js @@ -0,0 +1,44 @@ +/* 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'; + + $('#tmRequestForm').submit(function (event) { + var mozillian_re = /^https?:\/\/mozillians.org\/([^\/]+\/)?u\/[^\/]+$/i; + var errors = []; + var missing = false; + + $('label.required').each(function (index) { + var id = $(this).attr("for"); + var input = $("#" + id); + + 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")); + event.preventDefault(); + return; + } + + $('#short_desc').val( + "IT Discourse Request: " + $('#community').val() + ' (' + $('#name').val() + ')' + ); + }); +}); -- cgit v1.2.3-24-g4f1b