Skip to content

Commit

Permalink
fix(component): megamenu
Browse files Browse the repository at this point in the history
open one collapse closes others
  • Loading branch information
ygatesoupe committed Feb 14, 2017
1 parent 90ba25a commit 249088f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs-orange/examples/orange-news/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,18 @@
</div>
</div>
</li>
<li class="nav-item"><a class="nav-link collapsed" href="" data-toggle="collapse">Discover</a></li>
<li class="nav-item">
<a class="nav-link collapsed" href="#mega_level_2_collapse" data-toggle="collapse">Discover</a>
<div class="mega-menu-panel collapse" id="mega_level_2_collapse">
<div class="container">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="">Test 1</a>
</li>
</ul>
</div>
</div>
</li>
<li class="nav-item"><a class="nav-link collapsed" href="" data-toggle="collapse">My Orange</a></li>
</ul>
</div>
Expand Down
9 changes: 9 additions & 0 deletions js/src/o-megamenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const MegaMenu = (($) => {
this._$goForwardLinks = $(this._element).find(Selector.MEGAMENU_NAV).prev(Selector.NAV_LINK)
this._$goBackLinks = $(this._element).find(Selector.NAV_LINK_BACK)
this._$topCollapseMenus = $(this._element).find(Selector.MEGAMENU_PANEL)
this._$navLinkCollapses = $(this._element).find(Selector.NAV_LINK_COLLAPSE)
this._addEventListeners()
this._addAriaAttributes(this._element)
}
Expand All @@ -85,6 +86,7 @@ const MegaMenu = (($) => {
this._$goBackLinks.on('click', (event) => this._goBackward(event))
this._$navLinks.on('keydown', (event) => this._manageKeyDown(event))
this._$topCollapseMenus.on('shown.bs.collapse', this._collapseFocus)
this._$navLinkCollapses.on('click', (event) => this._handleCollapseToggle(event))
}

_addAriaAttributes(element) {
Expand Down Expand Up @@ -148,6 +150,13 @@ const MegaMenu = (($) => {
$(this).find(Selector.NAV_LINK).not(Selector.NAV_LINK_BACK).first().trigger('focus')
}

_handleCollapseToggle(e){
const $this = $(e.target)
const $thisCollapse = $($this.attr('href'))

this._$topCollapseMenus.not($thisCollapse).collapse('hide')
}

_goForward(e) {
e.preventDefault();
const $this = $(e.target)
Expand Down

0 comments on commit 249088f

Please sign in to comment.