Skip to content

Commit 1b9a5eb

Browse files
Megamenu fixes
1 parent 6e8061e commit 1b9a5eb

File tree

5 files changed

+78
-24
lines changed

5 files changed

+78
-24
lines changed

astroid/astroid-framework/framework/menu.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public static function getMegaMenu($item, $options, $items) {
160160
$active_id = $active->id;
161161
$default_id = $default->id;
162162
$path = $base->tree;
163-
echo '<ul class="nav-submenu">';
163+
echo '<ul class="nav-submenu megamenu-submenu-level-1">';
164164
foreach ($items as $i => $subitem) {
165165
if ($subitem->id != $element['id']) {
166166
continue;
@@ -208,8 +208,11 @@ public static function getMegaMenuSubItems($parent, $listAll) {
208208
}
209209
$list[] = $item;
210210
}
211-
212-
echo '<ul class="nav-submenu">';
211+
if ($parent->level == 2 && ($parent->type == "heading" || $parent->type == "separator")) {
212+
echo '<ul class="nav-submenu-static d-block">';
213+
} else {
214+
echo '<ul class="nav-submenu">';
215+
}
213216
foreach ($list as $i => &$item) {
214217
$options = self::getAstroidMenuOptions($item, $list);
215218
$class = self::getLiClass($item, $options, $default_id, $active_id, $path);

astroid/astroid-template-zero/frontend/header/horizontal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$navWrapperClass = ['align-self-center', 'px-2', 'd-none', 'd-lg-block'];
3131
?>
3232
<!-- header starts -->
33-
<header data-megamenu data-megamenu-class=".has-megamenu" data-megamenu-content-class=".megamenu-container" data-dropdown-arrow="<?php echo $template->params->get('dropdown_arrow', 0) ? 'true' : 'false'; ?>" data-header-offset="true" data-transition-speed="<?php echo $template->params->get('dropdown_animation_speed', 300); ?>" data-animation="<?php echo $template->params->get('dropdown_animation_type', 'fade'); ?>" data-easing="<?php echo $template->params->get('dropdown_animation_ease', 'linear'); ?>" data-trigger="<?php echo $template->params->get('dropdown_trigger', 'hover'); ?>" data-megamenu-submenu-class=".nav-submenu" id="astroid-header" class="<?php echo implode(' ', $class); ?>">
33+
<header data-megamenu data-megamenu-class=".has-megamenu" data-megamenu-content-class=".megamenu-container" data-dropdown-arrow="<?php echo $template->params->get('dropdown_arrow', 0) ? 'true' : 'false'; ?>" data-header-offset="true" data-transition-speed="<?php echo $template->params->get('dropdown_animation_speed', 300); ?>" data-animation="<?php echo $template->params->get('dropdown_animation_type', 'fade'); ?>" data-easing="<?php echo $template->params->get('dropdown_animation_ease', 'linear'); ?>" data-trigger="<?php echo $template->params->get('dropdown_trigger', 'hover'); ?>" data-megamenu-submenu-class=".nav-submenu,.nav-submenu-static" id="astroid-header" class="<?php echo implode(' ', $class); ?>">
3434
<div class="d-flex flex-row justify-content-between">
3535
<?php if (!empty($header_mobile_menu)) { ?>
3636
<div class="d-flex d-lg-none justify-content-start">

astroid/astroid-template-zero/frontend/header/menu/link.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
$active = $params['active'];
2424
$header = @$params['header'];
2525
$is_mobile_menu = $params['mobilemenu'];
26+
if ($item->type == "heading") {
27+
$item->flink = 'javascript:void(0);';
28+
}
2629

2730
$attributes = [];
2831
if ($item->anchor_title) {
@@ -78,6 +81,9 @@
7881
//$item->flink = 'javascript:void(0);';
7982
}
8083

84+
$attributes['class'] .= " item-link-" . $item->type;
85+
$attributes['class'] .= " item-level-" . $item->level;
86+
8187
$attr = [];
8288
foreach ($attributes as $key => $attribute) {
8389
$attr[] = $key . '="' . $attribute . '"';
@@ -101,22 +107,22 @@
101107
<?php echo $item->title; ?>
102108
<?php } ?>
103109
<?php } ?>
104-
<?php if($options->badge) { ?>
105-
<?php if ($item->level == 1){ ?>
110+
<?php if ($options->badge) { ?>
111+
<?php if ($item->level == 1) { ?>
106112
<sup>
107113
<span class="menu-item-badge" style="background: <?php echo $options->badge_bgcolor ?>; color: <?php echo $options->badge_color ?> !important;">
108114
<?php echo $options->badge_text; ?>
109115
</span>
110116
</sup>
111-
<?php } else { ?>
117+
<?php } else { ?>
112118
<span class="menu-item-badge" style="background: <?php echo $options->badge_bgcolor ?> !important; color: <?php echo $options->badge_color ?>;">
113119
<?php echo $options->badge_text; ?>
114120
</span>
115121
<?php } ?>
116122
<?php } ?>
117123
<?php if (!$is_mobile_menu && $item->level == 1 && (($item->parent && $item->deeper == 1) || $options->megamenu)) { ?>
118124
<i class="fa fa-chevron-down nav-item-caret"></i>
119-
<?php } elseif (!$is_mobile_menu && $item->parent) { ?>
125+
<?php } elseif (!$is_mobile_menu && $item->parent && !($item->type == "heading" || $item->type == "separator")) { ?>
120126
<i class="fa fa-chevron-right nav-item-caret"></i>
121127
<?php } ?>
122128
</span>

astroid/astroid-template-zero/js/vendor/jquery.jdmegamenu.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@
4040
var _submenus = _megamenu.find(settings.submenuClass);
4141
_submenus.children('li').each(function () {
4242
if ($(this).children(settings.submenuClass).length) {
43-
$(this).unbind('mouseenter mouseleave').hover(function () {
44-
var _submenu = $(this).children(settings.submenuClass);
45-
_submenu.removeClass('right');
46-
_submenu.stop(true, true).slideDown();
47-
if (_submenu.offset().left + _submenu.outerWidth() > $(window).innerWidth()) {
48-
_submenu.addClass('right');
49-
} else {
43+
if (!$(this).children(settings.submenuClass).hasClass('d-block')) {
44+
45+
$(this).unbind('mouseenter mouseleave').hover(function () {
46+
var _submenu = $(this).children(settings.submenuClass);
5047
_submenu.removeClass('right');
51-
}
52-
}, function () {
53-
var _submenu = $(this).children(settings.submenuClass);
54-
_submenu.stop(true, true).slideUp();
55-
});
48+
_submenu.stop(true, true).slideDown();
49+
if (_submenu.offset().left + _submenu.outerWidth() > $(window).innerWidth()) {
50+
_submenu.addClass('right');
51+
} else {
52+
_submenu.removeClass('right');
53+
}
54+
}, function () {
55+
var _submenu = $(this).children(settings.submenuClass);
56+
_submenu.stop(true, true).slideUp();
57+
});
58+
}
5659
}
5760
});
5861

astroid/astroid-template-zero/scss/astroid/_menu.scss

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
.menu-item-badge{
1010
padding: 2px 7px;
11-
font-weight: normal;
12-
text-transform: none;
13-
line-height: 20px;
14-
font-size: 14px;
11+
font-weight: normal;
12+
text-transform: none;
13+
line-height: 20px;
14+
font-size: 14px;
1515
border-radius: 2px;
1616
}
1717

@@ -36,6 +36,48 @@
3636
flex-direction: column;
3737
border: 1px solid #eee;
3838
z-index: 9;
39+
&.megamenu-submenu-level-1{
40+
border: 0;
41+
}
42+
> li{
43+
padding: 0;
44+
position: relative;
45+
> a{
46+
text-decoration: none;
47+
display: block;
48+
padding: 10px 15px;
49+
&.item-link-heading,item-link-separator{
50+
&.item-level-2{
51+
text-transform: uppercase;
52+
border-bottom: 1px solid;
53+
&:hover{
54+
color: inherit !important;
55+
background: inherit !important;
56+
}
57+
}
58+
}
59+
}
60+
> .nav-submenu{
61+
position: absolute;
62+
top: 0;
63+
left: 100%;
64+
width: 100%;
65+
max-width: 300px;
66+
display: none;
67+
&.right{
68+
left: -100%;
69+
}
70+
}
71+
}
72+
}
73+
74+
.nav-submenu-static{
75+
margin: 0;
76+
padding: 0;
77+
list-style-type: none;
78+
display: flex;
79+
flex-direction: column;
80+
z-index: 9;
3981
> li{
4082
padding: 0;
4183
position: relative;

0 commit comments

Comments
 (0)