Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Last active November 6, 2017 23:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaycs85/346c14aedffcafe8945e to your computer and use it in GitHub Desktop.
Save vijaycs85/346c14aedffcafe8945e to your computer and use it in GitHub Desktop.
(function ($) {
Drupal.behaviors.menuTree = {
attach: function (context, settings) {
// Set ul depths for better theming.
$('#main-menu ul').each(function () {
var depth = $(this).parents('ul').length;
$(this).addClass('ul-depth-' + depth);
});
// Set ul > li depths for better theming.
$('#main-menu ul li').each(function () {
var depth = $(this).parents('li').length;
$(this).addClass('li-depth-' + depth);
});
// Set li > a depths for better theming.
$('#main-menu ul li a').each(function () {
var depth = $(this).parents('ul').length;
$(this).addClass('ula-depth-' + depth);
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment