]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: make Toggler target an option #10892 10952/head
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 17 Feb 2018 22:58:39 +0000 (23:58 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 17 Feb 2018 22:58:39 +0000 (23:58 +0100)
Related to: https://github.com/zurb/foundation-sites/issues/10892

js/foundation.toggler.js

index d8c5744ecab3a6875935723347039c4c498525e8..79609986315d639cd4da3f0de4364d68020ad4b5 100644 (file)
@@ -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