Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.84
diff -u -r1.84 menu.inc
--- includes/menu.inc 25 Aug 2005 21:14:16 -0000 1.84
+++ includes/menu.inc 11 Sep 2005 02:00:47 -0000
@@ -549,11 +549,16 @@
*
* @param $pid
* The parent id of the menu.
+ * @param $dynamic
+ * Boolean indicating whether the menu should be rendered for dynamic, interactive display.
*
* @ingroup themeable
*/
-function theme_menu_tree($pid = 1) {
- if ($tree = menu_tree($pid)) {
+function theme_menu_tree($pid = 1, $dynamic = NULL) {
+ if ($dynamic === NULL) {
+ $dynamic = theme_get_setting('dynamic_menus');
+ }
+ if ($tree = menu_tree($pid, $dynamic)) {
return "\n
\n";
}
}
@@ -563,14 +568,17 @@
*
* @param $pid
* The parent id of the menu.
+ * @param $dynamic
+ * Boolean indicating whether the menu should be rendered for dynamic, interactive display.
*/
-function menu_tree($pid = 1) {
+function menu_tree($pid = 1, $dynamic = FALSE) {
$menu = menu_get_menu();
$output = '';
if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
foreach ($menu['visible'][$pid]['children'] as $mid) {
- $output .= theme('menu_item', $mid, menu_in_active_trail($mid) || ($menu['visible'][$mid]['type'] & MENU_EXPANDED) ? theme('menu_tree', $mid) : '', count($menu['visible'][$mid]['children']) == 0);
+ $state = count($menu['visible'][$mid]['children']) == 0 ? 'leaf' : 'expanded' . ((menu_in_active_trail($mid) || ($menu['visible'][$mid]['type'] & MENU_EXPANDED)) ? '' : ' collapsed');
+ $output .= theme('menu_item', $mid, $state, ((count($menu['visible'][$mid]['children']) > 0) && ($dynamic || ($state == 'expanded')) ? theme('menu_tree', $mid, $dynamic) : ''), $dynamic);
}
}
@@ -582,15 +590,20 @@
*
* @param $mid
* The menu id of the item.
+ * @param $class
+ * A string containing the CSS class.
* @param $children
* A string containing any rendered child items of this menu.
- * @param $leaf
- * A boolean indicating whether this menu item is a leaf.
+ * @param $dynamic
+ * Boolean indicating whether the menu should be rendered for dynamic, interactive display.
*
* @ingroup themeable
*/
-function theme_menu_item($mid, $children = '', $leaf = TRUE) {
- return ''. menu_item_link($mid) . $children ."\n";
+function theme_menu_item($mid, $class = 'leaf', $children = '', $dynamic = FALSE) {
+ if ($dynamic) {
+ drupal_add_js('misc/activemenu.js');
+ }
+ return '' . (($dynamic && (!(strpos($class, 'expanded') === FALSE))) ? '' : '') . menu_item_link($mid) . $children ."\n";
}
/**
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.258
diff -u -r1.258 theme.inc
--- includes/theme.inc 8 Sep 2005 19:17:34 -0000 1.258
+++ includes/theme.inc 11 Sep 2005 01:57:49 -0000
@@ -219,6 +219,7 @@
'logo_path' => '',
'default_favicon' => 1,
'favicon_path' => '',
+ 'dynamic_menus' => 0,
'toggle_logo' => 1,
'toggle_favicon' => 1,
'toggle_name' => 1,
Index: misc/drupal.css
===================================================================
RCS file: /cvs/drupal/drupal/misc/drupal.css,v
retrieving revision 1.120
diff -u -r1.120 drupal.css
--- misc/drupal.css 7 Sep 2005 20:56:00 -0000 1.120
+++ misc/drupal.css 10 Sep 2005 23:49:31 -0000
@@ -74,9 +74,22 @@
padding: 0.2em 0.5em 0 0;
margin: 0;
}
+li.collapsed ul {
+ display: none;
+}
li a.active {
color: #000;
}
+img.activemenu {
+ height: 7px;
+ width: 7px;
+ margin-left: -15px;
+ margin-right: 8px;
+}
+img.pointer {
+ cursor: pointer;
+ cursor: hand;
+}
td.menu-disabled {
background: #ccc;
}
Index: misc/drupal.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/drupal.js,v
retrieving revision 1.8
diff -u -r1.8 drupal.js
--- misc/drupal.js 7 Sep 2005 13:49:39 -0000 1.8
+++ misc/drupal.js 9 Sep 2005 15:55:17 -0000
@@ -169,7 +169,7 @@
}
/**
- * Adds a function to the window onload event
+ * Adds a function to a form's submit event
*/
function addSubmitEvent(form, func) {
var oldSubmit = form.onsubmit;
@@ -251,6 +251,22 @@
}
/**
+ * Switches one title for another for an element
+ */
+function switchTitle(node, title1, title2) {
+ title = node.getAttribute('title');
+ if(title == title1) {
+ node.setAttribute('title', title2);
+ return true;
+ }
+ else if(title == title2) {
+ node.setAttribute('title', title1);
+ return true;
+ }
+ return false;
+}
+
+/**
* Emulate PHP's ereg_replace function in javascript
*/
function eregReplace(search, replace, subject) {
Index: modules/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system.module,v
retrieving revision 1.233
diff -u -r1.233 system.module
--- modules/system.module 8 Sep 2005 20:25:08 -0000 1.233
+++ modules/system.module 11 Sep 2005 01:57:58 -0000
@@ -754,6 +754,13 @@
$form .= form_group(t('Shortcut icon settings'), $group);
}
+ // Dynamic menus setting
+ if ((!$key) || in_array('dynamic_menus', $features)) {
+ $group = t('Menu navigation can feature dynamic tree menus, which users can click to expand or collapse.');
+ $group .= form_checkbox(t('Use dynamic menus.'), "$var][dynamic_menus", 1, $settings['dynamic_menus'], '');
+ $form .= form_group(t('Dynamic menus'), $group);
+ }
+
// System wide only settings.
if (!$key) {
// Menu settings
Index: themes/engines/phptemplate/phptemplate.engine
===================================================================
RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v
retrieving revision 1.17
diff -u -r1.17 phptemplate.engine
--- themes/engines/phptemplate/phptemplate.engine 9 Sep 2005 05:32:31 -0000 1.17
+++ themes/engines/phptemplate/phptemplate.engine 11 Sep 2005 01:57:59 -0000
@@ -121,6 +121,7 @@
function phptemplate_features() {
return array(
'logo',
+ 'dynamic_menus',
'toggle_comment_user_picture',
'toggle_favicon',
'toggle_mission',