commit 44264836be924a5cfa768e5d3a4bb95c19af6058 Author: Ted Serbinski Date: Mon Sep 18 21:54:19 2006 +0000 new menu bar built with jquery 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 00000000..0d8d6602 Binary files /dev/null and b/bullet_go.gif differ diff --git a/folder.gif b/folder.gif new file mode 100644 index 00000000..6aaca8b6 Binary files /dev/null and b/folder.gif differ 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') .'
  • '; + } + } + + 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