From 7fd8572eff7c7b908a6053495fe98986e8403f28 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 26 Feb 2016 16:40:15 +0100 Subject: [PATCH] User menu will open login instead for guests --- com.woltlab.wcf/templates/pageMenuMobile.tpl | 111 +++++++++--------- wcfsetup/install/files/js/WCF.User.js | 26 ++-- .../files/js/WoltLab/WCF/Ui/Page/Menu/User.js | 12 ++ 3 files changed, 84 insertions(+), 65 deletions(-) diff --git a/com.woltlab.wcf/templates/pageMenuMobile.tpl b/com.woltlab.wcf/templates/pageMenuMobile.tpl index d798e52e66..e9a388a800 100644 --- a/com.woltlab.wcf/templates/pageMenuMobile.tpl +++ b/com.woltlab.wcf/templates/pageMenuMobile.tpl @@ -74,62 +74,63 @@ {* user menu *} -{* TODO: guests should see the login overlay when clicking the button *} - + + {event name='userMenuItems'} + + + + + +{/if} diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index 5658d49c11..4c393c8ff5 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -570,26 +570,32 @@ WCF.User.QuickLogin = { * Initializes the quick login box */ init: function() { - require(['Ui/Dialog'], function(UiDialog) { + require(['EventHandler', 'Ui/Dialog'], function(EventHandler, UiDialog) { var loginForm = document.getElementById('loginForm'); + var callbackOpen = function(event) { + if (event instanceof Event) { + event.preventDefault(); + event.stopPropagation(); + } + + loginForm.style.removeProperty('display'); + + UiDialog.openStatic('loginForm', null, { + title: WCF.Language.get('wcf.user.login') + }); + }; var links = document.getElementsByClassName('loginLink'); for (var i = 0, length = links.length; i < length; i++) { - links[i].addEventListener('click', function(event) { - event.preventDefault(); - - loginForm.style.removeProperty('display'); - - UiDialog.openStatic('loginForm', null, { - title: WCF.Language.get('wcf.user.login') - }); - }); + links[i].addEventListener(WCF_CLICK_EVENT, callbackOpen); } var input = loginForm.querySelector('#loginForm input[name=url]'); if (input !== null) { input.setAttribute('value', window.location.protocol + '//' + window.location.host + input.getAttribute('value')); } + + EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'showLogin', callbackOpen); }); } }; 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 dfe75fb166..4fb19468c1 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,6 +18,18 @@ 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', -- 2.20.1