5 * Provide a javascript based dropdown menu.
7 * An example are the dropdown settings in the panels ui, like for adding
10 * The dropdown menu will show up as a clickable link; when clicked,
11 * a small menu will slide down beneath it, showing the list of links.
13 * The dropdown will stay open until either the user has moved the mouse
14 * away from the box for > .5 seconds, or can be immediately closed by
15 * clicking the link again. The code is smart enough that if the mouse
16 * moves away and then back within the .5 second window, it will not
19 * Multiple dropdowns can be placed per page.
21 * If the user does not have javascript enabled, the link will not appear,
22 * and instead by default the list of links will appear as a normal inline
25 * The menu is heavily styled by default, and to make it look different
26 * will require a little bit of CSS. You can apply your own class to the
27 * dropdown to help ensure that your CSS can override the dropdown's CSS.
29 * In particular, the text, link, background and border colors may need to
30 * be changed. Please see dropdown.css for information about the existing
35 * Delegated implementation of hook_theme()
37 function ctools_dropdown_theme(&$items) {
38 $items['ctools_dropdown'] = array(
39 'variables' => array('title' => NULL, 'links' => NULL, 'image' => FALSE, 'class' => ''),
40 'file' => 'includes/dropdown.theme.inc',
45 * Create a dropdown menu.
48 * The text to place in the clickable area to activate the dropdown.
50 * A list of links to provide within the dropdown, suitable for use
51 * in via Drupal's theme('links').
53 * If true, the dropdown link is an image and will not get extra decorations
54 * that a text dropdown link will.
56 * An optional class to add to the dropdown's container div to allow you
57 * to style a single dropdown however you like without interfering with
60 function theme_ctools_dropdown($vars) {
61 // Provide a unique identifier for every dropdown on the page.
65 $class = 'ctools-dropdown-no-js ctools-dropdown' . ($vars['class'] ? (' ' . $vars['class']) : '');
67 ctools_add_js('dropdown');
68 ctools_add_css('dropdown');
72 $output .= '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">';
73 $output .= '<div class="ctools-dropdown-link-wrapper">';
75 $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-image-link">' . $vars['title'] . '</a>';
78 $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-text-link">' . check_plain($vars['title']) . '</a>';
81 $output .= '</div>'; // wrapper
82 $output .= '<div class="ctools-dropdown-container-wrapper">';
83 $output .= '<div class="ctools-dropdown-container">';
84 $output .= theme_links(array('links' => $vars['links'], 'attributes' => array(), 'heading' => ''));
85 $output .= '</div>'; // container
86 $output .= '</div>'; // container wrapper
87 $output .= '</div>'; // dropdown