From 6547c8f4c35674ad0d71c5fbc751c8b55df1893b Mon Sep 17 00:00:00 2001 From: Foyster Date: Wed, 31 May 2017 10:34:48 +0100 Subject: [PATCH 1/2] Updated default button class to match change in Bootstrap 4 --- js/bootstrap4-toggle.js | 180 ++++++++++++++++++++++++++++++++ js/bootstrap4-toggle.min.js | 9 ++ js/bootstrap4-toggle.min.js.map | 1 + 3 files changed, 190 insertions(+) create mode 100644 js/bootstrap4-toggle.js create mode 100644 js/bootstrap4-toggle.min.js create mode 100644 js/bootstrap4-toggle.min.js.map diff --git a/js/bootstrap4-toggle.js b/js/bootstrap4-toggle.js new file mode 100644 index 0000000..2b144b9 --- /dev/null +++ b/js/bootstrap4-toggle.js @@ -0,0 +1,180 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ + + + +function ($) { + 'use strict'; + + // TOGGLE PUBLIC CLASS DEFINITION + // ============================== + + var Toggle = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, this.defaults(), options) + this.render() + } + + Toggle.VERSION = '2.2.0' + + Toggle.DEFAULTS = { + on: 'On', + off: 'Off', + onstyle: 'primary', + offstyle: 'secondary', + size: 'normal', + style: '', + width: null, + height: null + } + + Toggle.prototype.defaults = function() { + return { + on: this.$element.attr('data-on') || Toggle.DEFAULTS.on, + off: this.$element.attr('data-off') || Toggle.DEFAULTS.off, + onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle, + offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle, + size: this.$element.attr('data-size') || Toggle.DEFAULTS.size, + style: this.$element.attr('data-style') || Toggle.DEFAULTS.style, + width: this.$element.attr('data-width') || Toggle.DEFAULTS.width, + height: this.$element.attr('data-height') || Toggle.DEFAULTS.height + } + } + + Toggle.prototype.render = function () { + this._onstyle = 'btn-' + this.options.onstyle + this._offstyle = 'btn-' + this.options.offstyle + var size = this.options.size === 'large' ? 'btn-lg' + : this.options.size === 'small' ? 'btn-sm' + : this.options.size === 'mini' ? 'btn-xs' + : '' + var $toggleOn = $('