From: Nicolas Coden Date: Sat, 17 Feb 2018 22:58:39 +0000 (+0100) Subject: fix: make Toggler target an option #10892 X-Git-Tag: v6.6.0~3^2~269^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=630cf4ccb80c839a5983fdba901434a9ff427d6c;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fix: make Toggler target an option #10892 Related to: https://github.com/zurb/foundation-sites/issues/10892 --- diff --git a/js/foundation.toggler.js b/js/foundation.toggler.js index d8c5744ec..796099863 100644 --- a/js/foundation.toggler.js +++ b/js/foundation.toggler.js @@ -50,7 +50,10 @@ class Toggler extends Plugin { } // Otherwise, parse toggle class else { - input = this.$element.data('toggler'); + input = this.options.toggler; + if (typeof input !== 'string' || !input.length) { + throw new Error(`The 'toogler' option containing the target class is required, got "${input}"`); + } // Allow for a . at the beginning of the string this.className = input[0] === '.' ? input.slice(1) : input; } @@ -138,6 +141,12 @@ class Toggler extends Plugin { } Toggler.defaults = { + /** + * Class of the element to toggle. It can be provided with or without "." + * @option + * @type {string} + */ + toggler: undefined, /** * Tells the plugin if the element should animated when toggled. * @option