From 44264836be924a5cfa768e5d3a4bb95c19af6058 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Mon, 18 Sep 2006 21:54:19 +0000 Subject: [PATCH 001/101] 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 From 911791b362986dd7bca2c8635f8e00b7176f952b Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 18 Nov 2006 01:22:58 +0000 Subject: [PATCH 002/101] fix menu paths when mod_rewrite is not available --- simplemenu.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simplemenu.module b/simplemenu.module index 6b83d600..6c5c0b2d 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -30,14 +30,14 @@ function menu_bar_menu($may_cache) { ); } + // We put this in !$may_cache so it's only added once per request 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'); + // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off + drupal_add_js(array('menu_bar' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting'); drupal_add_js($path .'/menu_bar.js'); } From 24bb9a57bbe0bb29165721abdce383634058acc1 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 18 Nov 2006 01:26:44 +0000 Subject: [PATCH 003/101] fix menu capitalization to be consistent with core --- simplemenu.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.module b/simplemenu.module index 6c5c0b2d..aaf9d9a2 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -22,7 +22,7 @@ function menu_bar_menu($may_cache) { $items[] = array( 'path' => 'admin/settings/menu_bar', - 'title' => t('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'), From 44e1fc9296a1b8907986fe4dc63a8a77cb0b7815 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 18 Nov 2006 01:27:40 +0000 Subject: [PATCH 004/101] fix default menu size to be a bit larger --- simplemenu.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.css b/simplemenu.css index 40437b30..b2c0b420 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -12,7 +12,7 @@ z-index:48; ul#menubar { background:#eee; border-bottom:1px solid #a3a3a3; -font:10px Arial, Helvetica, sans-serif; +font:12px Arial, Helvetica, sans-serif; left:0; position:fixed; top:0; From 5ca8a4fc6c42e095b39d25d07c8362005225e4aa Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 10 Jan 2007 05:36:57 +0000 Subject: [PATCH 005/101] #102423 fix anchor title from interfering with links, patch by quicksketch --- simplemenu.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/simplemenu.js b/simplemenu.js index 90c69430..54424f0c 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -9,9 +9,9 @@ $(document).ready(function() { // Drupal menu callback $('#menubar').load(basePath + 'menu_bar/menu', function() { - $('li', this).hover(function() { - $('ul', this).slideDown(200); - }, function() { } - ); + $('li', this).hover(function() { + $('ul', this).slideDown(200); + }, function() {}); + $('a', this).title(''); }); }); \ No newline at end of file From 12519279521fbf23d53e05cc8152f5efb1568a6b Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 10 Jan 2007 05:40:31 +0000 Subject: [PATCH 006/101] #108098 fix cursor being hidden in firefox, patch by quicksketch. note, the menu no longer stays on top as you scroll, however forms are usable once again. this feature will return in version 3 when it's rewritten to be 100% jQuery. --- simplemenu.css | 2 +- simplemenu.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/simplemenu.css b/simplemenu.css index b2c0b420..d18e9d23 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -14,7 +14,7 @@ background:#eee; border-bottom:1px solid #a3a3a3; font:12px Arial, Helvetica, sans-serif; left:0; -position:fixed; +position:static; top:0; width:100%; } diff --git a/simplemenu.js b/simplemenu.js index 54424f0c..d4f3cfa3 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -5,7 +5,7 @@ $(document).ready(function() { var basePath = Drupal.settings.menu_bar.basePath; // insert extra
    so menu doesn't overlap theme - $('body').prepend('
    '); + $('body').prepend(''); // Drupal menu callback $('#menubar').load(basePath + 'menu_bar/menu', function() { From 0c661bcbd4605df6e8fd61a6229f0a490c098c4d Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 10 Jan 2007 05:42:41 +0000 Subject: [PATCH 007/101] #103381 use negative margins for menus, gets rid of horizontal scrollbar, patch by quicksketch --- simplemenu.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simplemenu.css b/simplemenu.css index d18e9d23..20ece7bb 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -53,7 +53,7 @@ padding-left:2em; ul#menubar li ul { background:#ccc; border:1px solid #a3a3a3; -left:9999px; +left:-9999px; position:absolute; width:15em; z-index:24; @@ -64,7 +64,7 @@ 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; +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 { From 1ed6151591dad43d55f839e87175c2808f99647b Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 10 Jan 2007 06:13:00 +0000 Subject: [PATCH 008/101] smooth initial loading of menu, thanks to craq for the tip --- simplemenu.css | 1 + simplemenu.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/simplemenu.css b/simplemenu.css index 20ece7bb..08e3d0e3 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -17,6 +17,7 @@ left:0; position:static; top:0; width:100%; +height:22px; } ul#menubar li { diff --git a/simplemenu.js b/simplemenu.js index d4f3cfa3..90c48ae8 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -5,7 +5,7 @@ $(document).ready(function() { var basePath = Drupal.settings.menu_bar.basePath; // insert extra
    so menu doesn't overlap theme - $('body').prepend(''); + $('').prependTo('body').slideDown(400); // Drupal menu callback $('#menubar').load(basePath + 'menu_bar/menu', function() { From 60cc6ae1a3047e094511bcec457fef894585cdc5 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 11 Jan 2007 03:25:24 +0000 Subject: [PATCH 009/101] renaming menu bar module to SimpleMenu module --- README.txt | 10 +++---- simplemenu.css | 24 +++++++-------- simplemenu.info | 2 +- simplemenu.js | 6 ++-- simplemenu.module | 76 +++++++++++++++++++++++------------------------ 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/README.txt b/README.txt index b0d237b2..03e57d5d 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ --- README ------------------------------------------------------------- -Menu Bar, Version 2.0 +SimpleMenu, Version 2.0 Written by Ted Serbinski, aka, m3avrck hello@tedserbinski.com @@ -17,10 +17,10 @@ Icons from: http://www.famfamfam.com/ --- INSTALLATION -------------------------------------------------------- -1. Place menu_bar folder in your modules directory +1. Place simplemenu folder in your modules directory -2. Enable "menu bar" under administer > site configuration > modules +2. Enable "SimpleMenu" under administer > site configuration > modules -3. Enable access to "view menu bar" under administer > user management > access control +3. Enable access to "view simplemenu" under administer > user management > access control -4. Configure menu to use under administer > site configuration > menu bar \ No newline at end of file +4. Configure menu to use under administer > site configuration > simplemenu \ No newline at end of file diff --git a/simplemenu.css b/simplemenu.css index 08e3d0e3..6c9bcb78 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -1,6 +1,6 @@ /* $Id$ */ -ul#menubar,ul#menubar ul,ul#menubar li,ul#menubar a { +ul#simplemenu,ul#simplemenu ul,ul#simplemenu li,ul#simplemenu a { color:#333; display:block; list-style:none; @@ -9,7 +9,7 @@ padding:0; z-index:48; } -ul#menubar { +ul#simplemenu { background:#eee; border-bottom:1px solid #a3a3a3; font:12px Arial, Helvetica, sans-serif; @@ -20,11 +20,11 @@ width:100%; height:22px; } -ul#menubar li { +ul#simplemenu li { float:left; } -ul#menubar li a { +ul#simplemenu li a { background:#ccc; border-right:1px solid #a3a3a3; font-weight:400; @@ -32,26 +32,26 @@ padding:0.3em 0.6em; text-decoration:none; } -ul#menubar li:hover > a { +ul#simplemenu li:hover > a { background:orange; } -ul#menubar ul li a { +ul#simplemenu ul li a { border:none; width:11em; } -ul#menubar li.leaf { +ul#simplemenu li.leaf { background:#eee url(bullet_go.gif) no-repeat 0.2em; padding-left:2em; } -ul#menubar li.expanded { +ul#simplemenu li.expanded { background:#eee url(folder.gif) no-repeat 0.2em; padding-left:2em; } -ul#menubar li ul { +ul#simplemenu li ul { background:#ccc; border:1px solid #a3a3a3; left:-9999px; @@ -60,14 +60,14 @@ width:15em; z-index:24; } -ul#menubar li ul ul { +ul#simplemenu 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 { +ul#simplemenu li:hover ul ul,ul#simplemenu li:hover ul ul ul,ul#simplemenu li.sfhover ul ul,ul#simplemenu 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 { +ul#simplemenu li:hover ul,ul#simplemenu li li:hover ul,ul#simplemenu li li li:hover ul,ul#simplemenu li.sfhover ul,ul#simplemenu li li.sfhover ul,ul#simplemenu li li li.sfhover ul { left:auto; } \ No newline at end of file diff --git a/simplemenu.info b/simplemenu.info index c7fdacf1..afff517e 100644 --- a/simplemenu.info +++ b/simplemenu.info @@ -1,4 +1,4 @@ ; $Id$ -name = Menu bar +name = SimpleMenu description = Creates a menu bar that is displayed at the top of every page. diff --git a/simplemenu.js b/simplemenu.js index 90c48ae8..6d9bdb14 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -2,13 +2,13 @@ $(document).ready(function() { // get the Drupal basepath - var basePath = Drupal.settings.menu_bar.basePath; + var basePath = Drupal.settings.simplemenu.basePath; // insert extra
    so menu doesn't overlap theme - $('').prependTo('body').slideDown(400); + $('
      ').prependTo('body').slideDown(400); // Drupal menu callback - $('#menubar').load(basePath + 'menu_bar/menu', function() { + $('#simplemenu').load(basePath + 'simplemenu/menu', function() { $('li', this).hover(function() { $('ul', this).slideDown(200); }, function() {}); diff --git a/simplemenu.module b/simplemenu.module index aaf9d9a2..75e9941a 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -3,42 +3,42 @@ /** * @file - * Creates a menu bar. + * Creates a simplemenu. */ /** * Implementation of hook_menu(). */ -function menu_bar_menu($may_cache) { +function simplemenu_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( - 'path' => 'menu_bar/menu', - 'access' => user_access('view menu bar'), - 'callback' => 'menu_bar_get_menu', + 'path' => 'simplemenu/menu', + 'access' => user_access('view simplemenu'), + 'callback' => 'simplemenu_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.'), + 'path' => 'admin/settings/simplemenu', + 'title' => t('SimpleMenu'), + 'description' => t('Select the menu to display.'), 'callback' => 'drupal_get_form', - 'callback arguments' => array('menu_bar_admin_settings'), - 'access' => user_access('administer menu bar') + 'callback arguments' => array('simplemenu_admin_settings'), + 'access' => user_access('administer simplemenu') ); } // We put this in !$may_cache so it's only added once per request - elseif (user_access('view menu bar')) { - $path = drupal_get_path('module', 'menu_bar'); - drupal_add_css($path .'/menu_bar.css'); + elseif (user_access('view simplemenu')) { + $path = drupal_get_path('module', 'simplemenu'); + drupal_add_css($path .'/simplemenu.css'); // pass in base path to the JS file // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off - drupal_add_js(array('menu_bar' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting'); - drupal_add_js($path .'/menu_bar.js'); + drupal_add_js(array('simplemenu' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting'); + drupal_add_js($path .'/simplemenu.js'); } return $items; @@ -47,26 +47,26 @@ function menu_bar_menu($may_cache) { /** * Implementation of hook_perm(). */ -function menu_bar_perm() { - return array('view menu bar', 'administer menu bar'); +function simplemenu_perm() { + return array('view simplemenu', 'administer simplemenu'); } /** - * Menu bar settings page + * SimpleMenu settings page. */ -function menu_bar_admin_settings() { - $form['default_menu']['menu_bar_menu'] = array( +function simplemenu_admin_settings() { + $form['default_menu']['simplemenu_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.') + '#default_value' => variable_get('simplemenu_menu', 1), + '#description' => t('Select the menu to display.') ); - $form['default_menu']['menu_bar_devel'] = array( + $form['default_menu']['simplemenu_devel'] = array( '#type' => 'checkbox', '#title' => t('Add devel module links'), - '#default_value' => variable_get('menu_bar_devel', 0), + '#default_value' => variable_get('simplemenu_devel', 0), '#description' => t('Add devel module links for those users that can access the devel module.') ); @@ -75,12 +75,12 @@ function menu_bar_admin_settings() { /** * Return a list of devel module links if the module is enabled - * and the user has access to this module + * and the user has access to this module. */ -function menu_bar_get_devel() { +function simplemenu_get_devel() { $output = ''; - if (variable_get('menu_bar_devel', 0) && module_exists('devel')) { + if (variable_get('simplemenu_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'); @@ -105,11 +105,11 @@ function menu_bar_get_devel() { } /** - * Custom implementation of menu_tree() + * 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) { +function simplemenu_menu_tree($pid = 1) { $menu = menu_get_menu(); $output = ''; @@ -117,7 +117,7 @@ function menu_bar_menu_tree($pid = 1) { 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); + $output .= theme('menu_item', $mid, simplemenu_theme_menu_tree($mid), count($children) == 0); } } @@ -125,25 +125,25 @@ function menu_bar_menu_tree($pid = 1) { } /** - * Custom implementation of theme_menu_tree() to call our custom menu above + * 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)) { +function simplemenu_theme_menu_tree($pid = 1) { + if ($tree = simplemenu_menu_tree($pid)) { return '
        '. $tree .'
      '; } } /** - * AJAX menu callback to return an HTML list of links for a given menu + * 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)); +function simplemenu_get_menu() { + $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1)); if (!$menu) { - $menu = '
    • '. t('No menu items found. Try a different menu as the default.') .'
    • '; + $menu = '
    • '. t('No menu items found. Try a different menu as the default.') .'
    • '; } - print menu_bar_get_devel(); + print simplemenu_get_devel(); print $menu; exit; } \ No newline at end of file From 50807fe40fc275719840ffb29399bd3a704fee11 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 11 Jan 2007 04:03:09 +0000 Subject: [PATCH 010/101] add version info --- simplemenu.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.info b/simplemenu.info index afff517e..86e2061b 100644 --- a/simplemenu.info +++ b/simplemenu.info @@ -1,4 +1,4 @@ ; $Id$ name = SimpleMenu description = Creates a menu bar that is displayed at the top of every page. - +version = 2.0 \ No newline at end of file From cca7f982e47bb1f42cee6f7659555a977f0eb66c Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 11 Jan 2007 04:14:29 +0000 Subject: [PATCH 011/101] capitalization fix --- simplemenu.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.module b/simplemenu.module index 75e9941a..dadb19ab 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -95,7 +95,7 @@ function simplemenu_get_devel() { $links[] = l('node_access summary', 'devel/node_access/summary'); } - $output = '
    • '. t('devel module') .'
        '; + $output = '
      • '. t('Devel module') .'
          '; $output .= '
        • '. implode($links, '
        • ') .'
        • '; $output .= '
      • '; } From cb22790246c944a164b81cd7faa7a81232376fbc Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 16 Jan 2007 06:47:15 +0000 Subject: [PATCH 012/101] #108971, use any menu not just root menus, patch by ewhipple --- simplemenu.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.module b/simplemenu.module index dadb19ab..49c874b6 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -58,7 +58,7 @@ function simplemenu_admin_settings() { $form['default_menu']['simplemenu_menu'] = array( '#type' => 'select', '#title' => t('Menu'), - '#options' => menu_get_root_menus(), + '#options' => menu_parent_options(0), '#default_value' => variable_get('simplemenu_menu', 1), '#description' => t('Select the menu to display.') ); From 6f6aef2e670340a74c41169448e7145679aaf699 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 04:45:40 +0000 Subject: [PATCH 013/101] updated theme for menu, better usability, #113203 --- simplemenu.css | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/simplemenu.css b/simplemenu.css index 6c9bcb78..bf1da47d 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -10,58 +10,53 @@ z-index:48; } ul#simplemenu { -background:#eee; -border-bottom:1px solid #a3a3a3; -font:12px Arial, Helvetica, sans-serif; +background:#ddd; +border-bottom:1px solid #999; +font:11px Verdana, Helvetica, sans-serif; left:0; position:static; top:0; width:100%; -height:22px; +height:21px; } ul#simplemenu li { float:left; +border-right:1px solid #999; +border-left:1px solid #eee; } ul#simplemenu li a { -background:#ccc; -border-right:1px solid #a3a3a3; -font-weight:400; -padding:0.3em 0.6em; +background:#ddd; +padding:0.3em 2em 0.3em 0.6em; text-decoration:none; } -ul#simplemenu li:hover > a { -background:orange; -} - ul#simplemenu ul li a { border:none; width:11em; } -ul#simplemenu li.leaf { -background:#eee url(bullet_go.gif) no-repeat 0.2em; -padding-left:2em; +ul#simplemenu li.expanded > a { +background:#ddd url(bullet_go.gif) no-repeat 97%; } -ul#simplemenu li.expanded { -background:#eee url(folder.gif) no-repeat 0.2em; -padding-left:2em; +ul#simplemenu li:hover > a { +background-color:#2662F1; +color:#fff; } ul#simplemenu li ul { -background:#ccc; -border:1px solid #a3a3a3; +background:#999; +border:1px solid #999; left:-9999px; position:absolute; -width:15em; +width:14em; z-index:24; -} +} ul#simplemenu li ul ul { -margin:0 0 0 3em; +margin:0 0 0 6em; } ul#simplemenu li:hover ul ul,ul#simplemenu li:hover ul ul ul,ul#simplemenu li.sfhover ul ul,ul#simplemenu li.sfhover ul ul ul { From 7bbcc73ae87dbb71287a47c099df13fb3a933b4b Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 04:46:49 +0000 Subject: [PATCH 014/101] removing unused icon --- folder.gif | Bin 570 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 folder.gif diff --git a/folder.gif b/folder.gif deleted file mode 100644 index 6aaca8b617a71b01b3068778af141b3432c51034..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 From 831fbf4e0f424a831b7e5a599328d80a626f3f97 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 04:53:45 +0000 Subject: [PATCH 015/101] fix page scroll down, #108655 --- simplemenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simplemenu.js b/simplemenu.js index 6d9bdb14..3f30ba8d 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -3,9 +3,9 @@ $(document).ready(function() { // get the Drupal basepath var basePath = Drupal.settings.simplemenu.basePath; - + // insert extra
        so menu doesn't overlap theme - $('
          ').prependTo('body').slideDown(400); + $('
            ').prependTo('body'); // Drupal menu callback $('#simplemenu').load(basePath + 'simplemenu/menu', function() { From a5022b38fccfbf5c4d88d505d336340f504e2143 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 04:57:20 +0000 Subject: [PATCH 016/101] bring back fixed position menu, but fix it from overlapping the theme --- simplemenu.css | 2 +- simplemenu.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/simplemenu.css b/simplemenu.css index bf1da47d..9bbe8228 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -14,7 +14,7 @@ background:#ddd; border-bottom:1px solid #999; font:11px Verdana, Helvetica, sans-serif; left:0; -position:static; +position:fixed; top:0; width:100%; height:21px; diff --git a/simplemenu.js b/simplemenu.js index 3f30ba8d..fed20cf4 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -6,6 +6,7 @@ $(document).ready(function() { // insert extra
            so menu doesn't overlap theme $('
              ').prependTo('body'); + $('body').css('margin-top', '23px'); // Drupal menu callback $('#simplemenu').load(basePath + 'simplemenu/menu', function() { From 6085946d1dcba53604979f63b712ce3b1d369e5d Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 05:41:41 +0000 Subject: [PATCH 017/101] #114015, advanced menu settings to place menu anywhere on page, patch by Steve McKenzie, modified by me --- simplemenu.js | 19 ++++++++++++++++--- simplemenu.module | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/simplemenu.js b/simplemenu.js index fed20cf4..9b834807 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -3,9 +3,22 @@ $(document).ready(function() { // get the Drupal basepath var basePath = Drupal.settings.simplemenu.basePath; - - // insert extra
              so menu doesn't overlap theme - $('
                ').prependTo('body'); + // get the element to add the menu to + var element = Drupal.settings.simplemenu.element; + var menu = '
                  '; + + switch (Drupal.settings.simplemenu.placement) { + case 'prepend': + $(menu).prependTo(element); + break; + case 'append': + $(menu).appendTo(element); + break; + case 'replace': + $(element).html(menu); + break; + } + $('body').css('margin-top', '23px'); // Drupal menu callback diff --git a/simplemenu.module b/simplemenu.module index 49c874b6..a05671f8 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -33,11 +33,17 @@ function simplemenu_menu($may_cache) { // We put this in !$may_cache so it's only added once per request elseif (user_access('view simplemenu')) { $path = drupal_get_path('module', 'simplemenu'); - drupal_add_css($path .'/simplemenu.css'); - - // pass in base path to the JS file - // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off - drupal_add_js(array('simplemenu' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting'); + drupal_add_css($path .'/simplemenu.css'); + + $settings = array( + // pass in base path to the JS file + // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off + 'basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='), + 'placement' => variable_get('simplemenu_element_method', 'prepend'), + 'element' => variable_get('simplemenu_element', 'body') + ); + + drupal_add_js(array('simplemenu' => $settings), 'setting'); drupal_add_js($path .'/simplemenu.js'); } @@ -68,6 +74,30 @@ function simplemenu_admin_settings() { '#title' => t('Add devel module links'), '#default_value' => variable_get('simplemenu_devel', 0), '#description' => t('Add devel module links for those users that can access the devel module.') + ); + + $form['default_menu']['advanced'] = array( + '#type' => 'fieldset', + '#title' => t('Advanced settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE + ); + + $form['default_menu']['advanced']['simplemenu_element'] = array( + '#type' => 'textfield', + '#title' => t('CSS selector to attach menu to'), + '#default_value' => variable_get('simplemenu_element', 'body'), + '#description' => t('A valid CSS selector to attach the menu to. Example: body, #primary, div.my-class'), + '#required' => TRUE + ); + + $form['default_menu']['advanced']['simplemenu_element_method'] = array( + '#type' => 'radios', + '#title' => 'Attach method', + '#options' => drupal_map_assoc(array('prepend', 'append', 'replace')), + '#default_value' => variable_get('simplemenu_element_method', 'prepend'), + '#description' => t('Choose how the menu should be attached to the above selector.'), + '#required' => TRUE ); return system_settings_form($form); From ba3b8e51d12e9824a3a8e4e314410d8e63267cb9 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Tue, 30 Jan 2007 06:02:09 +0000 Subject: [PATCH 018/101] #114107, improved interface/colors, patch by quicksketch --- bullet_go.gif | Bin 303 -> 0 bytes down-green.gif | Bin 0 -> 179 bytes right-green.gif | Bin 0 -> 893 bytes simplemenu.css | 9 +++++++-- simplemenu.js | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 bullet_go.gif create mode 100644 down-green.gif create mode 100644 right-green.gif diff --git a/bullet_go.gif b/bullet_go.gif deleted file mode 100644 index 0d8d6602c14b738463aad1aa2fd3247877bde52d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/down-green.gif b/down-green.gif new file mode 100644 index 0000000000000000000000000000000000000000..215ecc33b5ee70fa925caf59e06d4d0eeff2bac4 GIT binary patch literal 179 zcmZ?wbhEHb6krfwI3mH&w8SZUx=!glhyCYQ%-L32KG&#ZuJN)xHI)l&j$T@oJV~p6 zb@0*4>(?LZ&z)hg{!s7Ct;OZ@oTqNeSbwN(`j&z%C#J97-?{nt)c^ngGhhRXKUo+V z7$g{UK$0Lk8CVSz)cR5~=Vh!~m$TZ6O^AgxVLn%=>9wgo3?VE=6$X6VQyUBvSi+e+ P4~iBFuB6plyu>5eRPme_GROMN_${SX=MNZax`u0KAZ2f85 zvpd)L@4mQb>zTPr54O~;Amp&T+E8x|aF<`CA3i4Zu-+QuZ!Vlh#GwVh4eti&UM zA(5F;!P@78!=WPwxtZ*01QHKAb+C)@@V!tt*v!tR=%HZo!lAj5i=Rv8#?Asp4jzGE OhK3VcG> a { -background:#ddd url(bullet_go.gif) no-repeat 97%; +background:#ddd url(right-green.gif) no-repeat 97%; +} + +ul#simplemenu li.root > a { +font-weight:bold; +background:#ddd url(down-green.gif) no-repeat 97%; } ul#simplemenu li:hover > a { -background-color:#2662F1; +background-color:#3875d7; color:#fff; } diff --git a/simplemenu.js b/simplemenu.js index 9b834807..1283075a 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -27,5 +27,6 @@ $(document).ready(function() { $('ul', this).slideDown(200); }, function() {}); $('a', this).title(''); + $(this).children('li.expanded').addClass('root'); }); }); \ No newline at end of file From 4687549e8935dacb44f9d0735387bd4903d7955e Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 28 Feb 2007 23:00:59 +0000 Subject: [PATCH 019/101] #114803, fix textareas not working, patch by quicksketch --- simplemenu.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplemenu.css b/simplemenu.css index 8d31c7f2..1f859279 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -14,7 +14,7 @@ background:#ddd; border-bottom:1px solid #999; font:11px Verdana, Helvetica, sans-serif; left:0; -position:fixed; +position:absolute; top:0; width:100%; height:21px; From 659a21255a955ed96e0f4cd1591e12010e542615 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 28 Feb 2007 23:02:53 +0000 Subject: [PATCH 020/101] #123486 fix typo in readme, thanks scor --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 03e57d5d..afd3cb7e 100644 --- a/README.txt +++ b/README.txt @@ -19,7 +19,7 @@ Icons from: http://www.famfamfam.com/ 1. Place simplemenu folder in your modules directory -2. Enable "SimpleMenu" under administer > site configuration > modules +2. Enable "SimpleMenu" under administer > site building > modules 3. Enable access to "view simplemenu" under administer > user management > access control From cd38617398a76e8e2fbefcbc94ffb3ee4d45f12a Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Wed, 28 Feb 2007 23:43:42 +0000 Subject: [PATCH 021/101] #116317, disable simplemenu on a per theme basis, patch by jjeff --- simplemenu.module | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/simplemenu.module b/simplemenu.module index a05671f8..503b17e4 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -29,9 +29,18 @@ function simplemenu_menu($may_cache) { 'access' => user_access('administer simplemenu') ); } - - // We put this in !$may_cache so it's only added once per request - elseif (user_access('view simplemenu')) { + + return $items; +} + +/** + * Implementation of hook_footer() + */ +function simplemenu_footer() { + global $theme; + $exclusions = variable_get('simplemenu_exclusions', array()); + if (user_access('view simplemenu') && !$exclusions[$theme]) { + global $theme, $custom_theme; $path = drupal_get_path('module', 'simplemenu'); drupal_add_css($path .'/simplemenu.css'); @@ -46,8 +55,6 @@ function simplemenu_menu($may_cache) { drupal_add_js(array('simplemenu' => $settings), 'setting'); drupal_add_js($path .'/simplemenu.js'); } - - return $items; } /** @@ -100,6 +107,14 @@ function simplemenu_admin_settings() { '#required' => TRUE ); + $form['default_menu']['advanced']['simplemenu_exclusions'] = array( + '#type' => 'checkboxes', + '#title' => 'Theme exclusions', + '#options' => drupal_map_assoc(array_keys(list_themes())), + '#default_value' => variable_get('simplemenu_exclusions', array()), + '#description' => t('Select which themes to not display the menu. Use this when you have a theme that displays its own admin navigation.'), + ); + return system_settings_form($form); } From eb09ab5342cbc7aef3b48f43924b80604b8cdfea Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 1 Mar 2007 00:08:04 +0000 Subject: [PATCH 022/101] add new RTL advanced setting for themes that need that --- left-green.gif | Bin 0 -> 895 bytes simplemenu.module | 13 ++++++++++++- simplemenu_rtl.css | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 left-green.gif create mode 100644 simplemenu_rtl.css diff --git a/left-green.gif b/left-green.gif new file mode 100644 index 0000000000000000000000000000000000000000..1929b376b9ebf04a080cca55ef141cb0190d0a38 GIT binary patch literal 895 zcmZ?wbhEHb6krfw_|CxK+$KJ2SHb?v%PN=H-Fta+&G9K|vveBP#Dq`Q?%$lc`Sk3t zNpkb{*0-$oE?i(%y)y9Sho>FuB6plyu>5eRPme_GROMN_${SX=MNZax`u0KAZ2f85 zvpd)L@4mQb>zTPr54O~+~Gp&T+E8x|aF<`CA3iTJ?8)u!dgl5yaILld90p2>p` z7Zz{|$*GkHI7~`% drupal_map_assoc(array_keys(list_themes())), '#default_value' => variable_get('simplemenu_exclusions', array()), '#description' => t('Select which themes to not display the menu. Use this when you have a theme that displays its own admin navigation.'), + ); + + $form['default_menu']['advanced']['simplemenu_rtl'] = array( + '#type' => 'checkbox', + '#title' => t('Set menu orientation to RTL'), + '#default_value' => variable_get('simplemenu_rtl', 0), + '#description' => t('Set the orientation of the menu to RTL for Eastern languages.') ); return system_settings_form($form); diff --git a/simplemenu_rtl.css b/simplemenu_rtl.css new file mode 100644 index 00000000..238001f3 --- /dev/null +++ b/simplemenu_rtl.css @@ -0,0 +1,20 @@ +/* $Id$ */ + +ul#simplemenu li { +float:right; +border-right:1px solid #eee; +border-left:1px solid #999; +} + +ul#simplemenu li.expanded > a { +background:#ddd url(left-green.gif) no-repeat 97%; +} + +ul#simplemenu li.root > a { +font-weight:bold; +background:#ddd url(down-green.gif) no-repeat 97%; +} + +ul#simplemenu li:hover ul,ul#simplemenu li li:hover ul,ul#simplemenu li li li:hover ul,ul#simplemenu li.sfhover ul,ul#simplemenu li li.sfhover ul,ul#simplemenu li li li.sfhover ul { +right:auto; +} \ No newline at end of file From 6b915cda88dbd43e201bb546c789dd9a6fcef89e Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Thu, 1 Mar 2007 00:11:38 +0000 Subject: [PATCH 023/101] bump the revision number --- README.txt | 2 +- simplemenu.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index afd3cb7e..947f89af 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ --- README ------------------------------------------------------------- -SimpleMenu, Version 2.0 +SimpleMenu, Version 2.1 Written by Ted Serbinski, aka, m3avrck hello@tedserbinski.com diff --git a/simplemenu.info b/simplemenu.info index 86e2061b..47b21d4d 100644 --- a/simplemenu.info +++ b/simplemenu.info @@ -1,4 +1,4 @@ ; $Id$ name = SimpleMenu description = Creates a menu bar that is displayed at the top of every page. -version = 2.0 \ No newline at end of file +version = 2.1 From ccd2494fb79d7441bb81d018839eba4a7cbee5f9 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 7 Apr 2007 03:30:15 +0000 Subject: [PATCH 024/101] #133010, fix devel links, patch by dericknwq --- simplemenu.module | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/simplemenu.module b/simplemenu.module index acf3b541..f2dfe5b9 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -138,19 +138,20 @@ function simplemenu_get_devel() { if (variable_get('simplemenu_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'); + $links[] = l('Devel settings', 'admin/settings/devel', array('title' => t('Adjust module settings for devel module'))); + $links[] = l('Empty cache', 'devel/cache/clear', array('title' => t('Clear the database cache tables which store page, menu, node, and variable caches.')), drupal_get_destination()); + $links[] = l('Phpinfo()', 'admin/logs/status/php'); + $links[] = l('Function reference', 'devel/reference', array('title' => t('View a list of currently defined user functions with documentation links'))); + $links[] = l('Reinstall modules', 'devel/reinstall', array('title' => t('Re-run hook_install() for a given module'))); + $links[] = l('Reset menus', 'devel/menu/reset', array('title' => t('Resets all menu items to their default settings'))); + $links[] = l('Variable editor', 'devel/variable', array('title' => t('Edit and delete site variables'))); + $links[] = l('Session viewer', 'devel/session', array('title' => t('List the contents of $_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'); + $links[] = l('Node access summary', 'devel/node_access/summary'); } - + $output = '
                • '. t('Devel module') .'
                    '; $output .= '
                  • '. implode($links, '
                  • ') .'
                  • '; $output .= '
                • '; From ec97ad2402b8b23b19d962b53451359e7047f0ee Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 7 Apr 2007 03:57:43 +0000 Subject: [PATCH 025/101] remove AJAX callback, pass menu structure to page directly, dramatically faster, 1 less HTTP request, clear your menu cache, can produce weirdness/infinit loops --- simplemenu.js | 15 ++++--- simplemenu.module | 101 ++++++++++++++++++++++------------------------ 2 files changed, 56 insertions(+), 60 deletions(-) diff --git a/simplemenu.js b/simplemenu.js index 1283075a..637e082a 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -21,12 +21,11 @@ $(document).ready(function() { $('body').css('margin-top', '23px'); - // Drupal menu callback - $('#simplemenu').load(basePath + 'simplemenu/menu', function() { - $('li', this).hover(function() { - $('ul', this).slideDown(200); - }, function() {}); - $('a', this).title(''); - $(this).children('li.expanded').addClass('root'); - }); + // Build menu + $('#simplemenu').append(simplemenu); + $('#simplemenu li').hover(function() { + $('ul', this).slideDown(200); + }, function() {}); + $('#simplemenu a').title(''); + $('#simplemenu').children('li.expanded').addClass('root'); }); \ No newline at end of file diff --git a/simplemenu.module b/simplemenu.module index f2dfe5b9..250ea05d 100644 --- a/simplemenu.module +++ b/simplemenu.module @@ -12,14 +12,7 @@ function simplemenu_menu($may_cache) { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'simplemenu/menu', - 'access' => user_access('view simplemenu'), - 'callback' => 'simplemenu_get_menu', - 'type' => MENU_CALLBACK - ); - + if ($may_cache) { $items[] = array( 'path' => 'admin/settings/simplemenu', 'title' => t('SimpleMenu'), @@ -57,6 +50,7 @@ function simplemenu_footer() { ); drupal_add_js(array('simplemenu' => $settings), 'setting'); + drupal_add_js('var simplemenu = '. drupal_to_js(simplemenu_get_menu() .';'), 'inline'); drupal_add_js($path .'/simplemenu.js'); } } @@ -129,6 +123,53 @@ function simplemenu_admin_settings() { return system_settings_form($form); } +/** + * Render an HTML list of links for a given menu. + */ +function simplemenu_get_menu() { + $output = ''; + + $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1)); + + if (!$menu) { + $menu = '
                • '. t('No menu items found. Try a different menu as the default.') .'
                • '; + } + + $output .= simplemenu_get_devel(); + $output .= $menu; + + 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 simplemenu_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, simplemenu_theme_menu_tree($mid), count($children) == 0); + } + } + + return $output; +} + +/** + * Custom implementation of theme_menu_tree() to call our custom menu above. + */ +function simplemenu_theme_menu_tree($pid = 1) { + if ($tree = simplemenu_menu_tree($pid)) { + return '
                    '. $tree .'
                  '; + } +} + /** * Return a list of devel module links if the module is enabled * and the user has access to this module. @@ -159,48 +200,4 @@ function simplemenu_get_devel() { } 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 simplemenu_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, simplemenu_theme_menu_tree($mid), count($children) == 0); - } - } - - return $output; -} - -/** - * Custom implementation of theme_menu_tree() to call our custom menu above. - */ -function simplemenu_theme_menu_tree($pid = 1) { - if ($tree = simplemenu_menu_tree($pid)) { - return '
                    '. $tree .'
                  '; - } -} - -/** - * AJAX menu callback to return an HTML list of links for a given menu. - */ -function simplemenu_get_menu() { - $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1)); - - if (!$menu) { - $menu = '
                • '. t('No menu items found. Try a different menu as the default.') .'
                • '; - } - - print simplemenu_get_devel(); - print $menu; - exit; } \ No newline at end of file From 4d03934230159cf2ec114dbd65923bcb6eec1ad4 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 7 Apr 2007 03:59:43 +0000 Subject: [PATCH 026/101] #132453, keep menus left justified even if the theme is centered, patch by dericknwq --- simplemenu.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simplemenu.css b/simplemenu.css index 1f859279..9942b2c3 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -23,7 +23,8 @@ height:21px; ul#simplemenu li { float:left; border-right:1px solid #999; -border-left:1px solid #eee; +border-left:1px solid #eee; +text-align: left; } ul#simplemenu li a { From 21563d09cef07f62847ea77d335afef577dc7912 Mon Sep 17 00:00:00 2001 From: Ted Serbinski Date: Sat, 7 Apr 2007 05:41:34 +0000 Subject: [PATCH 027/101] major rewrite of menu code, tons of bug and usability fixes, faster, and better cross browser integration, and RTL support --- README.txt | 3 +- simplemenu.css | 132 +++++++++++++++++++++++++++------------------ simplemenu.js | 128 +++++++++++++++++++++++++++++++++++++++---- simplemenu.module | 2 +- simplemenu_rtl.css | 38 ++++++++----- 5 files changed, 226 insertions(+), 77 deletions(-) diff --git a/README.txt b/README.txt index 947f89af..46c3db32 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ --- README ------------------------------------------------------------- -SimpleMenu, Version 2.1 +SimpleMenu, Version 3.0 Written by Ted Serbinski, aka, m3avrck hello@tedserbinski.com @@ -12,6 +12,7 @@ Written by Ted Serbinski, aka, m3avrck Requirements: Drupal 5.0 Icons from: http://www.famfamfam.com/ +jQuery Superfish: http://users.tpg.com.au/j_birch/plugins/superfish/ diff --git a/simplemenu.css b/simplemenu.css index 9942b2c3..46a168b6 100644 --- a/simplemenu.css +++ b/simplemenu.css @@ -1,74 +1,102 @@ /* $Id$ */ - -ul#simplemenu,ul#simplemenu ul,ul#simplemenu li,ul#simplemenu a { -color:#333; -display:block; -list-style:none; -margin:0; -padding:0; -z-index:48; +#simplemenu +{ + background:#ddd; + color:#333; + margin:0; + padding:0; + z-index:48; + border-bottom:1px solid #999; + font:11px Verdana, Helvetica, sans-serif; + left:0; + position:absolute; + top:0; + width:100%; + height:20px; + z-index:48; } -ul#simplemenu { -background:#ddd; -border-bottom:1px solid #999; -font:11px Verdana, Helvetica, sans-serif; -left:0; -position:absolute; -top:0; -width:100%; -height:21px; +#simplemenu li +{ + background:#ddd; + border-right:1px solid #999; + border-left:1px solid #eee; + float:left; + list-style:none; + position:relative; + margin:0; + padding:0; + z-index:48; } -ul#simplemenu li { -float:left; -border-right:1px solid #999; -border-left:1px solid #eee; -text-align: left; +#simplemenu a +{ + color:#333; + display:block; + float:left; + padding:.3em 2em .3em .6em; + text-decoration:none; + background:#ddd; } -ul#simplemenu li a { -background:#ddd; -padding:0.3em 2em 0.3em 0.6em; -text-decoration:none; +#simplemenu li.expanded > a +{ + background:url(right-green.gif) no-repeat 97%; + padding-right:2em; } -ul#simplemenu ul li a { -border:none; -width:11em; +#simplemenu li.root > a +{ + font-weight:700; + background:url(down-green.gif) no-repeat 97%; } -ul#simplemenu li.expanded > a { -background:#ddd url(right-green.gif) no-repeat 97%; +#simplemenu li ul +{ + float:none; + top:-999em; + position:absolute; + margin:0; + padding:0; + z-index:48; + width:14em; + background:#ddd; + border:1px solid #999; } -ul#simplemenu li.root > a { -font-weight:bold; -background:#ddd url(down-green.gif) no-repeat 97%; +#simplemenu li:hover,#simplemenu li.sfhover,#simplemenu a:focus,#simplemenu a:hover,#simplemenu a:active +{ + background:#3875d7; + color:#fff; } -ul#simplemenu li:hover > a { -background-color:#3875d7; -color:#fff; +#simplemenu li:hover ul,#simplemenu li.sfhover ul +{ + left:-1px; + top:20px; } -ul#simplemenu li ul { -background:#999; -border:1px solid #999; -left:-9999px; -position:absolute; -width:14em; -z-index:24; -} - -ul#simplemenu li ul ul { -margin:0 0 0 6em; +#simplemenu li:hover li ul,#simplemenu li.sfhover li ul +{ + top:-999em; } -ul#simplemenu li:hover ul ul,ul#simplemenu li:hover ul ul ul,ul#simplemenu li.sfhover ul ul,ul#simplemenu li.sfhover ul ul ul { -left:-9999px; +#simplemenu li li:hover ul,#simplemenu li li.sfhover ul +{ + left:14em; + top:-1px; + width:14em; } -ul#simplemenu li:hover ul,ul#simplemenu li li:hover ul,ul#simplemenu li li li:hover ul,ul#simplemenu li.sfhover ul,ul#simplemenu li li.sfhover ul,ul#simplemenu li li li.sfhover ul { -left:auto; +#simplemenu li li +{ + background:#ddd; + float:none; + border:none; +} + +#simplemenu li li a +{ + float:none; + padding-right:0; } \ No newline at end of file diff --git a/simplemenu.js b/simplemenu.js index 637e082a..42be6136 100644 --- a/simplemenu.js +++ b/simplemenu.js @@ -19,13 +19,123 @@ $(document).ready(function() { break; } - $('body').css('margin-top', '23px'); + $('body').css('margin-top', '20px'); - // Build menu - $('#simplemenu').append(simplemenu); - $('#simplemenu li').hover(function() { - $('ul', this).slideDown(200); - }, function() {}); - $('#simplemenu a').title(''); - $('#simplemenu').children('li.expanded').addClass('root'); -}); \ No newline at end of file + // Build menu + $('#simplemenu').append(simplemenu).children('li.expanded').addClass('root').superfish({ + animation : { opacity:"show", delay: 750 } + }) + .find(">li[ul]") + .mouseover(function(){ + $("ul", this).bgIframe({opacity:false}); + }) + .find("a") + .focus(function(){ + $("ul", $("#simplemenu>li[ul]")).bgIframe({opacity:false}); + }); +}); + +/* + * Superfish - jQuery menu widget + * + * Copyright (c) 2007 Joel Birch + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Last updated: 18/3/07 to remove iframes on 'out' + */ + +(function($){ + $.fn.superfish = function(o){ + var defaults = { + hoverClass : "sfHover", + delay : 500, + animation : {opacity:"show"}, + speed : "normal" + }, + over = function(){ + var $$ = $(this); + clearTimeout(this.sfTimer); + if (!$$.is("."+o.hoverClass)) { + $$.addClass(o.hoverClass) + .find("ul") + .animate(o.animation,o.speed) + .end() + .siblings() + .removeClass(o.hoverClass); + } + }, + out = function(){ + var $$ = $(this); + this.sfTimer=setTimeout(function(){ + $$.removeClass(o.hoverClass) + .find("iframe", this) + .remove(); + },o.delay); + }; + o = $.extend(defaults, o || {}); + var sfHovAr=$("li",this) + .hover(over,out) + .find("a").each(function() { + var $a = $(this), $li = $a.parents("li"); + $a.focus(function(){ $li.each(over); }) + .blur(function(){ $li.each(out); }); + }).end(); + $(window).unload(function() { + sfHovAr.unbind("mouseover").unbind("mouseout"); + }); + return this; + }; +})(jQuery); + +/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * $LastChangedDate: 2007-03-07 15:07:51 -0600 (Wed, 07 Mar 2007) $ + * $Rev: 1505 $ + */ + +/** + * The bgiframe is chainable and applies the iframe hack to get + * around zIndex issues in IE6. It will only apply itself in IE + * and adds a class to the iframe called 'bgiframe'. + * + * It does take borders into consideration but all values + * need to be in pixels and the element needs to have + * position relative or absolute. + * + * NOTICE: This plugin uses CSS expersions in order to work + * with an element's borders, height and with and can result in poor + * performance when used on an element that changes properties + * like size and position a lot. Two of these expressions can be + * removed if border doesn't matter and performance does. + * See lines 39 and 40 below and set top: 0 and left: 0 + * instead of their current values. + * + * @example $('div').bgiframe(); + * @before

                  Paragraph

                  + * @result