vendor/assets/javascripts/base/_switch.js in active_frontend-14.0.77 vs vendor/assets/javascripts/base/_switch.js in active_frontend-14.0.78
- old
+ new
@@ -19,10 +19,12 @@
Switch.VERSION = '1.0.0';
Switch.DEFAULTS = {
baseClass: 'switch',
offClass: 'switch-color-light-haze',
onClass: 'switch-color-green',
+ onOffCallback: function () {},
+ onOnCallback: function () {},
text: {
off: '<i class="icon-cross"></i>',
on: '<i class="icon-checkmark"></i>'
}
};
@@ -69,19 +71,23 @@
this.$switch.removeClass('off');
this.$switch.addClass(this.options.onClass);
this.$element.prop('checked', true);
if (!silent) this.trigger();
+
+ this.options.onOnCallback();
};
Switch.prototype.off = function (silent) {
if (this.$element.prop('disabled')) return false;
this.$switch.removeClass(this.options.onClass);
this.$switch.addClass('off');
this.$element.prop('checked', false);
if (!silent) this.trigger();
+
+ this.options.onOffCallback();
};
Switch.prototype.enable = function () {
this.$element.prop('disabled', false);
this.$switch.removeAttr('disabled')