mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix #3897: Top menu dropdown on mobile does not update active state
This commit is contained in:
parent
136e13ca59
commit
6a2a36da30
@ -7,6 +7,7 @@ HumHub Change Log
|
||||
- Fix #3893: New user invite headline broken in German translation
|
||||
- Enh: Updated translation files
|
||||
- Fix #3894: Pjax call does not does not release scroll body scroll lock when default swipe is active
|
||||
- Fix #3897: Top menu dropdown on mobile does not update active state
|
||||
|
||||
|
||||
1.4.2 (Februrary 27, 2020)
|
||||
|
@ -10,7 +10,7 @@ humhub.module('ui.navigation', function (module, require, $) {
|
||||
// Default implementation for topbar. Activate li on click.
|
||||
$('#top-menu-nav a').on('click', function () {
|
||||
var $this = $(this);
|
||||
if (!$this.is('#space-menu')) {
|
||||
if (!$this.is('#space-menu') && !$this.is('#top-dropdown-menu')) {
|
||||
module.setActiveItem($this);
|
||||
}
|
||||
});
|
||||
@ -32,11 +32,23 @@ humhub.module('ui.navigation', function (module, require, $) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(item && item.url) {
|
||||
module.setActiveItem($('#' + id).find('[href="' + item.url + '"]'));
|
||||
} else {
|
||||
if(!item) {
|
||||
module.setActiveItem(null);
|
||||
return;
|
||||
}
|
||||
|
||||
var $menu = $('#' + id);
|
||||
var $item = null;
|
||||
|
||||
if(item.id) {
|
||||
$item = $menu.find('[data-menu-id="'+item.id+'"]');
|
||||
}
|
||||
|
||||
if((!$item || !$item.length) && item.url) {
|
||||
$item = $menu.find('[href="' + item.url + '"]');
|
||||
}
|
||||
|
||||
module.setActiveItem($item);
|
||||
};
|
||||
|
||||
var setActiveItem = function ($item) {
|
||||
@ -45,9 +57,14 @@ humhub.module('ui.navigation', function (module, require, $) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item.closest('ul').find('li').removeClass('active');
|
||||
$item.closest('li').addClass('active');
|
||||
$item.trigger('blur');
|
||||
$item.each(function() {
|
||||
var $this = $(this);
|
||||
$this.closest('ul').find('li').removeClass('active');
|
||||
$this.closest('ul').find('a').removeClass('active');
|
||||
$this.closest('li').addClass('active');
|
||||
$this.addClass('active');
|
||||
$this.trigger('blur');
|
||||
});
|
||||
};
|
||||
|
||||
module.export({
|
||||
|
Loading…
x
Reference in New Issue
Block a user