From 5717e253eb760bd096795a4797c41de910a3b266 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 26 Feb 2016 17:29:22 +0100 Subject: [PATCH] Guests will now be served a proper user menu Just showing the login dialog is rather lame, especially since it does not provide the ability to change the UI language. --- com.woltlab.wcf/templates/pageHeaderUser.tpl | 11 +++- com.woltlab.wcf/templates/pageMenuMobile.tpl | 53 ++++++++++++++++--- wcfsetup/install/files/js/WCF.User.js | 8 ++- .../js/WoltLab/WCF/Ui/Page/Menu/Abstract.js | 7 ++- .../files/js/WoltLab/WCF/Ui/Page/Menu/User.js | 19 ++----- 5 files changed, 72 insertions(+), 26 deletions(-) diff --git a/com.woltlab.wcf/templates/pageHeaderUser.tpl b/com.woltlab.wcf/templates/pageHeaderUser.tpl index 22fbe3e4f3..13e45b60f8 100644 --- a/com.woltlab.wcf/templates/pageHeaderUser.tpl +++ b/com.woltlab.wcf/templates/pageHeaderUser.tpl @@ -204,7 +204,7 @@ {if $__wcf->getLanguage()->getLanguages()|count > 1}
  • diff --git a/com.woltlab.wcf/templates/pageMenuMobile.tpl b/com.woltlab.wcf/templates/pageMenuMobile.tpl index e9a388a800..e73ed15dcf 100644 --- a/com.woltlab.wcf/templates/pageMenuMobile.tpl +++ b/com.woltlab.wcf/templates/pageMenuMobile.tpl @@ -74,9 +74,10 @@ {* user menu *} -{if $__wcf->user->userID} - diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index 4c393c8ff5..0031b347aa 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -595,7 +595,13 @@ WCF.User.QuickLogin = { input.setAttribute('value', window.location.protocol + '//' + window.location.host + input.getAttribute('value')); } - EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'showLogin', callbackOpen); + EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'more', function(data) { + if (data.identifier === 'com.woltlab.wcf.login') { + data.handler.close(true); + + callbackOpen(); + } + }); }); } }; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/Abstract.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/Abstract.js index 284cd5ed79..46ad9b68a6 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/Abstract.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/Abstract.js @@ -135,14 +135,17 @@ define(['Environment', 'EventHandler', 'ObjectMap', 'Dom/Traverse', 'Ui/Screen'] var isLink = (elAttr(item, 'href') !== '#'); var parent = item.parentNode; var parentItemList = parent.parentNode; - var itemTitle = DomTraverse.childByClass(item, 'menuOverlayItemTitle').textContent; + var itemTitle = elData(itemList, 'title'); this._items.set(item, { itemList: itemList, parentItemList: parentItemList }); - elData(itemList, 'title', itemTitle); + if (itemTitle === '') { + itemTitle = DomTraverse.childByClass(item, 'menuOverlayItemTitle').textContent + elData(itemList, 'title', itemTitle); + } var callbackLink = this._showItemList.bind(this, item), wrapper; if (isLink) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/User.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/User.js index 4fb19468c1..e816776c88 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/User.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/User.js @@ -18,18 +18,6 @@ define(['Core', 'EventHandler', './Abstract'], function(Core, EventHandler, UiPa * Initializes the touch-friendly fullscreen user menu. */ init: function() { - // check if user menu is present, as it is absent when not logged-in - if (elById('pageUserMenuMobile') === null) { - elBySel('#pageHeader .userPanel').addEventListener(WCF_CLICK_EVENT, function(event) { - event.preventDefault(); - event.stopPropagation(); - - EventHandler.fire('com.woltlab.wcf.UserMenuMobile', 'showLogin'); - }); - - return; - } - UiPageMenuUser._super.prototype.init.call( this, 'com.woltlab.wcf.UserMenuMobile', @@ -47,7 +35,8 @@ define(['Core', 'EventHandler', './Abstract'], function(Core, EventHandler, UiPa */ _initItem: function(item) { // check if it should contain a 'more' link w/ an external callback - var more = elData(item.parentNode, 'more'); + var parent = item.parentNode; + var more = elData(parent, 'more'); if (more) { item.addEventListener(WCF_CLICK_EVENT, (function(event) { event.preventDefault(); @@ -55,7 +44,9 @@ define(['Core', 'EventHandler', './Abstract'], function(Core, EventHandler, UiPa EventHandler.fire(this._eventIdentifier, 'more', { handler: this, - identifier: more + identifier: more, + item: item, + parent: parent }); }).bind(this)); -- 2.20.1