[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/includes/ -> dropdown.theme.inc (source)

   1  <?php
   2  // $Id: dropdown.theme.inc,v 1.5.2.1 2009/10/02 17:44:17 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   * Provide a javascript based dropdown menu.
   7   *
   8   * The dropdown menu will show up as a clickable link; when clicked,
   9   * a small menu will slide down beneath it, showing the list of links.
  10   *
  11   * The dropdown will stay open until either the user has moved the mouse
  12   * away from the box for > .5 seconds, or can be immediately closed by
  13   * clicking the link again. The code is smart enough that if the mouse
  14   * moves away and then back within the .5 second window, it will not
  15   * re-close.
  16   *
  17   * Multiple dropdowns can be placed per page.
  18   *
  19   * If the user does not have javascript enabled, the link will not appear,
  20   * and instead by default the list of links will appear as a normal inline
  21   * list.
  22   *
  23   * The menu is heavily styled by default, and to make it look different
  24   * will require a little bit of CSS. You can apply your own class to the
  25   * dropdown to help ensure that your CSS can override the dropdown's CSS.
  26   *
  27   * In particular, the text, link, background and border colors may need to
  28   * be changed. Please see dropdown.css for information about the existing
  29   * styling.
  30   */
  31  
  32  /**
  33   * Delegated implementation of hook_theme()
  34   */
  35  function ctools_dropdown_theme(&$items) {
  36    $items['ctools_dropdown'] = array(
  37      'arguments' => array('title' => NULL, 'links' => NULL, 'image' => FALSE, 'class' => ''),
  38      'file' => 'includes/dropdown.theme.inc',
  39    );
  40  }
  41  
  42  /**
  43   * Create a dropdown menu.
  44   *
  45   * @param $title
  46   *   The text to place in the clickable area to activate the dropdown.
  47   * @param $links
  48   *   A list of links to provide within the dropdown, suitable for use
  49   *   in via Drupal's theme('links').
  50   * @param $image
  51   *   If true, the dropdown link is an image and will not get extra decorations
  52   *   that a text dropdown link will.
  53   * @param $class
  54   *   An optional class to add to the dropdown's container div to allow you
  55   *   to style a single dropdown however you like without interfering with
  56   *   other dropdowns.
  57   */
  58  function theme_ctools_dropdown($title, $links, $image = FALSE, $class = '') {
  59    // Provide a unique identifier for every dropdown on the page.
  60    static $id = 0;
  61    $id++;
  62  
  63    $class = 'ctools-dropdown-no-js ctools-dropdown' . ($class ? (' ' . $class) : '');
  64  
  65    ctools_add_js('dropdown');
  66    ctools_add_css('dropdown');
  67  
  68    $output = '';
  69  
  70    $output .= '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">';
  71    $output .= '<div class="ctools-dropdown-link-wrapper">';
  72    if ($image) {
  73      $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-image-link">' . $title . '</a>';
  74    }
  75    else {
  76      $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-text-link">' . check_plain($title) . '</a>';
  77    }
  78  
  79    $output .= '</div>'; // wrapper
  80    $output .= '<div class="ctools-dropdown-container-wrapper">';
  81    $output .= '<div class="ctools-dropdown-container">';
  82    $output .= theme_links($links);
  83    $output .= '</div>'; // container
  84    $output .= '</div>'; // container wrapper
  85    $output .= '</div>'; // dropdown
  86    return $output;
  87  }
  88  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7