From 841055d4427d56c41fa9f2b409a4678fde256c04 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Fri, 4 Nov 2016 16:06:18 -0400 Subject: [PATCH] Add an option to the drilldown menu to position the back button at the top or bottom of a drilldown list --- js/foundation.drilldown.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/foundation.drilldown.js b/js/foundation.drilldown.js index feebac5c7..50fb0f6cb 100644 --- a/js/foundation.drilldown.js +++ b/js/foundation.drilldown.js @@ -85,7 +85,16 @@ class Drilldown { var $menu = $(this), $back = $menu.find('.js-drilldown-back'); if(!$back.length){ - $menu.prepend(_this.options.backButton); + switch (_this.options.backButtonPosition) { + case "bottom": + $menu.append(_this.options.backButton); + break; + case "top": + $menu.prepend(_this.options.backButton); + break; + default: + console.error("Unsupported backButtonPosition value '" + _this.options.backButtonPosition + "'"); + } } _this._back($menu); }); @@ -389,11 +398,17 @@ class Drilldown { Drilldown.defaults = { /** - * Markup used for JS generated back button. Prepended to submenu lists and deleted on `destroy` method, 'js-drilldown-back' class required. Remove the backslash (`\`) if copy and pasting. + * Markup used for JS generated back button. Prepended or appended (see backButtonPosition) to submenu lists and deleted on `destroy` method, 'js-drilldown-back' class required. Remove the backslash (`\`) if copy and pasting. * @option * @example '<\li><\a>Back<\/a><\/li>' */ backButton: '
  • Back
  • ', + /** + * Position the back button either at the top or bottom of drilldown submenus. + * @option + * @example bottom + */ + backButtonPosition: 'top', /** * Markup used to wrap drilldown menu. Use a class name for independent styling; the JS applied class: `is-drilldown` is required. Remove the backslash (`\`) if copy and pasting. * @option -- 2.47.2