[%# 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 %]
#creative_form {
  padding: 10px;
}
#creative_form .required:after {
  content: " *";
  color: var(--required-label-color);
}
#creative_form .field_label {
  font-weight: bold;
}
#creative_form .field_desc {
  padding-bottom: 3px;
}
#creative_form .field_desc,
#creative_form .head_desc {
  width: 600px;
  word-wrap: normal;
}
#creative_form .head_desc {
  padding-top: 5px;
  padding-bottom: 12px;
}
#creative_form .form_section {
  margin-bottom: 10px;
}
#creative_form input[disabled] {
  background: transparent;
}
.yui-calcontainer {
  z-index: 2;
}
[% END %]

[% inline_javascript = BLOCK %]
function validateAndSubmit() {
  var alert_text = '';
  if (!isFilledOut('overview')) alert_text += 'Please enter a value for Project Overview.\n';
  if (!isFilledOut('short_desc')) alert_text += 'Please enter a value for Request Title.\n';
  if (!isFilledOut('specs')) alert_text += 'Please enter a value for Creative Specs.\n';
  if (!isFilledOut('cta_design')) alert_text += 'Please enter a value for CTA Design.\n';
  if (!isFilledOut('launch_date')) alert_text += 'Please enter a value for the expected launch date.\n';
  if (!isFilledOut('goal')) alert_text += 'Please select a value for Mozilla Goal.\n';
  if (YAHOO.util.Dom.get('goal').value == 'Other') {
    if (!isFilledOut('goal_other')) alert_text += 'Please select a value for Mozilla Goal Other.\n';
  }
  if (YAHOO.util.Dom.get('type_copy').checked == false
      && YAHOO.util.Dom.get('type_design').checked == false
      && YAHOO.util.Dom.get('type_video').checked == false
      && YAHOO.util.Dom.get('type_other').checked == false)
  {
     alert_text += 'Please select at least one type of help needed.\n';
  }
  if (YAHOO.util.Dom.get('type_other').checked == true) {
    if (!isFilledOut('type_other_text')) alert_text += 'Please enter a value for other type of help needed.\n';
  }
  if (alert_text != '') {
    alert(alert_text);
    return false;
  }

  document.getElementById('cc').value = document.getElementById('poc').value;
  if (document.getElementById('collective').checked) {
    document.getElementById('cc').value = document.getElementById('cc').value + ', smartell@mozilla.com, enoonan@mozilla.com';
    document.getElementById('status_whiteboard').value = 'Creative Collective Project';
  } else {
    document.getElementById('status_whiteboard').value = '';
  }

  return true;
}
function toggleGoalOther() {
  var goal_select = YAHOO.util.Dom.get('goal');
  if (goal_select.options[goal_select.selectedIndex].value == 'Other') {
    YAHOO.util.Dom.removeClass('goal_other','bz_default_hidden');
  }
  else {
    YAHOO.util.Dom.addClass('goal_other','bz_default_hidden');
  }
}
function toggleTypeOther(element) {
  var other_text = YAHOO.util.Dom.get('type_other_text');
  if (element.checked == true) {
    other_text.disabled = false;
    other_text.focus();
  }
  else {
    other_text.disabled = true;
  }
}

[% END %]

[% PROCESS global/header.html.tmpl
   title = "Creative Initiation Form"
   generate_api_token = 1
   style = inline_style
   javascript = inline_javascript
   javascript_urls = [ 'extensions/BMO/web/js/form_validate.js',
                       'js/field.js' ]
%]

[% USE Bugzilla %]
[% cgi = Bugzilla.cgi %]

<form id="creative_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
      onSubmit="return validateAndSubmit();">
  <input type="hidden" name="filed_via" value="custom_form">
  <input type="hidden" name="format" value="creative">
  <input type="hidden" name="product" value="Marketing">
  <input type="hidden" name="component" value="Design">
  <input type="hidden" name="rep_platform" value="All">
  <input type="hidden" name="op_sys" value="Other">
  <input type="hidden" name="version" value="unspecified">
  <input type="hidden" name="bug_type" value="task">
  <input type="hidden" name="cc" id="cc" value="">
  <input type="hidden" name="status_whiteboard" id="status_whiteboard" value="">
  <input type="hidden" name="token" value="[% token FILTER html %]">

<img title="Creative Initiation Form" src="[% basepath FILTER none %]extensions/BMO/web/images/creative.png">

<div class="head_desc">
  Have a new project or campaign that requires copy, design, video or other awesomeness
  from your friendly neighborhood Brand Team? Please use this form to tell us about it
  and we'll get back to you with next steps as soon as possible.
</div>

<div class="form_section">
  <label for="short_desc" class="field_label required">Project / Request Title</label>
  <div class="field_desc">
    Describe your project or request in a few words or a short phrase.
  </div>
  <input type="text" name="short_desc" id="short_desc" size="80">
</div>

<div class="form_section">
  <label for="overview" class="field_label required">Project Overview</label>
  <div class="field_desc">
    Briefly describe the background, goals and objectives for this project.
  </div>
  <textarea id="overview" name="overview" cols="80" rows="5"></textarea>
</div>

<div class="form_section">
  <label for="specs" class="field_label required">Creative Specs and Deliverables</label>
  <div class="field_desc">
    Select what sort of help you need (check at least one or more)
  </div>
  <input type="checkbox" name="type_copy" id="type_copy" value="1">
  <label for="type_copy">Copy</label>
  <br>
  <input type="checkbox" name="type_design" id="type_design" value="1">
  <label for="type_design">Design</label>
  <br>
  <input type="checkbox" name="type_video" id="type_video" value="1">
  <label for="type_video">Video</label>
  <br>
  <input type="checkbox" name="type_other" id="type_other" value="1" onchange="toggleTypeOther(this);">
  <label for="type_other">Other</label>&nbsp;&nbsp;
  <input type="text" name="type_other_text" id="type_other_text" disabled>
  <br>
  <br>
  <div class="field_desc">
    <strong class="required">Specs</strong><br>
    What is the final deliverable and what format should it be delivered in?
    Please include information on the format, image/file size, word count, video length,
    etc. We like details here.
  </div>
  <textarea id="specs" name="specs" cols="80" rows="5"></textarea>
  <br>
  <br>
  <div class="field_desc">
    <strong class="required">CTAs and design directions</strong><br>
    Provide as much information as possible. Make sure to include links to documents with copy,
    mock-ups, wireframes, or any other information or assets that could help with direction.
  </div>
  <textarea id="cta_design" name="cta_design" cols="80" rows="5"></textarea>
</div>

<div class="form_section">
  <label for="launch_date" class="field_label required">
    Expected Launch Date
  </label>
  <div class="field_desc">
    When do you anticipate your project launching? We will determine a creative
    due date with you based on this to ensure that it works for everyone.
  </div>
  <input name="launch_date" size="20" id="launch_date" value=""
         onchange="updateCalendarFromField(this)">
  <button type="button" class="calendar_button"
          id="button_calendar_launch_date"
          onclick="showCalendar('launch_date')">
    <span>Calendar</span>
  </button>
  <div id="con_calendar_launch_date"></div>
  <script [% script_nonce FILTER none %]>
    createCalendar('launch_date')
  </script>
</div>

<div class="form_section">
  <label for="goal" class="field_label required">Mozilla Goal</label>
  <div class="field_desc">
    Which high-level Mozilla goal does this project support?
  </div>
  <select id="goal" name="goal"
          onchange="toggleGoalOther();">
    <option value="">Please select..</option>
    <option value="Firefox Browser">Firefox Browser</option>
    <option value="Million Mozillians">Million Mozillians</option>
    <option value="Services">Services</option>
    <option value="Org Support">Org Support</option>
    <option value="Other">Other</option>
  </select>
  <br>
  <input type="text" name="goal_other" id="goal_other" size="40"
         class="bz_default_hidden" value="">
</div>

<div class="form_section">
  <label class="field_label">Mozilla Creative Collective</label>
  <div>
    <input type="checkbox" id="collective" name="collective">
    <label for="collective">
      I would like a
      <a href="https://wiki.mozilla.org/Design/creativecollective"
         target="_blank" rel="noopener noreferrer">Mozilla Creative Collective</a> designer to work on this project.
    </label>
  </div>
</div>

<div class="form_section">
  <label for="poc" class="field_label">Points of Contact</label>
  <div class="field_desc">
    Who should be kept in the loop and informed of updates (and CC'd on the [% terms.bug %])?
  </div>
  [% INCLUDE global/userselect.html.tmpl
     id       => "poc"
     name     => "poc"
     value    => ""
     size     => 80
     classes  => ["bz_userfield"]
     multiple => 5
  %]
</div>

<div class="head_desc">
  Thanks! Once you hit submit, your request will go off into the vortex of creative magic.
  (Actually, it goes to [% terms.Bugzilla %], but that doesn't sound as cool.) We'll be in touch soon
  with next steps and to let you know if we need any additional info.
</div>

<input type="submit" id="commit" value="Submit">

<p>
  [ <span class="required_star">*</span> <span class="required_explanation">Required Field</span> ]
</p>

</form>

[% PROCESS global/footer.html.tmpl %]
