Configuration Cookbook

This page is meant as a collection of good advices or hints what helped or worked for someone and does not fit on the two Cookbook pages CustomMarkupCookbook and ExternalToolsCookbook. Maybe it can also serve as a place for longer explanations for customized reports. (Yes, some reports are not self explaining)


Default Focus on pages with Forms

With the default settings it requires a lot of TAB keystrokes to get to the first input field of a form, because the focus is on one of the navigation links in the header section. Typical examples for this are the login page or the search page. The idea is to use a custom HTML header section with a Javascript handler that set the focus. A custom header can be set in the Configure Style section of the setup configuration. The following script block needs to be added to the header after the encoding, stylesheet and title tags. And the <body> tag needs an explicit onload handler to execute the javascript function. The input fields have short name tags like "u" for user, "s" for search or "t" for title (of the ticket), so it is easy to retrieve them with traditional Javascript code:

  <script type="text/javascript">
  function setFocus() {
    var firstForm, e;
    if ( document.forms && (firstForm = document.forms[0]) ) {
      if      ( (e = firstForm.elements["u"]) && e.type == "text" ) e.focus();
      else if ( (e = firstForm.elements["t"]) && e.type == "text" ) e.focus();
      else if ( (e = firstForm.elements["s"]) && e.type == "text" ) e.focus();
    }
  }
  </script>
  </head>
  <body onload="setFocus()">

The problem with the custom header is that it is applied to all pages and not only to those that contain a form. And even for some pages with a form you do not want to set the focus on the form elements. The Timeline is such a case where focusing on the form elements would make the browser scroll down to the Timeline options while the user wants to see the top entries.

The additional test in the code, if the form element is an input/text field makes sure that none of the elements on the timeline form match the criteria, because the "s" and "t" elements of the Timeline are radio buttons and checkboxes and hence setting the focus is not applied to them. (see also Ticket #806)