}
});
-/**
- * Handles ACPMenu.
- *
- * @param array<string> activeMenuItems
- */
-WCF.ACP.Menu = Class.extend({
- /**
- * Initializes ACPMenu.
- *
- * @param array activeMenuItems
- */
- init: function(activeMenuItems) {
- this._headerNavigation = $('nav#mainMenu');
- this._sidebarNavigation = $('aside.collapsibleMenu > div');
-
- this._prepareElements(activeMenuItems);
- },
-
- /**
- * Resets all elements and binds event listeners.
- */
- _prepareElements: function(activeMenuItems) {
- this._headerNavigation.find('li').removeClass('active');
-
- this._sidebarNavigation.find('legend').each($.proxy(function(index, menuHeader) {
- $(menuHeader).click($.proxy(this._toggleItem, this));
- }, this));
-
- // close all navigation groups
- this._sidebarNavigation.find('nav ul').each(function() {
- $(this).hide();
- });
-
- this._headerNavigation.find('li').click($.proxy(this._toggleSidebar, this));
-
- if (activeMenuItems.length === 0) {
- this._renderSidebar(this._headerNavigation.find('li:first').data('menuItem'), []);
- }
- else {
- this._renderSidebar('', activeMenuItems);
- }
- },
-
- /**
- * Toggles a navigation group entry.
- */
- _toggleItem: function(event) {
- var $menuItem = $(event.currentTarget);
-
- $menuItem.parent().find('nav ul').stop(true, true).toggle('blind', { }, 200).end();
- $menuItem.toggleClass('active');
- },
-
- /**
- * Handles clicks on main menu.
- *
- * @param object event
- */
- _toggleSidebar: function(event) {
- var $target = $(event.currentTarget);
-
- if ($target.hasClass('active')) {
- return;
- }
-
- this._renderSidebar($target.data('menuItem'), []);
- },
-
- /**
- * Renders sidebar including highlighting of currently active menu items.
- *
- * @param string menuItem
- * @param array activeMenuItems
- */
- _renderSidebar: function(menuItem, activeMenuItems) {
- // reset visible and active items
- this._headerNavigation.find('li').removeClass('active');
- this._sidebarNavigation.find('> div').hide();
-
- if (activeMenuItems.length === 0) {
- // show active menu
- this._headerNavigation.find('li[data-menu-item="' + menuItem + '"]').addClass('active');
- this._sidebarNavigation.find('div[data-parent-menu-item="' + menuItem + '"]').show();
- }
- else {
- // open menu by active menu items, first element is always a head navigation item
- menuItem = activeMenuItems.shift();
-
- this._headerNavigation.find('li[data-menu-item="' + menuItem + '"]').addClass('active');
- this._sidebarNavigation.find('div[data-parent-menu-item="' + menuItem + '"]').show();
-
- for (var $i = 0, $size = activeMenuItems.length; $i < $size; $i++) {
- var $item = activeMenuItems[$i];
-
- if ($.wcfIsset($item)) {
- var $menuItem = $('#' + $.wcfEscapeID($item));
-
- if ($menuItem.getTagName() === 'ul') {
- $menuItem.show().parents('fieldset').children('legend').addClass('active');
- }
- else {
- $menuItem.addClass('active');
- }
- }
- }
- }
- }
-});
-
/**
* Namespace for ACP package management.
*/