From c318ad3b11a577c935d510f9261857ebbdb5675b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 4 May 2015 13:57:12 +0200 Subject: [PATCH] Implemented the flexible menu --- .../templates/headIncludeJavaScript.tpl | 34 --- wcfsetup/install/files/js/WCF.js | 214 +----------------- .../install/files/js/WoltLab/WCF/Bootstrap.js | 9 +- .../files/js/WoltLab/WCF/DOM/Traverse.js | 45 ++++ .../install/files/js/WoltLab/WCF/DOM/Util.js | 23 +- .../files/js/WoltLab/WCF/UI/FlexibleMenu.js | 202 +++++++++++++++++ 6 files changed, 283 insertions(+), 244 deletions(-) create mode 100644 wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index 02685ae5d0..e63e9235db 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -130,13 +130,6 @@ {event name='javascriptLanguageImport'} }); - - $(function() { - console.time('wcf'); - //WCF.TabMenu.init(); - //WCF.System.FlexibleMenu.init(); - console.timeEnd('wcf'); - }); @@ -145,39 +138,12 @@ baseUrl: '{@$__wcf->getPath()}js' }); - /*require(function(require) { - var ui = require('WCF/UI'); - - console.debug(ui); - });*/ - define('jQuery', [], function() { return window.jQuery; }); $.holdReady(true); require(['WoltLab/WCF/Bootstrap'], function(bootstrap) { bootstrap.setup(); }); - /* - require(['WoltLab/WCF/Date/Time/Relative', 'UI/SimpleDropdown'], function(relative, dropdown) { - relative.init(); - - console.time('wcfNew'); - dropdown.setup(); - console.timeEnd('wcfNew'); - - $.holdReady(false); - }); - */ - /* - require(function(require) { - var core = require('WoltLab/WCF/Core'); - - core.Init(); - }); - - require(['WoltLab/WCF/Core'], function(core) { - core.Init(); - });*/ {if ENABLE_DEBUG_MODE} diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index a132200bde..875b0a8c86 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3877,8 +3877,8 @@ WCF.TabMenu = { * Initializes all TabMenus */ init: function() { - require(['WoltLab/WCF/UI/TabMenu'], function(tabMenu) { - tabMenu.init(); + require(['WoltLab/WCF/UI/TabMenu'], function(UITabMenu) { + UITabMenu.setup(); }); return; @@ -6647,74 +6647,10 @@ WCF.System.Dependency.Manager = { * Provides flexible dropdowns for tab-based menus. */ WCF.System.FlexibleMenu = { - /** - * list of containers - * @var object - */ - _containers: { }, - - /** - * list of registered container ids - * @var array - */ - _containerIDs: [ ], - - /** - * list of dropdowns - * @var object - */ - _dropdowns: { }, - - /** - * list of dropdown menus - * @var object - */ - _dropdownMenus: { }, - - /** - * list of hidden status for containers - * @var object - */ - _hasHiddenItems: { }, - - /** - * true if menus are currently rebuilt - * @var boolean - */ - _isWorking: false, - - /** - * list of tab menu items per container - * @var object - */ - _menuItems: { }, - /** * Initializes the WCF.System.FlexibleMenu class. */ - init: function() { - // register .mainMenu and .navigationHeader by default - this.registerMenu('mainMenu'); - this.registerMenu($('.navigationHeader:eq(0)').wcfIdentify()); - - this._registerTabMenus(); - - $(window).resize($.proxy(this.rebuildAll, this)); - WCF.DOMNodeInsertedHandler.addCallback('WCF.System.FlexibleMenu', $.proxy(this._registerTabMenus, this)); - }, - - /** - * Registers tab menus. - */ - _registerTabMenus: function() { - // register tab menus - $('.tabMenuContainer:not(.jsFlexibleMenuEnabled), .messageTabMenu:not(.jsFlexibleMenuEnabled)').each(function(index, tabMenuContainer) { - var $navigation = $(tabMenuContainer).addClass('jsFlexibleMenuEnabled').children('nav'); - if ($navigation.length && $navigation.find('> ul:eq(0) > li').length) { - WCF.System.FlexibleMenu.registerMenu($navigation.wcfIdentify()); - } - }); - }, + init: function() { /* does nothing */ }, /** * Registers a tab-based menu by id. @@ -6732,39 +6668,9 @@ WCF.System.FlexibleMenu = { * @param string containerID */ registerMenu: function(containerID) { - var $container = $('#' + containerID); - if (!$container.length) { - console.debug("[WCF.System.FlexibleMenu] Unable to find container identified by '" + containerID + "', aborting."); - return; - } - - this._containerIDs.push(containerID); - this._containers[containerID] = $container; - this._menuItems[containerID] = $container.find('> ul:eq(0) > li'); - this._dropdowns[containerID] = $('').data('containerID', containerID).click($.proxy(this._click, this)); - this._dropdownMenus[containerID] = $('