Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parentLink option to drilldown #8060

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion js/foundation.drilldown.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
* @example '<\div class="is-drilldown"><\/div>'
*/
wrapper: '<div></div>',
/**
* Adds the parent link to the submenu.
* @option
* @example false
*/
parentLink: false,
/**
* Allow the menu to return to root list on body click.
* @option
Expand Down Expand Up @@ -84,6 +90,9 @@
this.$submenuAnchors.each(function(){
var $sub = $(this);
var $link = $sub.find('a:first');
if(_this.options.parentLink){
$link.clone().prependTo($sub.children('[data-submenu]')).wrap('<li class="is-submenu-parent-item is-submenu-item is-drilldown-submenu-item" role="menu-item"></li>');
}
$link.data('savedHref', $link.attr('href')).removeAttr('href');
$sub.children('[data-submenu]')
.attr({
Expand Down Expand Up @@ -305,7 +314,7 @@
this._hideAll();
Foundation.Nest.Burn(this.$element, 'drilldown');
this.$element.unwrap()
.find('.js-drilldown-back').remove()
.find('.js-drilldown-back, .is-submenu-parent-item').remove()
.end().find('.is-active, .is-closing, .is-drilldown-submenu').removeClass('is-active is-closing is-drilldown-submenu')
.end().find('[data-submenu]').removeAttr('aria-hidden tabindex role')
.off('.zf.drilldown').end().off('zf.drilldown');
Expand Down