vendor/assets/js/foundation.toggler.js.es6 in foundation-rails-6.3.1.0 vs vendor/assets/js/foundation.toggler.js.es6 in foundation-rails-6.4.1.0

- old
+ new

@@ -1,33 +1,39 @@ 'use strict'; -!function($) { +import $ from 'jquery'; +import { Motion } from './foundation.util.motion'; +import { Plugin } from './foundation.plugin'; +import { Triggers } from './foundation.util.triggers'; /** * Toggler module. * @module foundation.toggler * @requires foundation.util.motion * @requires foundation.util.triggers */ -class Toggler { +class Toggler extends Plugin { /** * Creates a new instance of Toggler. * @class + * @name Toggler * @fires Toggler#init * @param {Object} element - jQuery object to add the trigger to. * @param {Object} options - Overrides to the default plugin settings. */ - constructor(element, options) { + _setup(element, options) { this.$element = element; this.options = $.extend({}, Toggler.defaults, element.data(), options); this.className = ''; + this.className = 'Toggler'; // ie9 back compat + // Triggers init is idempotent, just need to make sure it is initialized + Triggers.init($); + this._init(); this._events(); - - Foundation.registerPlugin(this, 'Toggler'); } /** * Initializes the Toggler plugin by parsing the toggle class from data-toggler, or animation classes from data-animate. * @function @@ -101,18 +107,18 @@ _toggleAnimate() { var _this = this; if (this.$element.is(':hidden')) { - Foundation.Motion.animateIn(this.$element, this.animationIn, function() { + Motion.animateIn(this.$element, this.animationIn, function() { _this._updateARIA(true); this.trigger('on.zf.toggler'); this.find('[data-mutate]').trigger('mutateme.zf.trigger'); }); } else { - Foundation.Motion.animateOut(this.$element, this.animationOut, function() { + Motion.animateOut(this.$element, this.animationOut, function() { _this._updateARIA(false); this.trigger('off.zf.toggler'); this.find('[data-mutate]').trigger('mutateme.zf.trigger'); }); } @@ -124,13 +130,12 @@ /** * Destroys the instance of Toggler on the element. * @function */ - destroy() { + _destroy() { this.$element.off('.zf.toggler'); - Foundation.unregisterPlugin(this); } } Toggler.defaults = { /** @@ -140,9 +145,6 @@ * @default false */ animate: false }; -// Window exports -Foundation.plugin(Toggler, 'Toggler'); - -}(jQuery); +export {Toggler};