diff --git a/drupal/sites/all/modules/custom/dmenu_admin/README.txt b/drupal/sites/all/modules/custom/dmenu_admin/README.txt new file mode 100644 index 0000000..66d0e4f --- /dev/null +++ b/drupal/sites/all/modules/custom/dmenu_admin/README.txt @@ -0,0 +1,8 @@ +Dynamic Menu Admin is a module designed for sites with outstandingly large +amount of menu entries. Stock Drupal 6 does not particularly like having more +than about 200 entries but even if that were fixed, rendering more than 200 +is very likely to crash IE6 and some 7 users due to slower JS engines. + +After enabling the module you will find new links on the Menu Admin page which +will allow you to expand/collapse branches of the menu system so that at any +point your browser will not have to render too much information. \ No newline at end of file diff --git a/drupal/sites/all/modules/custom/dmenu_admin/dmenu-admin.js b/drupal/sites/all/modules/custom/dmenu_admin/dmenu-admin.js new file mode 100644 index 0000000..18efe9d --- /dev/null +++ b/drupal/sites/all/modules/custom/dmenu_admin/dmenu-admin.js @@ -0,0 +1,37 @@ +// $Id$ + +/** + * This behavior adds twisty links to the menu admin page which helps with rendering + * time on large menus significantly. + */ +Drupal.behaviors.dmenu_admin = function (context) { + // We're going to screw up any tiger-striping by having hidden rows so we really + // have to kill it here. + $('.even').removeClass('even').addClass('odd'); + // Override the striping function or it will restripe when a row is dragged + Drupal.tableDrag.prototype.restripeTable = function () {}; + + $('a.showchild').click( function() { + // Show children + var mlid = $(this).parent().parent().attr('class').match(/mlid([^\ ]*)/)[1]; + $('.plid' + mlid).show(); + + // switch link to collapse child menus + $(this).hide(); + $(this).parent().find('.hidechild').show(); + return false; + }); + $('a.hidechild').click( function() { + // Show children + var mlid = $(this).parent().parent().attr('class').match(/mlid([^\ ]*)/)[1]; + $('.plid' + mlid).each(function () { + $(this).hide(); + $(this).find('a.hidechild').click(); + }); + + // switch link to expand child menus + $(this).hide(); + $(this).parent().find('.showchild').show(); + return false; + }); +}; \ No newline at end of file diff --git a/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.info b/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.info new file mode 100644 index 0000000..9762a65 --- /dev/null +++ b/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.info @@ -0,0 +1,4 @@ +name = Dynamic Menu Administration +description = Dynamic loading of the submenus during menu administration +core = 6.x +dependancies[] = menu diff --git a/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.module b/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.module new file mode 100644 index 0000000..68be725 --- /dev/null +++ b/drupal/sites/all/modules/custom/dmenu_admin/dmenu_admin.module @@ -0,0 +1,66 @@ + 'AJAX callback for the dynamic menu builder', + 'page callback' => 'dmenu_admin_return_children', + 'access arguments' => array('administer menu'), + 'type' => MENU_CALLBACK, + ); + + return $items; +} + + + +/** + * Implements hook_form_alter(). + */ +function dmenu_admin_form_alter(&$form, $form_state, $form_id) { + switch ( $form_id ) { + case "menu_overview_form": + foreach ( $form as &$element ) { + // Change the type of the weight column to a hidden element which speeds up + // load time of the menus dramatically. This will hopefully someday become + // a core patch. + if (is_array($element)) { + if ( $element['weight']['#type'] == 'weight') { + $element['weight']['#type'] = 'textfield'; + unset($element['weight']['#options']); + } + if (isset( $element['#item']['plid'])) { + $element['#attributes']['class'] .= ' plid' . $element['plid']['#default_value']; + $element['#attributes']['class'] .= ' mlid' . $element['mlid']['#value']; + + if ($element['#item']['plid'] != 0) { + // remove everything but the top level elements + $element['#attributes']['style'] = 'display: none;'; + } + } + if (isset( $element['#item']['has_children'] ) && $element['#item']['has_children']) { + // Add a class so that people can color the expandable areas at their whim + $element['#attributes']['class'] .= ' has-children'; + // print a link to get the children + $element['title']['#value'] .= + ' ' . + t('[expand]') .''; + $element['title']['#value'] .= + ''; + } + } + } + drupal_add_js(drupal_get_path('module', 'dmenu_admin') . '/dmenu-admin.js', 'module', 'header', FALSE, TRUE, FALSE); + break; + } +} +