{if $__wcf->getLanguage()->getLanguages()|count > 1}
<li id="pageLanguageContainer">
<script data-relocate="true">
- require(['WoltLab/WCF/Language/Chooser'], function(LanguageChooser) {
+ require(['EventHandler', 'WoltLab/WCF/Language/Chooser'], function(EventHandler, LanguageChooser) {
var languages = {
{implode from=$__wcf->getLanguage()->getLanguages() item=__language}
'{@$__language->languageID}': {
{/implode}
};
- LanguageChooser.init('pageLanguageContainer', 'languageID', {@$__wcf->getLanguage()->languageID}, languages, function(listItem) {
+ var callback = function(listItem) {
var location = window.location.toString().replace(/#.*/, '').replace(/(\?|&)l=[0-9]+/g, '');
var delimiter = (location.indexOf('?') == -1) ? '?' : '&';
window.location = location + delimiter + 'l=' + elData(listItem, 'language-id') + window.location.hash;
+ };
+
+ LanguageChooser.init('pageLanguageContainer', 'languageID', {@$__wcf->getLanguage()->languageID}, languages, callback);
+ EventHandler.add('com.woltlab.wcf.UserMenuMobile', 'more', function(data) {
+ if (data.identifier === 'com.woltlab.wcf.language') {
+ callback(data.parent);
+ }
});
});
</script>
</div>
{* user menu *}
-{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">
+<div id="pageUserMenuMobile" class="pageUserMenuMobile menuOverlayMobile" data-page-logo="{$__wcf->getPath()}images/default-logo.png">
+ <ol class="menuOverlayItemList" data-title="TODO: user menu">
+ {if $__wcf->user->userID}
+ {* logged-in *}
<li class="menuOverlayTitle">{lang}wcf.user.controlPanel{/lang}</li>
<li class="menuOverlayItem">
<a href="{link controller='User' object=$__wcf->user}{/link}" class="menuOverlayItemLink box24">
<span class="menuOverlayItemTitle">{lang}wcf.user.notification.notifications{/lang}</span>
</a>
</li>
- <li class="menuOverlayItem">
+ <li class="menuOverlayItem" data-more="com.woltlab.wcf.moderation">
<a href="#" class="menuOverlayItemLink box24">
<span class="icon icon24 fa-exclamation-triangle"></span>
<span class="menuOverlayItemTitle">{lang}wcf.moderation.moderation{/lang}</span>
<span class="menuOverlayItemTitle">{lang}wcf.user.logout{/lang}</span>
</a>
</li>
- </ol>
- </div>
-{/if}
+ {else}
+ {* guest *}
+ <li class="menuOverlayTitle">TODO: user menu</li>
+ <li class="menuOverlayItem" data-more="com.woltlab.wcf.login">
+ <a href="#" class="menuOverlayItemLink box24">
+ <span class="icon icon24 fa-sign-in"></span>
+ <span class="menuOverlayItemTitle">{lang}wcf.user.login{/lang}</span>
+ </a>
+ </li>
+ <li class="menuOverlayItem">
+ <a href="{link controller='Register'}{/link}" class="menuOverlayItemLink box24">
+ <span class="icon icon24 fa-asterisk"></span>
+ <span class="menuOverlayItemTitle">{lang}wcf.user.register{/lang}</span>
+ </a>
+ </li>
+
+ {event name='guestUserMenuItems'}
+
+ {if $__wcf->getLanguage()->getLanguages()|count > 1}
+ <li class="menuOverlayItemSpacer"></li>
+ <li class="menuOverlayTitle">{lang}wcf.user.language{/lang}</li>
+ <li class="menuOverlayItem">
+ <a href="#" class="menuOverlayItemLink box24">
+ <img src="{$__wcf->getLanguage()->getIconPath()}">
+ <span class="menuOverlayItemTitle">{$__wcf->getLanguage()}</span>
+ </a>
+ <ol class="menuOverlayItemList" data-title="{lang}wcf.user.language{/lang}">
+ {foreach from=$__wcf->getLanguage()->getLanguages() item=__language}
+ <li class="menuOverlayItem" data-more="com.woltlab.wcf.language" data-language-id="{@$__language->languageID}">
+ <a href="#" class="menuOverlayItemLink box24">
+ <img src="{$__language->getIconPath()}">
+ <span class="menuOverlayItemTitle">{$__language}</span>
+ </a>
+ </li>
+ {/foreach}
+ </ol>
+ </li>
+ {/if}
+ {/if}
+ </ol>
+</div>
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();
+ }
+ });
});
}
};
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) {
* 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',
*/
_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();
EventHandler.fire(this._eventIdentifier, 'more', {
handler: this,
- identifier: more
+ identifier: more,
+ item: item,
+ parent: parent
});
}).bind(this));