summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/web
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-11-26 23:01:03 +0100
committerDavid Lawrence <dkl@mozilla.com>2014-11-26 23:01:03 +0100
commit412b8264dd8b7832e273be8e887df2c47c46b297 (patch)
tree0aec273e0a4d872949c5b3d26ee2feeeca9eb2ca /extensions/BMO/web
parent55d148d167630fce08f40e6fcf2ab9def0b9699d (diff)
downloadbugzilla-412b8264dd8b7832e273be8e887df2c47c46b297.tar.gz
bugzilla-412b8264dd8b7832e273be8e887df2c47c46b297.tar.xz
Bug 1063818: Updates to form.dev-engagement-event
Diffstat (limited to 'extensions/BMO/web')
-rw-r--r--extensions/BMO/web/js/dev_engagement.js290
-rw-r--r--extensions/BMO/web/js/form_validate.js15
2 files changed, 305 insertions, 0 deletions
diff --git a/extensions/BMO/web/js/dev_engagement.js b/extensions/BMO/web/js/dev_engagement.js
new file mode 100644
index 000000000..0bb7313b1
--- /dev/null
+++ b/extensions/BMO/web/js/dev_engagement.js
@@ -0,0 +1,290 @@
+/* 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. */
+
+var DE = {
+ formUpdate: function () {
+ var sections = {
+ developer_event_warning: false,
+ code_of_conduct_warning: false,
+ mozilla_attending_warning: false,
+ mozillian_profile_url_section: false,
+ mozilla_attending_list_section: false,
+ code_of_conduct_url_section: false,
+ speaker_needed_detail_section: false,
+ previous_event_details_section: false
+ };
+ var commit_disabled = false;
+
+ if (fieldValue('developer_event') == 'No') {
+ commit_disabled = true;
+ sections.developer_event_warning = true;
+ }
+
+ if (fieldValue('mozilla_attending') == 'No') {
+ sections.mozilla_attending_warning = true;
+ }
+ else if (fieldValue('mozilla_attending') == 'Yes') {
+ sections.mozilla_attending_list_section = true;
+ }
+
+ if (fieldValue('code_of_conduct') == 'No') {
+ commit_disabled = true;
+ sections.code_of_conduct_warning = true;
+ }
+ else if (fieldValue('code_of_conduct') == 'Yes') {
+ sections.code_of_conduct_url_section = true;
+ }
+
+ if (fieldValue('vouched_mozillian') == 'Yes') {
+ sections.mozillian_profile_url_section = true;
+ }
+
+ if (fieldValue('previous_event') == 'Yes') {
+ sections.previous_event_details_section = true;
+ }
+
+ if (fieldValue('speaker_needed') == 'Yes') {
+ sections.speaker_needed_detail_section = true;
+ }
+
+ for (section in sections) {
+ if (sections[section]) {
+ DE.removeClass(document.getElementById(section),
+ 'bz_default_hidden');
+ }
+ else {
+ DE.addClass(document.getElementById(section),
+ 'bz_default_hidden');
+ }
+ }
+ YAHOO.util.Dom.get('commit').disabled = commit_disabled;
+ },
+ focusOther: function (id, other_id) {
+ var cb = document.getElementById(id);
+ var input = document.getElementById(other_id);
+ input.disabled = !cb.checked;
+ if (cb.checked) input.focus();
+ },
+ onSubmit: function (ev) {
+ var alert_text = '';
+ // Required fields check
+ var required_text_fields = {
+ 'name' : 'Please enter your name.',
+ 'email' : 'Please enter your email address.',
+ 'role' : 'Please enter your role.',
+ 'event' : 'Please enter the event name.',
+ 'start_date' : 'Please enter the event start date.',
+ 'end_date' : 'Please enter the event end date.',
+ 'location' : 'Please enter a location description for the event.',
+ 'attendees' : 'Please enter number of expected attendees.',
+ 'desc' : 'Please enter a description of the event.',
+ };
+
+ var required_selects = {
+ 'vouched_mozillian' : 'Please select if you are a vouched mozillian.',
+ 'developer_event' : 'Please select if this is a developer event.',
+ 'mozilla_attending' : 'Please select if Mozilla is attending the event.',
+ 'code_of_conduct' : 'Please select if the event has a code of conduct.',
+ 'event_location' : 'Please a location for the event.',
+ 'previous_event' : 'Please select if Mozilla has sponsored this event before.',
+ 'development_session' : 'Please select if this event includes a development session.',
+ };
+
+ if (fieldValue('vouched_mozillian') == 'Yes')
+ required_text_fields['mozillian_profile_url']
+ = 'Please enter your mozillian profile url.';
+ if (fieldValue('mozilla_attending') == 'Yes')
+ required_text_fields['mozilla_attending_list']
+ = 'Please enter a list of Mozilla persons attending the event.';
+ if (fieldValue('code_of_conduct') == 'Yes')
+ required_text_fields['code_of_conduct_url']
+ = 'Please enter a code of conduct url.';
+ if (fieldValue('previous_event') == 'Yes') {
+ required_text_fields['previous_event_year']
+ = 'Please select a year for the previous sponsored event.';
+ required_text_fields['previous_event_name']
+ = 'Please enter a name for the previous sponsored event.';
+ }
+
+ var relevant_products = [
+ 'product_fxos',
+ 'product_fx',
+ 'product_webmaker',
+ 'product_persona',
+ 'product_marketplace',
+ 'product_tb',
+ 'product_fow',
+ 'product_devtools',
+ 'product_other',
+ ];
+ var found = 0;
+ for (var i = 0, l = relevant_products.length; i < l; i ++) {
+ if (isChecked(relevant_products[i])) found = 1;
+ }
+ if (!found)
+ alert_text += "Please check one or more relevant products.\n";
+ if (isChecked('product_other'))
+ required_text_fields['product_other_text']
+ = 'Please enter a value for other relevant product.';
+
+ var request_types = [
+ 'request_keynote',
+ 'request_talk',
+ 'request_workshop',
+ 'request_sponsorship',
+ 'request_other'
+ ];
+ found = 0;
+ for (var i = 0, l = request_types.length; i < l; i ++) {
+ if (isChecked(request_types[i])) found = 1;
+ }
+ if (!found)
+ alert_text += "Please check one or more items being requested of Mozilla.\n";
+ if (isChecked('request_other'))
+ required_text_fields['request_other_text']
+ = 'Please enter a value for other item being requested.';
+
+ for (field in required_text_fields) {
+ if (!isFilledOut(field))
+ alert_text += required_text_fields[field] + "\n";
+ }
+ for (field in required_selects) {
+ if (!fieldValue(field))
+ alert_text += required_selects[field] + "\n";
+ }
+ if (alert_text != '') {
+ alert(alert_text);
+ YAHOO.util.Event.stopEvent(ev);
+ }
+
+ // Whiteboard value
+ var wb = '';
+ var location_wb_map = {
+ 'Africa' : 'africa',
+ 'Asia' : 'asia',
+ 'Australia' : 'australia',
+ 'Europe' : 'europe',
+ 'North America' : 'north-america',
+ 'Central / South America' : 'central-south-america',
+ 'Multiple' : 'multiple',
+ 'Online only' : 'online',
+ };
+ wb += '[location:' + location_wb_map[fieldValue('event_location')] + '] ';
+
+ var request_items = [];
+ if (document.getElementById('request_keynote').checked)
+ request_items.push('keynote');
+ if (document.getElementById('request_talk').checked)
+ request_items.push('talk');
+ if (document.getElementById('request_workshop').checked)
+ request_items.push('workshop');
+ if (document.getElementById('request_sponsorship').checked)
+ request_items.push('sponsorship');
+ if (document.getElementById('request_other').checked)
+ request_items.push('other');
+ wb += '[requesting:' + request_items.join(',') + '] ';
+
+ var product_items = [];
+ if (document.getElementById('product_fxos').checked)
+ product_items.push('firefox-os');
+ if (document.getElementById('product_fx').checked)
+ product_items.push('firefox-web-browser');
+ if (document.getElementById('product_webmaker').checked)
+ product_items.push('webmaker');
+ if (document.getElementById('product_persona').checked)
+ product_items.push('persona');
+ if (document.getElementById('product_marketplace').checked)
+ product_items.push('marketplace');
+ if (document.getElementById('product_tb').checked)
+ product_items.push('thunderbird');
+ if (document.getElementById('product_fow').checked)
+ product_items.push('open-web');
+ if (document.getElementById('product_devtools').checked)
+ product_items.push('developer-tools');
+ if (document.getElementById('product_other').checked)
+ product_items.push('other');
+ wb += '[products:' + product_items.join(',') + '] ';
+
+ if (fieldValue('developer_event') == 'Yes')
+ wb += '[developer-event:true] ';
+ var mozilla_attending = fieldValue('mozilla_attending') == 'Yes' ? 'true' : 'false';
+ wb += '[mozilla-already-attending:' + mozilla_attending + '] ';
+ var vouched = fieldValue('vouched_mozillian') == 'Yes' ? 'true' : 'false';
+ wb += '[requested-by-mozillian:' + vouched + '] ';
+ if (fieldValue('code_of_conduct') == 'Yes')
+ wb += '[code-of-conduct:true] ';
+ var previous_event = fieldValue('previous_event') == 'Yes' ? 'true' : 'false';
+ wb += '[past-sponsorship:' + previous_event + '] ';
+ var needs_speaker = fieldValue('speaker_needed') == 'Yes' ? 'true' : 'false';
+ wb += '[needs-speaker:' + needs_speaker + '] ';
+ var sponsor_booth = fieldValue('sponsor_booth') == 'Yes' ? 'true' : 'false';
+ wb += '[option-to-sponsor-booth:' + sponsor_booth + '] ';
+ var dev_session_map = {
+ 'Yes' : 'true',
+ 'No' : 'false',
+ 'To be determined' : 'tbd',
+ };
+ wb += '[open-web-session-at-event:' +
+ dev_session_map[fieldValue('development_session')] + '] ';
+ wb += '[expected-attendees:' + fieldValue('attendees') + '] ';
+ var prospectus = fieldValue('data') ? 'true' : 'false';
+ wb += '[prospectus:' + prospectus + '] ';
+ document.getElementById('status_whiteboard').value = wb.replace(/ $/, '');
+
+ var summary = document.getElementById('event').value + ', ' + DE.long_start_date();
+ var loc = document.getElementById('location').value;
+ if (loc)
+ summary = summary + ' (' + loc + ')';
+ document.getElementById('short_desc').value = summary;
+ document.getElementById('bug_file_loc').value = document.getElementById('link').value;
+ document.getElementById('cf_due_date').value = document.getElementById('start_date').value;
+ },
+ long_start_date: function () {
+ var ymd = document.getElementById('start_date').value.split('-');
+ if (ymd.length != 3)
+ return '';
+ var month = YAHOO.bugzilla.calendar_start_date.cfg.getProperty('MONTHS_LONG')[ymd[1] - 1];
+ return month + ' ' + ymd[0];
+ },
+ hasClass: function (element, class_name) {
+ return element.className.match(new RegExp('(\\s|^)' + class_name + '(\\s|$)'));
+ },
+ addClass: function (element, class_name) {
+ if (!DE.hasClass(element, class_name))
+ element.className += " " + class_name;
+ },
+ removeClass: function (element, class_name) {
+ if (DE.hasClass(element, class_name)) {
+ var reg = new RegExp('(\\s|^)' + class_name + '(\\s|$)');
+ element.className = element.className.replace(reg,' ');
+ }
+ },
+ init: function() {
+ YAHOO.util.Event.on('dev_form', 'submit', DE.onSubmit);
+ YAHOO.util.Event.on('product_other', 'change', function () {
+ DE.focusOther('product_other', 'product_other_text');
+ });
+ YAHOO.util.Event.on('request_other', 'change', function () {
+ DE.focusOther('request_other', 'request_other_text');
+ });
+ var select_inputs = [
+ 'developer_event',
+ 'code_of_conduct',
+ 'vouched_mozillian',
+ 'mozilla_attending',
+ 'speaker_needed',
+ 'previous_event'
+ ];
+ for (var i = 0, l = select_inputs.length; i < l; i++) {
+ YAHOO.util.Event.on(select_inputs[i], 'change', DE.formUpdate);
+ }
+ DE.formUpdate();
+ createCalendar('start_date');
+ createCalendar('end_date');
+ }
+};
+YAHOO.util.Event.onDOMReady(DE.init);
diff --git a/extensions/BMO/web/js/form_validate.js b/extensions/BMO/web/js/form_validate.js
index 7e9746a5c..53b16ab1c 100644
--- a/extensions/BMO/web/js/form_validate.js
+++ b/extensions/BMO/web/js/form_validate.js
@@ -39,3 +39,18 @@ function isOneChecked(form_nodelist) {
}
return false;
}
+
+function fieldValue(elem_id) {
+ var el = document.getElementById(elem_id);
+ if (!el) {
+ console.error('Failed to find element: ' + elem_id);
+ return false;
+ }
+ if (el.type == 'text'
+ || el.type == 'textarea'
+ || el.type == 'file')
+ {
+ return el.value;
+ }
+ return el.options[el.selectedIndex].value;
+}