annotate sites/all/modules/ctools/includes/dropdown.theme.inc @ 11:b0ee71395280

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