From 44264836be924a5cfa768e5d3a4bb95c19af6058 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Mon, 18 Sep 2006 21:54:19 +0000 Subject: [PATCH] new menu bar built with jquery --- README.txt | 26 ++++++++ bullet_go.gif | Bin 0 -> 303 bytes folder.gif | Bin 0 -> 570 bytes simplemenu.css | 72 ++++++++++++++++++++++ simplemenu.info | 4 ++ simplemenu.js | 17 ++++++ simplemenu.module | 149 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 268 insertions(+) create mode 100644 README.txt create mode 100644 bullet_go.gif create mode 100644 folder.gif create mode 100644 simplemenu.css create mode 100644 simplemenu.info create mode 100644 simplemenu.js create mode 100644 simplemenu.module diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..b0d237b2 --- /dev/null +++ b/README.txt @@ -0,0 +1,26 @@ +# $Id$ + + +--- README ------------------------------------------------------------- + +Menu Bar, Version 2.0 + +Written by Ted Serbinski, aka, m3avrck + hello@tedserbinski.com + http://tedserbinski.com + +Requirements: Drupal 5.0 + +Icons from: http://www.famfamfam.com/ + + + +--- INSTALLATION -------------------------------------------------------- + +1. Place menu_bar folder in your modules directory + +2. Enable "menu bar" under administer > site configuration > modules + +3. Enable access to "view menu bar" under administer > user management > access control + +4. Configure menu to use under administer > site configuration > menu bar \ No newline at end of file diff --git a/bullet_go.gif b/bullet_go.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d8d6602c14b738463aad1aa2fd3247877bde52d GIT binary patch literal 303 zcmZ?wbhEHb6krfwxXQpFTgBY4DRRx($x*X3t~@(G^+3IAzeM69SK|(e;#GcgkF*=L zbGK~GOkZdcI88BnzV*X*_p+BdEjiKCzq?qyf!VrCpng+A(mVsR4(U6uZg@_Ru3i_C zyVzp+>HY;rJ9~HL#Vv4}cCfK!YwFFHS5ud`8}>+=wR46|S1(v*r`gE$|Nnmm%7Efe z7DjdkEe0KsF(5xNu=zMlE%4Bh>OZlhDAFZ%#v!){Q(OwAru(WVI+(FMICsR^NLIh; vynD*V7CDi}3zR=rNGJ+5C6r|Fi1M?tb0~XrD@aKCXfg-{Oql57$Y2cs)C67y literal 0 HcmV?d00001 diff --git a/folder.gif b/folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..6aaca8b617a71b01b3068778af141b3432c51034 GIT binary patch literal 570 zcmZ?wbhEHb6krfwc*ekRv)lOF%abp6wthIR`fOv_w}-25FSGjh=fk%L)sGJ+J=h=m z=ktY+mkK{!sr!7{`Rjvu&(GJ~>a+NABl_R3_h0W#{{Q#KtJB%S-(Q*h{c+3x|Nnn~I`i#L_U$>=x3^e-xgPxU#q4`W zli!^${di9Q{e{Y}w^M#RoAUepj&Ju0|9m>}`9|;OD;~F}S$({a{pZ__A5VJkthK+h z+2O&S@b3>BzF%wka(DU9my6$@(|mcL=*5NR@6Yz$o8tBB?WT9<+8KrpQ2fcl$j+e5 zpaXI;C{7sIr#C1!HMg|3wRd#3aB=qbatX6fn$)b`DkVQtUcgDR$x75hgr9ZdWOh;O zCQD%v5neGd2?^b;QdUjUQi^VljLWA;H?b*;9uqa!S2ENSGC!isCTe7$plQLODx|^3 zeL;=g)&A5O4HH=%6}2W)VS5Xkr_XhmRZN>)WbEujjE#ADC2njmJkq>?o5hA9;>3hR N7RD|mFCG>KYXDW8&8GkW literal 0 HcmV?d00001 diff --git a/simplemenu.css b/simplemenu.css new file mode 100644 index 00000000..40437b30 --- /dev/null +++ b/simplemenu.css @@ -0,0 +1,72 @@ +/* $Id$ */ + +ul#menubar,ul#menubar ul,ul#menubar li,ul#menubar a { +color:#333; +display:block; +list-style:none; +margin:0; +padding:0; +z-index:48; +} + +ul#menubar { +background:#eee; +border-bottom:1px solid #a3a3a3; +font:10px Arial, Helvetica, sans-serif; +left:0; +position:fixed; +top:0; +width:100%; +} + +ul#menubar li { +float:left; +} + +ul#menubar li a { +background:#ccc; +border-right:1px solid #a3a3a3; +font-weight:400; +padding:0.3em 0.6em; +text-decoration:none; +} + +ul#menubar li:hover > a { +background:orange; +} + +ul#menubar ul li a { +border:none; +width:11em; +} + +ul#menubar li.leaf { +background:#eee url(bullet_go.gif) no-repeat 0.2em; +padding-left:2em; +} + +ul#menubar li.expanded { +background:#eee url(folder.gif) no-repeat 0.2em; +padding-left:2em; +} + +ul#menubar li ul { +background:#ccc; +border:1px solid #a3a3a3; +left:9999px; +position:absolute; +width:15em; +z-index:24; +} + +ul#menubar li ul ul { +margin:0 0 0 3em; +} + +ul#menubar li:hover ul ul,ul#menubar li:hover ul ul ul,ul#menubar li.sfhover ul ul,ul#menubar li.sfhover ul ul ul { +left:9999px; +} + +ul#menubar li:hover ul,ul#menubar li li:hover ul,ul#menubar li li li:hover ul,ul#menubar li.sfhover ul,ul#menubar li li.sfhover ul,ul#menubar li li li.sfhover ul { +left:auto; +} \ No newline at end of file diff --git a/simplemenu.info b/simplemenu.info new file mode 100644 index 00000000..c7fdacf1 --- /dev/null +++ b/simplemenu.info @@ -0,0 +1,4 @@ +; $Id$ +name = Menu bar +description = Creates a menu bar that is displayed at the top of every page. + diff --git a/simplemenu.js b/simplemenu.js new file mode 100644 index 00000000..90c69430 --- /dev/null +++ b/simplemenu.js @@ -0,0 +1,17 @@ +// $Id$ + +$(document).ready(function() { + // get the Drupal basepath + var basePath = Drupal.settings.menu_bar.basePath; + + // insert extra
so menu doesn't overlap theme + $('body').prepend('
'); + + // Drupal menu callback + $('#menubar').load(basePath + 'menu_bar/menu', function() { + $('li', this).hover(function() { + $('ul', this).slideDown(200); + }, function() { } + ); + }); +}); \ No newline at end of file diff --git a/simplemenu.module b/simplemenu.module new file mode 100644 index 00000000..6b83d600 --- /dev/null +++ b/simplemenu.module @@ -0,0 +1,149 @@ + 'menu_bar/menu', + 'access' => user_access('view menu bar'), + 'callback' => 'menu_bar_get_menu', + 'type' => MENU_CALLBACK + ); + + $items[] = array( + 'path' => 'admin/settings/menu_bar', + 'title' => t('menu bar'), + 'description' => t('Set which menus should appear in the menu bar.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('menu_bar_admin_settings'), + 'access' => user_access('administer menu bar') + ); + } + + elseif (user_access('view menu bar')) { + $path = drupal_get_path('module', 'menu_bar'); + // Add the CSS for this module + // We put this in !$may_cache so it's only added once per request + drupal_add_css($path .'/menu_bar.css'); + + // pass in base path to the JS file + drupal_add_js(array('menu_bar' => array('basePath' => base_path())), 'setting'); + drupal_add_js($path .'/menu_bar.js'); + } + + return $items; +} + +/** + * Implementation of hook_perm(). + */ +function menu_bar_perm() { + return array('view menu bar', 'administer menu bar'); +} + +/** + * Menu bar settings page + */ +function menu_bar_admin_settings() { + $form['default_menu']['menu_bar_menu'] = array( + '#type' => 'select', + '#title' => t('Menu'), + '#options' => menu_get_root_menus(), + '#default_value' => variable_get('menu_bar_menu', 1), + '#description' => t('Select the menu to display in the menu bar.') + ); + + $form['default_menu']['menu_bar_devel'] = array( + '#type' => 'checkbox', + '#title' => t('Add devel module links'), + '#default_value' => variable_get('menu_bar_devel', 0), + '#description' => t('Add devel module links for those users that can access the devel module.') + ); + + return system_settings_form($form); +} + +/** + * Return a list of devel module links if the module is enabled + * and the user has access to this module + */ +function menu_bar_get_devel() { + $output = ''; + + if (variable_get('menu_bar_devel', 0) && module_exists('devel')) { + if (user_access('access devel information')) { + $links[] = l('module settings', 'admin/settings/devel'); + $links[] = l('empty cache', 'devel/cache/clear'); + $links[] = l('phpinfo()', 'devel/phpinfo'); + $links[] = l('reinstall modules', 'devel/reinstall'); + $links[] = l('reset menus', 'devel/menu/reset'); + $links[] = l('variable viewer', 'devel/variable'); + $links[] = l('session viewer', 'devel/session'); + + if (function_exists('devel_node_access_perm') && user_access(DNA_ACCESS_VIEW)) { + // True only if devel_node_access enabled. + $links[] = l('node_access summary', 'devel/node_access/summary'); + } + + $output = '
  • '. t('devel module') .'
      '; + $output .= '
    • '. implode($links, '
    • ') .'
    • '; + $output .= '
  • '; + } + } + + return $output; +} + +/** + * Custom implementation of menu_tree() + * We want to retrieve the entire menu structure for a given menu, + * regardless of whether or not the menu item is expanded or not. + */ +function menu_bar_menu_tree($pid = 1) { + $menu = menu_get_menu(); + $output = ''; + + if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) { + foreach ($menu['visible'][$pid]['children'] as $mid) { + $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL; + $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL; + $output .= theme('menu_item', $mid, menu_bar_theme_menu_tree($mid), count($children) == 0); + } + } + + return $output; +} + +/** + * Custom implementation of theme_menu_tree() to call our custom menu above + */ +function menu_bar_theme_menu_tree($pid = 1) { + if ($tree = menu_bar_menu_tree($pid)) { + return ''; + } +} + +/** + * AJAX menu callback to return an HTML list of links for a given menu + */ +function menu_bar_get_menu() { + $menu = menu_bar_menu_tree(variable_get('menu_bar_menu', 1)); + + if (!$menu) { + $menu = '
  • '. t('No menu items found. Try a different menu as the default.') .'
  • '; + } + + print menu_bar_get_devel(); + print $menu; + exit; +} \ No newline at end of file