OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/app/assets/javascripts/specific/main_menu.js.erb

26 lines
1.3 KiB

<% environment.context_class.instance_eval { include ApplicationHelper } %>
jQuery(document).ready(function($) {
// rejigger the main-menu sub-menu functionality.
$("#main-menu .toggler").remove(); // remove the togglers so they're inserted properly later.
$("#main-menu li:has(ul) > a").not("ul ul a")
// 1. unbind the current click functions
.unbind("click")
// 2. wrap each in a span that we'll use for the new click element
.wrapInner("<span class='toggle-follow ellipsis'></span>")
// 3. reinsert the <span class="toggler"> so that it sits outside of the above
.append('<%= icon_wrapper("toggler icon6 icon-arrow-right5-2", I18n.t("description_menu_item_toggle")) %>')
// 4. attach a new click function that will follow the link if you clicked on the span itself and toggle if not
.click(function(event) {
if ($(event.target).hasClass("toggler") ) {
var menuParent = $(this).toggleClass("open").parent().find("ul").not("ul ul ul");
menuParent.mySlide();
if ($(this).hasClass("open")) {
menuParent.find("li > a:first").focus();
}
return false;
}
});
});