User menu will open login instead for guests
authorAlexander Ebert <ebert@woltlab.com>
Fri, 26 Feb 2016 15:40:15 +0000 (16:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 26 Feb 2016 15:40:15 +0000 (16:40 +0100)
com.woltlab.wcf/templates/pageMenuMobile.tpl
wcfsetup/install/files/js/WCF.User.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/Menu/User.js

index d798e52e66319e00978f723d9753a4887a946932..e9a388a8008dd41192e65040b07d0e5075ba35ee 100644 (file)
 </div>
 
 {* user menu *}
-{* TODO: guests should see the login overlay when clicking the button *}
-<div id="pageUserMenuMobile" class="pageUserMenuMobile menuOverlayMobile" data-page-logo="{$__wcf->getPath()}images/default-logo.png">
-       <ol class="menuOverlayItemList" data-title="TODO: user menu">
-               <li class="menuOverlayTitle">{lang}wcf.user.controlPanel{/lang}</li>
-               <li class="menuOverlayItem">
-                       <a href="{link controller='User' object=$__wcf->user}{/link}" class="menuOverlayItemLink box24">
-                               {@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(24)}
-                               <span class="menuOverlayItemTitle">{$__wcf->user->username}</span>
-                       </a>
-               </li>
-               <li class="menuOverlayItem">
-                       <a href="{link controller='Settings'}{/link}" class="menuOverlayItemLink box24">
-                               <span class="icon icon24 fa-cog"></span>
-                               <span class="menuOverlayItemTitle">Einstellungen</span>
-                       </a>
-                       <ol class="menuOverlayItemList">
-                               {foreach from=$__wcf->getUserMenu()->getMenuItems('') item=menuCategory}
-                                       <li class="menuOverlayTitle">{lang}{$menuCategory->menuItem}{/lang}</li>
-                                       {foreach from=$__wcf->getUserMenu()->getMenuItems($menuCategory->menuItem) item=menuItem}
-                                               <li class="menuOverlayItem">
-                                                       <a href="{$menuItem->getProcessor()->getLink()}" class="menuOverlayItemLink">{@$menuItem}</a>
-                                               </li>
+{if $__wcf->user->userID}
+       <div id="pageUserMenuMobile" class="pageUserMenuMobile menuOverlayMobile" data-page-logo="{$__wcf->getPath()}images/default-logo.png">
+               <ol class="menuOverlayItemList" data-title="TODO: user menu">
+                       <li class="menuOverlayTitle">{lang}wcf.user.controlPanel{/lang}</li>
+                       <li class="menuOverlayItem">
+                               <a href="{link controller='User' object=$__wcf->user}{/link}" class="menuOverlayItemLink box24">
+                                       {@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(24)}
+                                       <span class="menuOverlayItemTitle">{$__wcf->user->username}</span>
+                               </a>
+                       </li>
+                       <li class="menuOverlayItem">
+                               <a href="{link controller='Settings'}{/link}" class="menuOverlayItemLink box24">
+                                       <span class="icon icon24 fa-cog"></span>
+                                       <span class="menuOverlayItemTitle">Einstellungen</span>
+                               </a>
+                               <ol class="menuOverlayItemList">
+                                       {foreach from=$__wcf->getUserMenu()->getMenuItems('') item=menuCategory}
+                                               <li class="menuOverlayTitle">{lang}{$menuCategory->menuItem}{/lang}</li>
+                                               {foreach from=$__wcf->getUserMenu()->getMenuItems($menuCategory->menuItem) item=menuItem}
+                                                       <li class="menuOverlayItem">
+                                                               <a href="{$menuItem->getProcessor()->getLink()}" class="menuOverlayItemLink">{@$menuItem}</a>
+                                                       </li>
+                                               {/foreach}
                                        {/foreach}
-                               {/foreach}
-                       </ol>
-               </li>
-               {if $__wcf->session->getPermission('admin.general.canUseAcp')}
+                               </ol>
+                       </li>
+                       {if $__wcf->session->getPermission('admin.general.canUseAcp')}
+                               <li class="menuOverlayItem">
+                                       <a href="{link isACP=true}{/link}" class="menuOverlayItemLink box24">
+                                               <span class="icon icon24 fa-wrench"></span>
+                                               <span class="menuOverlayItemTitle">{lang}wcf.global.acp.short{/lang}</span>
+                                       </a>
+                               </li>
+                       {/if}
+                       <li class="menuOverlayItemSpacer"></li>
+                       <li class="menuOverlayItem" data-more="com.woltlab.wcf.notifications">
+                               <a href="{link controller='NotificationList'}{/link}" class="menuOverlayItemLink box24">
+                                       <span class="icon icon24 fa-bell-o"></span>
+                                       <span class="menuOverlayItemTitle">{lang}wcf.user.notification.notifications{/lang}</span>
+                               </a>
+                       </li>
                        <li class="menuOverlayItem">
-                               <a href="{link isACP=true}{/link}" class="menuOverlayItemLink box24">
-                                       <span class="icon icon24 fa-wrench"></span>
-                                       <span class="menuOverlayItemTitle">{lang}wcf.global.acp.short{/lang}</span>
+                               <a href="#" class="menuOverlayItemLink box24">
+                                       <span class="icon icon24 fa-exclamation-triangle"></span>
+                                       <span class="menuOverlayItemTitle">{lang}wcf.moderation.moderation{/lang}</span>
                                </a>
                        </li>
-               {/if}
-               <li class="menuOverlayItemSpacer"></li>
-               <li class="menuOverlayItem" data-more="com.woltlab.wcf.notifications">
-                       <a href="{link controller='NotificationList'}{/link}" class="menuOverlayItemLink box24">
-                               <span class="icon icon24 fa-bell-o"></span>
-                               <span class="menuOverlayItemTitle">{lang}wcf.user.notification.notifications{/lang}</span>
-                       </a>
-               </li>
-               <li class="menuOverlayItem">
-                       <a href="#" class="menuOverlayItemLink box24">
-                               <span class="icon icon24 fa-exclamation-triangle"></span>
-                               <span class="menuOverlayItemTitle">{lang}wcf.moderation.moderation{/lang}</span>
-                       </a>
-               </li>
-               
-               {event name='userMenuItems'}
-               
-               <li class="menuOverlayItemSpacer"></li>
-               <li class="menuOverlayItem">
-                       <a href="{link controller='Logout'}t={@SECURITY_TOKEN}{/link}" class="menuOverlayItemLink box24">
-                               <span class="icon icon24 fa-sign-out"></span>
-                               <span class="menuOverlayItemTitle">{lang}wcf.user.logout{/lang}</span>
-                       </a>
-               </li>
-       </ol>
-</div>
+                       
+                       {event name='userMenuItems'}
+                       
+                       <li class="menuOverlayItemSpacer"></li>
+                       <li class="menuOverlayItem">
+                               <a href="{link controller='Logout'}t={@SECURITY_TOKEN}{/link}" class="menuOverlayItemLink box24">
+                                       <span class="icon icon24 fa-sign-out"></span>
+                                       <span class="menuOverlayItemTitle">{lang}wcf.user.logout{/lang}</span>
+                               </a>
+                       </li>
+               </ol>
+       </div>
+{/if}
index 5658d49c1155e6a8c686f3322e619e8fdc80dd26..4c393c8ff57aae31fd25be53aed76c0d04baf347 100644 (file)
@@ -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);
                });
        }
 };
index dfe75fb166b2d6fb950de9d1e1640b5914cc4e7f..4fb19468c1dabf78fbecca8a9af12c5a5823767f 100644 (file)
@@ -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',