//import Util from './util' // Switch decorator, to be called after Input const Switch = (($) => { /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ const NAME = 'switch' const DATA_KEY = `mdb.${NAME}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Default = { template: `` } /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ */ class Switch { constructor(element, config) { this.$element = $(element) this.config = $.extend({}, Default, config) this.$element.after(this.config.template) } dispose() { $.removeData(this.$element, DATA_KEY) this.$element = null this.config = null } // ------------------------------------------------------------------------ // private // ------------------------------------------------------------------------ // static static _jQueryInterface(config) { return this.each(function () { let $element = $(this) let data = $element.data(DATA_KEY) if (!data) { data = new Switch(this, config) $element.data(DATA_KEY, data) } }) } } /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = Switch._jQueryInterface $.fn[NAME].Constructor = Switch $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT return Switch._jQueryInterface } return Switch })(jQuery) export default Switch