[%# 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.
  #%]

[%# Display product and component descriptions after their respective fields %]
<script [% script_nonce FILTER none %]>
  var Event = YAHOO.util.Event;
  var Dom = YAHOO.util.Dom;
  Event.onDOMReady(function() {
    // Display product description if user requests it
    var prod_desc = '[% bug.product_obj.description FILTER html_light FILTER js %]';
    if (prod_desc) {
      var field_container = Dom.get('field_container_product');
      var toggle_container = document.createElement('span');
      Dom.setAttribute(toggle_container, 'id', 'toggle_prod_desc');
      toggle_container.appendChild(document.createTextNode(' ('));
      var toggle_link = document.createElement('a');
      Dom.setAttribute(toggle_link, 'id', 'toggle_prod_desc_link');
      Dom.setAttribute(toggle_link, 'href', 'javascript:void(0);')
      toggle_link.appendChild(document.createTextNode('show info'));
      toggle_container.appendChild(toggle_link);
      toggle_container.appendChild(document.createTextNode(')'));
      field_container.appendChild(toggle_container);
      var desc_container = document.createElement('div');
      Dom.setAttribute(desc_container, 'id', 'prod_desc_container');
      Dom.addClass(desc_container, 'bz_default_hidden');
      desc_container.innerHTML = prod_desc;
      field_container.appendChild(desc_container);
      Event.addListener(toggle_link, 'click', function () {
        if (Dom.hasClass('prod_desc_container', 'bz_default_hidden')) {
          Dom.get('toggle_prod_desc_link').innerHTML  = 'hide info';
          Dom.removeClass('prod_desc_container', 'bz_default_hidden');
        }
        else {
          Dom.get('toggle_prod_desc_link').innerHTML = 'show info';
          Dom.addClass('prod_desc_container', 'bz_default_hidden');
        }
      });
    }

    // Display component description if user requests it
    var comp_desc = '[% bug.component_obj.description FILTER html_light FILTER js %]';
    if (comp_desc) {
      var field_container = Dom.get('field_container_component');
      var toggle_container = document.createElement('span');
      Dom.setAttribute(toggle_container, 'id', 'toggle_comp_desc');
      toggle_container.appendChild(document.createTextNode(' ('));
      var toggle_link = document.createElement('a');
      Dom.setAttribute(toggle_link, 'id', 'toggle_comp_desc_link');
      Dom.setAttribute(toggle_link, 'href', 'javascript:void(0);')
      toggle_link.appendChild(document.createTextNode('show info'));
      toggle_container.appendChild(toggle_link);
      toggle_container.appendChild(document.createTextNode(')'));
      field_container.appendChild(toggle_container);
      var desc_container = document.createElement('div');
      Dom.setAttribute(desc_container, 'id', 'comp_desc_container');
      Dom.addClass(desc_container, 'bz_default_hidden');
      desc_container.innerHTML = comp_desc;
      field_container.appendChild(desc_container);
      Event.addListener(toggle_link, 'click', function () {
        if (Dom.hasClass('comp_desc_container', 'bz_default_hidden')) {
          Dom.get('toggle_comp_desc_link').innerHTML  = 'hide info';
          Dom.removeClass('comp_desc_container', 'bz_default_hidden');
        }
        else {
          Dom.get('toggle_comp_desc_link').innerHTML = 'show info';
          Dom.addClass('comp_desc_container', 'bz_default_hidden');
        }
      });
    }
  });
</script>

[% UNLESS cf_hidden_in_product('cf_rank', bug.product, bug.component) %]
  [% IF bug.check_can_change_field('cf_rank', 0, 1) %]
    <label class="field_label" id="rank_label" for="cf_rank">Rank:</label>
    <input type="number" id="cf_rank" name="cf_rank" size="3" value="[% bug.cf_rank FILTER html %]">
  [% ELSIF bug.cf_rank != '' %]
    <label class="field_label" id="rank_label" for="cf_rank">Rank:</label>
    <span id="cf_rank">[% bug.cf_rank FILTER html %]</span>
  [% END %]
[% END %]
