Index: activemenu.js =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/activemenu.js,v retrieving revision 1.1 diff -u -r1.1 activemenu.js --- activemenu.js 28 Mar 2008 16:36:44 -0000 1.1 +++ activemenu.js 28 Aug 2009 15:47:11 -0000 @@ -91,3 +91,71 @@ } } }; + +/* Drop down menu */ + +jQuery.fn.dropdownMenuHover = function (callback) { + this.hover( + function() { + $(this).find('ul:first').show(400); + }, + function() { + $(this).find('ul:first').hide(400); + } + ); +} + +Drupal.behaviors.dropdownMenu = function (context) { + // The elements supported. Each can designate a different uri. + var menus = Drupal.settings.dropdownmenu; + for (var menu in menus) { + $(menu).addClass('dropdownMenu-container'); + $(menu + ' li.expanded:not(.dropdownMenu-processed)').each(function () { + Drupal.preventSelect(this); + $(this) + .addClass('dropdownMenu-processed') + .dropdownMenuHover(); + }); + $(menu + ' li.collapsed:not(.dropdownMenu-processed)').each(function() { + if ($(this).children('ul').length > 0) { + return; + } + var path = Drupal.getPath($('a:first', this).attr('href')); + var url = Drupal.url(menus[menu]); + var elt = this; + Drupal.preventSelect(this); + $(this) + .mouseover(function (e) { + $(elt).addClass('loading'); + $.ajax({ + type: 'POST', + url: url, + data: {path: path}, + dataType: 'json', + success: function (data) { + $(elt).removeClass('loading'); + if ($(elt).children('ul').length > 0) { + return; + } + var dummy = document.createElement('div'); + $(dummy).html(data.content); + $(elt) + .append($(dummy).find('li:has(> a[href*='+ path +'])').find('> ul')) + .removeClass('collapsed') + .addClass('expanded') + .unbind('mouseover') + .find('ul:first').show(400); + $(elt).dropdownMenuHover(); + Drupal.attachBehaviors(elt); + }, + error: function (xmlhttp) { + if(xmlhttp.status >= 400) + alert('An HTTP error '+ xmlhttp.status +' occured.\n' + url); + } + }); + return false; + }) + .addClass('dropdownMenu-processed'); + }); + } +}; Index: activemenu.module =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/activemenu.module,v retrieving revision 1.4 diff -u -r1.4 activemenu.module --- activemenu.module 29 Dec 2008 22:38:47 -0000 1.4 +++ activemenu.module 28 Aug 2009 15:37:15 -0000 @@ -19,6 +19,14 @@ */ function activemenu_menu() { $items = array(); + + $items['admin/settings/activemenu'] = array( + 'title' => 'Activemenu settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('activemenu_admin'), + 'access arguments' => array('administer activemenu'), + 'file' => 'activemenu.admin.inc', + ); $items['activemenu/menu'] = array( 'title' => 'activemenu', @@ -37,13 +45,21 @@ function activemenu_load() { static $loaded = FALSE; if (!$loaded) { - $path = drupal_get_path('module', 'activemenu'); - jstools_add_js($path . '/activemenu.js'); - $activemenu = module_invoke_all('activemenu'); + $settings = variable_get('activemenu_settings', array()); + $activemenu = module_invoke_all('activemenu', $settings); + if (count($activemenu)) { - drupal_add_js(array('activemenu' => $activemenu), 'setting'); + $path = drupal_get_path('module', 'activemenu'); + jstools_add_js($path . '/activemenu.js'); + + foreach (array_keys(activemenu_get_menu_types()) as $type) { + if (! empty($activemenu[$type])) { + drupal_add_js(array($type => $activemenu[$type]), 'setting'); + } + } + + activemenu_theme_css(); } - activemenu_theme_css(); $loaded = TRUE; } } @@ -114,3 +130,15 @@ } return isset($_POST['path']) ? drupal_get_normal_path($_POST['path'], $langcode) : FALSE; } + +/** +* @return Array All existing menu types +*/ +function activemenu_get_menu_types() { + return array( + 'activemenu' => t('Tree menu'), + 'dropdownmenu' => t('Drop down menu'), + ); +} + + Index: modules/book.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/modules/book.inc,v retrieving revision 1.4 diff -u -r1.4 book.inc --- modules/book.inc 21 Jun 2008 02:03:33 -0000 1.4 +++ modules/book.inc 28 Aug 2009 15:31:21 -0000 @@ -4,9 +4,13 @@ /** * Implementation of hook_activemenu(). */ -function book_activemenu() { +function book_activemenu($settings) { $items = array(); - $items['#block-book-0'] = 'activemenu/book'; + + if (! empty($settings['book']['enable'])) { + $items[$settings['book']['type']]['#block-book-0'] = 'activemenu/book'; + } + return $items; } @@ -49,3 +53,28 @@ print drupal_to_js(array('status' => TRUE, 'content' => $menu)); } } + +/** + * Implementation of hook_activemenu_settings(). + */ +function book_activemenu_settings($settings) { + $form = array( + '#type' => 'fieldset', + '#title' => t('Book'), + ); + + $form['enable'] = array( + '#type' => 'checkbox', + '#title' => t('Activate AJAX menu for books'), + '#default_value' => isset($settings['enable']) ? $settings['enable'] : 0, + ); + + $form['type'] = array( + '#type' => 'select', + '#title' => t('Menu type'), + '#options' => activemenu_get_menu_types(), + '#default_value' => isset($settings['type']) ? $settings['type'] : 'tree', + ); + + return $form; +} Index: modules/menu.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/modules/menu.inc,v retrieving revision 1.1 diff -u -r1.1 menu.inc --- modules/menu.inc 28 Mar 2008 16:36:45 -0000 1.1 +++ modules/menu.inc 28 Aug 2009 15:31:43 -0000 @@ -1,13 +1,51 @@ 'fieldset', + '#title' => t('Menus'), + ); + + $menus = menu_get_menus(); + // The Navigation menu is handled by the user module. + unset($menus['navigation']); + + foreach ($menus as $name => $title) { + $form[$name] = array( + '#type' => 'fieldset', + '#title' => $title, + ); + + $form[$name]['enable'] = array( + '#type' => 'checkbox', + '#title' => t('Activate AJAX menu for %menu', array('%menu' => $title)), + '#default_value' => isset($settings[$name]['enable']) ? $settings[$name]['enable'] : 0, + ); + + $form[$name]['type'] = array( + '#type' => 'select', + '#title' => t('Menu type'), + '#options' => activemenu_get_menu_types(), + '#default_value' => isset($settings[$name]['type']) ? $settings[$name]['type'] : 'tree', + ); + } + + return $form; } \ No newline at end of file Index: modules/user.inc =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/modules/user.inc,v retrieving revision 1.1 diff -u -r1.1 user.inc --- modules/user.inc 28 Mar 2008 16:36:45 -0000 1.1 +++ modules/user.inc 28 Aug 2009 15:31:53 -0000 @@ -1,8 +1,37 @@ 'fieldset', + '#title' => t('Navigation'), + ); + + $form['enable'] = array( + '#type' => 'checkbox', + '#title' => t('Activate AJAX menu for navigation menu'), + '#default_value' => isset($settings['enable']) ? $settings['enable'] : 0, + ); + + $form['type'] = array( + '#type' => 'select', + '#title' => t('Menu type'), + '#options' => activemenu_get_menu_types(), + '#default_value' => isset($settings['type']) ? $settings['type'] : 'tree', + ); + + return $form; +} Index: theme/garland.css =================================================================== RCS file: /cvs/drupal/contributions/modules/activemenu/theme/garland.css,v retrieving revision 1.1 diff -u -r1.1 garland.css --- theme/garland.css 28 Mar 2008 16:36:45 -0000 1.1 +++ theme/garland.css 28 Aug 2009 15:55:57 -0000 @@ -23,3 +23,131 @@ li.collapsed ul { display: none; } + +/* Drop down menu */ + +.dropdownMenu-container, +.dropdownMenu-container .dropdownMenu-container ul, +#header-region .dropdownMenu-container, +#header-region .dropdownMenu-container ul { + margin: 0; + padding: 0; + list-style-type: none; + list-style-position: outside; + position: relative; + line-height: 1.5em; + display: block; +} + +.dropdownMenu-container ul a, +#header-region .dropdownMenu-container ul a { + display: block; + padding: 0px 20px 0 5px; + border: 1px solid #333; + color: #fff; + text-decoration: none; + background-color: #333; + background-repeat: no-repeat; + background-position: center right; +} + +.dropdownMenu-container ul a:hover, +#header-region .dropdownMenu-container ul a:hover { + background-color: #fff; + color: #333; +} + +.dropdownMenu-container li.leaf a, +#header-region .dropdownMenu-container li.leaf a, +.dropdownMenu-container li.dropdownMenu-processed li.leaf a, +#header-region .dropdownMenu-container li.dropdownMenu-processed li.leaf a { + background-image: none; +} + +.dropdownMenu-container li.expanded a, +.dropdownMenu-container li.collapsed a, +#header-region .dropdownMenu-container li.expanded a, +#header-region .dropdownMenu-container li.collapsed a { + background-image: url(../arrow_down.png); +} + +li.dropdownMenu-processed li.expanded a, +li.dropdownMenu-processed li.collapsed a, +#header-region li.dropdownMenu-processed li.expanded a, +#header-region li.dropdownMenu-processed li.collapsed a { + background-image: url(../arrow_right.png); +} + +.dropdownMenu-container li.expanded.loading a, +.dropdownMenu-container li.collapsed.loading a, +.dropdownMenu-container li.dropdownMenu-processed.loading a, +li.dropdownMenu-processed li.dropdownMenu-processed.loading a, +#header-region .dropdownMenu-container li.expanded.loading a, +#header-region .dropdownMenu-container li.collapsed.loading a, +#header-region .dropdownMenu-container li.dropdownMenu-processed.loading a, +#header-region li.dropdownMenu-processed li.dropdownMenu-processed.loading a { + background-image: url(../status-active.gif); +} + +li.dropdownMenu-processed, +.dropdownMenu-container li.leaf, +#header-region li.dropdownMenu-processed, +#header-region .dropdownMenu-container li.leaf { + display: list-item; + float: left; + position: relative; + margin: 0 .3em; +} + +.dropdownMenu-container li.expanded li, +#header-region .dropdownMenu-container li.expanded li { + margin: 0; +} + +.dropdownMenu-container ul ul, +#header-region .dropdownMenu-container ul ul { + position: absolute; + z-index: 10; + display: none; + width: 12em; + top: 1.5em; +} + +li.dropdownMenu-processed ul a, +#header-region li.dropdownMenu-processed ul a { + width: 12em; + height: auto; + float: left; +} + +.dropdownMenu-container ul ul, +#header-region .dropdownMenu-container ul ul { + top: auto; +} + +.dropdownMenu-container ul li ul ul, +#header-region .dropdownMenu-container ul li ul ul { + left: 12em; + margin: 0px 0 0 10px; +} + +.dropdownMenu-container ul li:hover ul ul, +.dropdownMenu-container ul li:hover ul ul ul, +.dropdownMenu-container ul li:hover ul ul ul ul, +#header-region .dropdownMenu-container ul li:hover ul ul, +#header-region .dropdownMenu-container ul li:hover ul ul ul, +#header-region .dropdownMenu-container ul li:hover ul ul ul ul { + display: none; +} + +.dropdownMenu-container ul li:hover ul, +.dropdownMenu-container ul li li:hover ul, +.dropdownMenu-container ul li li li:hover ul, +.dropdownMenu-container ul li li li li:hover ul +#header-region .dropdownMenu-container ul li:hover ul, +#header-region .dropdownMenu-container ul li li:hover ul, +#header-region .dropdownMenu-container ul li li li:hover ul, +#header-region .dropdownMenu-container ul li li li li:hover ul { + display: block; +} +