From a0a9b20a58dc99b84743c42183a17bc909106924 Mon Sep 17 00:00:00 2001 From: Brett Mason Date: Tue, 16 Feb 2016 19:10:24 +0000 Subject: [PATCH] Add drilldown parent link option. If set to true this prepend's the parent link to the submenu. --- js/foundation.drilldown.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/foundation.drilldown.js b/js/foundation.drilldown.js index 88be96084..55ad35c4b 100644 --- a/js/foundation.drilldown.js +++ b/js/foundation.drilldown.js @@ -68,6 +68,9 @@ class Drilldown { 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('
  • '); + } $link.data('savedHref', $link.attr('href')).removeAttr('href'); $sub.children('[data-submenu]') .attr({ @@ -295,7 +298,7 @@ class Drilldown { 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'); @@ -322,6 +325,12 @@ Drilldown.defaults = { * @example '<\div class="is-drilldown"><\/div>' */ wrapper: '
    ', + /** + * Adds the parent link to the submenu. + * @option + * @example false + */ + parentLink: false, /** * Allow the menu to return to root list on body click. * @option -- 2.47.2