From: Alexander Ebert Date: Sat, 8 Oct 2016 12:05:17 +0000 (+0200) Subject: Fixed tab menu change on location hash update X-Git-Tag: 3.0.0_Beta_3~50^2~55 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f03cf6f951d8742f72c2bd98117cd9eeb143ebe6;p=GitHub%2FWoltLab%2FWCF.git Fixed tab menu change on location hash update --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js index 347c4322f1..1762f77c87 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js @@ -40,6 +40,18 @@ define(['Dictionary', 'EventHandler', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Clos disable: this._scrollDisable.bind(this), setup: this._scrollEnable.bind(this, true) }); + + window.addEventListener('hashchange', function () { + var hash = window.location.hash.replace(/^#/, ''); + var element = (hash) ? elById(hash) : null; + if (element !== null && element.classList.contains('tabMenuContent')) { + _tabMenus.forEach(function (tabMenu) { + if (tabMenu.hasTab(hash)) { + tabMenu.select(hash); + } + }); + } + }); }, /** diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js index 3bc3b93a4d..53c3bf57d3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js @@ -291,6 +291,16 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict this.init(oldTabs); }, + /** + * Returns true if this tab menu has a tab with provided name. + * + * @param {string} name tab name + * @return {boolean} true if tab name matches + */ + hasTab: function (name) { + return this._tabs.has(name); + }, + /** * Handles clicks on a tab. *