[%# 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. #%] [% PROCESS global/variables.none.tmpl %] [% inline_style = BLOCK %] #pr_form { padding: 10px; width: 600px; } #pr_form input[type="text"], #pr_form textarea { width: 100%; margin-bottom: 2px; } #pr_form .calendar { width: 100px; } #pr_form .user { width: 300px; } #pr_form select { width: 200px; } #pr_form .required:after { content: " *"; color: red; } #pr_form .missing { box-shadow: 0px 0px 5px red; } #pr_form label { font-weight: bold; display: block; } #pr_form label.normal { font-weight: normal; display: inline; } #pr_form .calendar_button { margin-top: 0.5em; } #pr_form .desc { padding-bottom: 3px; } #pr_form .field { margin-bottom: 10px; } #pr_form .indent { margin-left: 30px; } #pr_form textarea { font-family: inherit; font-size: inherit; } #pr_form .head { font-weight: bold; border-top: 1px solid silver; border-bottom: 1px solid silver; padding: 5px; margin: 1em 0; background: #ddd; } #pr_form fieldset { border: none; } #pr_form .extra { font-style: italic; } #pr_form .extra a { text-decoration: underline; } #pr_form #commit { margin-top: 20px; } #pr_form .linked { display: block; margin-top: 2px; width: 300px; } [% END %] [% inline_javascript = BLOCK %] var pr_inited = false; function init_listener(id, event, fn) { YAHOO.util.Event.addListener(id, event, fn); bz_fireEvent(document.getElementById(id), event); } function toggle_linked(id, value, suffix) { var el = document.getElementById(id); var show = el.type == 'checkbox' ? el.checked : el.value == value; if (show) { var linked = document.getElementById(id + suffix); YAHOO.util.Dom.addClass(linked, 'linked'); YAHOO.util.Dom.removeClass(linked, 'bz_default_hidden'); if (pr_inited && linked.nodeName == "INPUT") { linked.focus(); linked.select(); } } else { YAHOO.util.Dom.addClass(id + suffix, 'bz_default_hidden'); } } function init_other(id) { init_listener(id, 'change', function(o) { toggle_linked(id, 'Other:', '_other'); }); } YAHOO.util.Event.onDOMReady(function() { init_listener('metrica', 'change', function(o) { toggle_linked('metrica', 'Yes', '_extra'); }); init_listener('budget', 'change', function(o) { toggle_linked('budget', 'Extra', '_extra'); }); init_listener('proj_mat_online', 'click', function(o) { toggle_linked('proj_mat_online', 0, '_extra'); }); init_listener('proj_mat_file', 'click', function(o) { toggle_linked('proj_mat_file', 0, '_extra'); }); init_listener('pr_mat_online', 'click', function(o) { toggle_linked('pr_mat_online', 0, '_extra'); }); init_listener('pr_mat_file', 'click', function(o) { toggle_linked('pr_mat_file', 0, '_extra'); }); init_other('pr_owner'); init_other('group_focus'); init_other('project_type'); init_other('region'); init_other('press_center'); init_other('internal_resources'); init_other('external_resources'); init_other('localization'); init_other('audience'); pr_inited = true; }); function validate_other(id, value, suffix) { var el = document.getElementById(id); if (!value) value = 'Other:'; if (!suffix) suffix = '_other'; if (!el) { console.error('Failed to find element: ' + elem_id); return false; } if (el.type == 'checkbox') { if (!el.checked) return true; } else if (el.value != value) { return true; } return isFilledOut(id + suffix); } function validate_form() { var Dom = YAHOO.util.Dom; var old_missing = Dom.getElementsByClassName('missing'); for (var i = 0, il = old_missing.length; i < il; i++) { Dom.removeClass(old_missing[i], 'missing'); } var missing = []; if (!isFilledOut('short_desc')) missing.push(['short_desc', 'Project Title']); if (!isFilledOut('desc')) missing.push(['desc', 'Project Description and Scope']); if (!isFilledOut('start_date')) missing.push(['start_date', 'Start Date']); if (!isFilledOut('announce_date')) missing.push(['announce_date', 'Announcement Date']); if (!isFilledOut('cf_due_date')) missing.push(['cf_due_date', 'Internal Deadline']); if (!isFilledOut('pr_owner')) missing.push(['pr_owner', 'Project PR Owner']); if (!isFilledOut('owner')) missing.push(['owner', 'Project Owner']); if (!isFilledOut('rasci_a')) missing.push(['rasci_a', 'RASCI Approver']); if (!isFilledOut('tier')) missing.push(['tier', 'Tier']); if (!isFilledOut('project_type')) missing.push(['project_type', 'Project Type']); if (!isFilledOut('pr_approach')) missing.push(['pr_approach', 'PR Approach']); if (!isFilledOut('group_focus')) missing.push(['group_focus', 'Product Group Focus']); if (!validate_other('group_focus')) missing.push(['group_focus', 'Product Group Focus - Other']); if (!isFilledOut('region')) missing.push(['region', 'Region']); if (!validate_other('region')) missing.push(['region', 'Region - Other']); if (!isFilledOut('project_goals')) missing.push(['project_goals', 'Project Goals']); if (!isFilledOut('pr_goals')) missing.push(['pr_goals', 'PR Goals']); if (!isFilledOut('company_goal')) missing.push(['company_goal', 'Company Goal']); if (!isOneChecked(document.forms.pr_form.audience)) missing.push(['audience_group', 'Audiences']); if (!validate_other('audience')) missing.push(['audience', 'Audience - Other']); if (!isFilledOut('key_messages')) missing.push(['key_messages', 'Key Messages']); if (Dom.get('proj_mat_online').checked) { if (!isFilledOut('proj_mat_online_desc')) missing.push(['proj_mat_online_desc', 'Project Materials - Online Description']); if (!isFilledOut('proj_mat_online_link')) missing.push(['proj_mat_online_link', 'Project Materials - Online Link']); } if (Dom.get('proj_mat_file').checked) { if (!isFilledOut('proj_mat_file_desc')) missing.push(['proj_mat_file_desc', 'Project Materials - Upload Description']); if (!isFilledOut('proj_mat_file_attach')) missing.push(['proj_mat_file_attach', 'Project Materials - Upload File']); } if (Dom.get('pr_mat_online').checked) { if (!isFilledOut('pr_mat_online_desc')) missing.push(['pr_mat_online_desc', 'PR Project Materials - Online Description']); if (!isFilledOut('pr_mat_online_link')) missing.push(['pr_mat_online_link', 'PR Project Materials - Online Link']); } if (Dom.get('pr_mat_file').checked) { if (!isFilledOut('pr_mat_file_desc')) missing.push(['pr_mat_file_desc', 'PR Project Materials - Upload Description']); if (!isFilledOut('pr_mat_file_attach')) missing.push(['pr_mat_file_attach', 'PR Project Materials - Upload File']); } if (!validate_other('press_center')) missing.push(['press_center', 'Press Center Update - Other']); if (!validate_other('internal_resources')) missing.push(['internal_resources', 'Internal Resources Needed - Other']); if (!validate_other('external_resources')) missing.push(['external_resources', 'External Resources Needed - Other']); if (!validate_other('localization')) missing.push(['localization', 'Localization Needed - Other']); if (!isFilledOut('budget')) missing.push(['budget', 'Budget']); if (!validate_other('budget', 'Extra', '_extra')) missing.push(['budget', 'Budget - Extra']); if (missing.length) { var missing_text = []; for (var i = 0, il = missing.length; i < il; i++) { Dom.addClass(missing[i][0], 'missing'); missing_text.push(missing[i][1]); } if (missing_text.length == 1) { alert("The field '" + missing_text[0] + "' is required."); } else { alert("The following fields are required:\n- " + missing_text.join("\n- ")); } return false; } return true; } [% END %] [% PROCESS global/header.html.tmpl title = "PR Project Form" generate_api_token = 1 style = inline_style javascript = inline_javascript javascript_urls = [ 'extensions/BMO/web/js/form_validate.js', 'js/field.js', 'js/util.js' ] %] [% UNLESS user.in_group('pr-private') %]