remove AJAX callback, pass menu structure to page directly, dramatically faster, 1 less HTTP request, clear your menu cache, can produce weirdness/infinit loops
This commit is contained in:
parent
ccd2494fb7
commit
ec97ad2402
@ -21,12 +21,11 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('body').css('margin-top', '23px');
|
$('body').css('margin-top', '23px');
|
||||||
|
|
||||||
// Drupal menu callback
|
// Build menu
|
||||||
$('#simplemenu').load(basePath + 'simplemenu/menu', function() {
|
$('#simplemenu').append(simplemenu);
|
||||||
$('li', this).hover(function() {
|
$('#simplemenu li').hover(function() {
|
||||||
$('ul', this).slideDown(200);
|
$('ul', this).slideDown(200);
|
||||||
}, function() {});
|
}, function() {});
|
||||||
$('a', this).title('');
|
$('#simplemenu a').title('');
|
||||||
$(this).children('li.expanded').addClass('root');
|
$('#simplemenu').children('li.expanded').addClass('root');
|
||||||
});
|
|
||||||
});
|
});
|
@ -13,13 +13,6 @@ function simplemenu_menu($may_cache) {
|
|||||||
$items = array();
|
$items = array();
|
||||||
|
|
||||||
if ($may_cache) {
|
if ($may_cache) {
|
||||||
$items[] = array(
|
|
||||||
'path' => 'simplemenu/menu',
|
|
||||||
'access' => user_access('view simplemenu'),
|
|
||||||
'callback' => 'simplemenu_get_menu',
|
|
||||||
'type' => MENU_CALLBACK
|
|
||||||
);
|
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'path' => 'admin/settings/simplemenu',
|
'path' => 'admin/settings/simplemenu',
|
||||||
'title' => t('SimpleMenu'),
|
'title' => t('SimpleMenu'),
|
||||||
@ -57,6 +50,7 @@ function simplemenu_footer() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
drupal_add_js(array('simplemenu' => $settings), 'setting');
|
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');
|
drupal_add_js($path .'/simplemenu.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,33 +124,19 @@ function simplemenu_admin_settings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of devel module links if the module is enabled
|
* Render an HTML list of links for a given menu.
|
||||||
* and the user has access to this module.
|
|
||||||
*/
|
*/
|
||||||
function simplemenu_get_devel() {
|
function simplemenu_get_menu() {
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if (variable_get('simplemenu_devel', 0) && module_exists('devel')) {
|
$menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1));
|
||||||
if (user_access('access devel information')) {
|
|
||||||
$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)) {
|
if (!$menu) {
|
||||||
// True only if devel_node_access enabled.
|
$menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
||||||
$links[] = l('Node access summary', 'devel/node_access/summary');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = '<li class="expanded"><a href="'. url('admin/settings/devel') .'">'. t('Devel module') .'</a><ul>';
|
$output .= simplemenu_get_devel();
|
||||||
$output .= '<li class="leaf">'. implode($links, '</li><li class="leaf">') .'</li>';
|
$output .= $menu;
|
||||||
$output .= '</ul></li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
@ -191,16 +171,33 @@ function simplemenu_theme_menu_tree($pid = 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AJAX menu callback to return an HTML list of links for a given menu.
|
* Return a list of devel module links if the module is enabled
|
||||||
|
* and the user has access to this module.
|
||||||
*/
|
*/
|
||||||
function simplemenu_get_menu() {
|
function simplemenu_get_devel() {
|
||||||
$menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1));
|
$output = '';
|
||||||
|
|
||||||
if (!$menu) {
|
if (variable_get('simplemenu_devel', 0) && module_exists('devel')) {
|
||||||
$menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
if (user_access('access devel information')) {
|
||||||
|
$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');
|
||||||
}
|
}
|
||||||
|
|
||||||
print simplemenu_get_devel();
|
$output = '<li class="expanded"><a href="'. url('admin/settings/devel') .'">'. t('Devel module') .'</a><ul>';
|
||||||
print $menu;
|
$output .= '<li class="leaf">'. implode($links, '</li><li class="leaf">') .'</li>';
|
||||||
exit;
|
$output .= '</ul></li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user