From 453e74fe042c4fb4877abdc346e0f37804a49b0c Mon Sep 17 00:00:00 2001 From: Manuel van Rijn Date: Mon, 27 Oct 2014 15:05:54 +0100 Subject: [PATCH] updated assets to v3.1.0 --- README.md | 1 + lib/bootstrap-switch-rails/version.rb | 2 +- vendor/assets/javascripts/bootstrap-switch.js | 77 +++++++++-- .../stylesheets/bootstrap2-switch.css.scss | 124 +++++++++++------- .../stylesheets/bootstrap3-switch.css.scss | 77 ++++++----- 5 files changed, 192 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 31b7378..e76f8c8 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ See the [demo page of Mattia Larentis](http://www.bootstrap-switch.org/) for exa | Version | Notes | | -------:| ----------------------------------------------------------------------------------- | +| 3.1.2 | Update to v3.1.2 of the bootstrap-switch plugin | | 3.0.2 | Update to v3.0.2 of the bootstrap-switch plugin | | 3.0.0 | Update to v3.0.0 of the bootstrap-switch plugin | | 2.0.2 | Fixed issue where bootstrap 2 sass wasn't compiling (issue #7) | diff --git a/lib/bootstrap-switch-rails/version.rb b/lib/bootstrap-switch-rails/version.rb index c87ea27..e3eafaa 100644 --- a/lib/bootstrap-switch-rails/version.rb +++ b/lib/bootstrap-switch-rails/version.rb @@ -1,7 +1,7 @@ module Bootstrap module Switch module Rails - VERSION = "3.0.2" + VERSION = "3.1.0" end end end diff --git a/vendor/assets/javascripts/bootstrap-switch.js b/vendor/assets/javascripts/bootstrap-switch.js index 778a25b..453588c 100644 --- a/vendor/assets/javascripts/bootstrap-switch.js +++ b/vendor/assets/javascripts/bootstrap-switch.js @@ -1,5 +1,5 @@ /* ======================================================================== - * bootstrap-switch - v3.0.2 + * bootstrap-switch - v3.1.0 * http://www.bootstrap-switch.org * ======================================================================== * Copyright 2012-2013 Mattia Larentis @@ -38,14 +38,15 @@ disabled: this.$element.is(":disabled"), readonly: this.$element.is("[readonly]"), indeterminate: this.$element.data("indeterminate"), + inverse: this.$element.data("inverse"), + radioAllOff: this.$element.data("radio-all-off"), onColor: this.$element.data("on-color"), offColor: this.$element.data("off-color"), onText: this.$element.data("on-text"), offText: this.$element.data("off-text"), labelText: this.$element.data("label-text"), baseClass: this.$element.data("base-class"), - wrapperClass: this.$element.data("wrapper-class"), - radioAllOff: this.$element.data("radio-all-off") + wrapperClass: this.$element.data("wrapper-class") }, options); this.$wrapper = $("
", { "class": (function(_this) { @@ -68,6 +69,9 @@ if (_this.options.indeterminate) { classes.push("" + _this.options.baseClass + "-indeterminate"); } + if (_this.options.inverse) { + classes.push("" + _this.options.baseClass + "-inverse"); + } if (_this.$element.attr("id")) { classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id"))); } @@ -105,7 +109,7 @@ })(this)); this.$container = this.$element.wrap(this.$container).parent(); this.$wrapper = this.$container.wrap(this.$wrapper).parent(); - this.$element.before(this.$on).before(this.$label).before(this.$off).trigger("init.bootstrapSwitch"); + this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off).trigger("init.bootstrapSwitch"); this._elementHandlers(); this._handleHandlers(); this._labelHandlers(); @@ -118,22 +122,32 @@ if (typeof value === "undefined") { return this.options.state; } - if (this.options.disabled || this.options.readonly || this.options.indeterminate) { + if (this.options.disabled || this.options.readonly) { return this.$element; } if (this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) { return this.$element; } - value = !!value; + if (this.options.indeterminate) { + this.indeterminate(false); + value = true; + } else { + value = !!value; + } this.$element.prop("checked", value).trigger("change.bootstrapSwitch", skip); return this.$element; }; BootstrapSwitch.prototype.toggleState = function(skip) { - if (this.options.disabled || this.options.readonly || this.options.indeterminate) { + if (this.options.disabled || this.options.readonly) { return this.$element; } - return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip); + if (this.options.indeterminate) { + this.indeterminate(false); + return this.state(true); + } else { + return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip); + } }; BootstrapSwitch.prototype.size = function(value) { @@ -160,6 +174,12 @@ return this.$element; }; + BootstrapSwitch.prototype.toggleAnimate = function() { + this.$wrapper.toggleClass("" + this.options.baseClass + "-animate"); + this.options.animate = !this.options.animate; + return this.$element; + }; + BootstrapSwitch.prototype.disabled = function(value) { if (typeof value === "undefined") { return this.options.disabled; @@ -214,6 +234,36 @@ return this.$element; }; + BootstrapSwitch.prototype.inverse = function(value) { + var $off, $on; + if (typeof value === "undefined") { + return this.options.inverse; + } + value = !!value; + this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-inverse"); + $on = this.$on.clone(true); + $off = this.$off.clone(true); + this.$on.replaceWith($off); + this.$off.replaceWith($on); + this.$on = $off; + this.$off = $on; + this.options.inverse = value; + return this.$element; + }; + + BootstrapSwitch.prototype.toggleInverse = function() { + var $off, $on; + this.$wrapper.toggleClass("" + this.options.baseClass + "-inverse"); + $on = this.$on.clone(true); + $off = this.$off.clone(true); + this.$on.replaceWith($off); + this.$off.replaceWith($on); + this.$on = $off; + this.$off = $on; + this.options.inverse = !this.options.inverse; + return this.$element; + }; + BootstrapSwitch.prototype.onColor = function(value) { var color; color = this.options.onColor; @@ -362,7 +412,7 @@ })(this), "keydown.bootstrapSwitch": (function(_this) { return function(e) { - if (!e.which || _this.options.disabled || _this.options.readonly || _this.options.indeterminate) { + if (!e.which || _this.options.disabled || _this.options.readonly) { return; } switch (e.which) { @@ -423,7 +473,7 @@ })(this), "mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (function(_this) { return function(e) { - if (_this.isLabelDragging || _this.options.disabled || _this.options.readonly || _this.options.indeterminate) { + if (_this.isLabelDragging || _this.options.disabled || _this.options.readonly) { return; } e.preventDefault(); @@ -433,13 +483,15 @@ })(this), "mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) { return function(e) { + var state; if (!_this.isLabelDragging) { return; } e.preventDefault(); if (_this.isLabelDragged) { + state = parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6); _this.isLabelDragged = false; - _this.state(parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6)); + _this.state(_this.options.inverse ? !state : state); if (_this.options.animate) { _this.$wrapper.addClass("" + _this.options.baseClass + "-animate"); } @@ -516,6 +568,8 @@ disabled: false, readonly: false, indeterminate: false, + inverse: false, + radioAllOff: false, onColor: "primary", offColor: "default", onText: "ON", @@ -523,7 +577,6 @@ labelText: " ", baseClass: "bootstrap-switch", wrapperClass: "wrapper", - radioAllOff: false, onInit: function() {}, onSwitchChange: function() {} }; diff --git a/vendor/assets/stylesheets/bootstrap2-switch.css.scss b/vendor/assets/stylesheets/bootstrap2-switch.css.scss index 8cd5fa4..28fd0fc 100644 --- a/vendor/assets/stylesheets/bootstrap2-switch.css.scss +++ b/vendor/assets/stylesheets/bootstrap2-switch.css.scss @@ -1,5 +1,5 @@ /* ======================================================================== - * bootstrap-switch - v3.0.2 + * bootstrap-switch - v3.1.0 * http://www.bootstrap-switch.org * ======================================================================== * Copyright 2012-2013 Mattia Larentis @@ -103,16 +103,37 @@ font-size: 16px; line-height: normal; } +.bootstrap-switch.bootstrap-switch-disabled, +.bootstrap-switch.bootstrap-switch-readonly, +.bootstrap-switch.bootstrap-switch-indeterminate { + opacity: 0.5; + filter: alpha(opacity=50); + cursor: default !important; +} +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on, +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off, +.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label { + cursor: default !important; +} .bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container { -webkit-transition: margin-left 0.5s; -moz-transition: margin-left 0.5s; -o-transition: margin-left 0.5s; transition: margin-left 0.5s; } -.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container { - margin-left: 0%; -} -.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label { +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on { + -webkit-border-top-left-radius: 0; + -moz-border-radius-topleft: 0; + border-top-left-radius: 0; + -webkit-border-bottom-left-radius: 0; + -moz-border-radius-bottomleft: 0; + border-bottom-left-radius: 0; -webkit-border-top-right-radius: 4px; -moz-border-radius-topright: 4px; border-top-right-radius: 4px; @@ -120,10 +141,13 @@ -moz-border-radius-bottomright: 4px; border-bottom-right-radius: 4px; } -.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container { - margin-left: -50%; -} -.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label { +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off { + -webkit-border-top-right-radius: 0; + -moz-border-radius-topright: 0; + border-top-right-radius: 0; + -webkit-border-bottom-right-radius: 0; + -moz-border-radius-bottomright: 0; + border-bottom-right-radius: 0; -webkit-border-top-left-radius: 4px; -moz-border-radius-topleft: 4px; border-top-left-radius: 4px; @@ -131,27 +155,6 @@ -moz-border-radius-bottomleft: 4px; border-bottom-left-radius: 4px; } -.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container { - margin-left: -25%; -} -.bootstrap-switch.bootstrap-switch-disabled, -.bootstrap-switch.bootstrap-switch-readonly, -.bootstrap-switch.bootstrap-switch-indeterminate { - opacity: 0.5; - filter: alpha(opacity=50); - cursor: default !important; -} -.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on, -.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on, -.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on, -.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off, -.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off, -.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off, -.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label, -.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label, -.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label { - cursor: default !important; -} .bootstrap-switch.bootstrap-switch-focused { border-color: rgba(82, 168, 236, 0.8); outline: 0; @@ -160,6 +163,35 @@ -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82, 168, 236, .6); box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82, 168, 236, .6); } +.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-container { + margin-left: 0%; +} +.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label { + -webkit-border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -moz-border-radius-bottomright: 4px; + border-bottom-right-radius: 4px; +} +.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-container { + margin-left: -50%; +} +.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label { + -webkit-border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; + border-top-left-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + border-bottom-left-radius: 4px; +} +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container { + margin-left: -25%; +} .bootstrap-switch .bootstrap-switch-container { display: inline-block; width: 150%; @@ -432,22 +464,6 @@ .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default.active { background-color: #e6e6e6 \9; } -.bootstrap-switch .bootstrap-switch-handle-on { - -webkit-border-top-left-radius: 4px; - -moz-border-radius-topleft: 4px; - border-top-left-radius: 4px; - -webkit-border-bottom-left-radius: 4px; - -moz-border-radius-bottomleft: 4px; - border-bottom-left-radius: 4px; -} -.bootstrap-switch .bootstrap-switch-handle-off { - -webkit-border-top-right-radius: 4px; - -moz-border-radius-topright: 4px; - border-top-right-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -moz-border-radius-bottomright: 4px; - border-bottom-right-radius: 4px; -} .bootstrap-switch .bootstrap-switch-label { text-align: center; margin-top: -1px; @@ -486,6 +502,22 @@ .bootstrap-switch .bootstrap-switch-label.active { background-color: #cccccc \9; } +.bootstrap-switch .bootstrap-switch-handle-on { + -webkit-border-top-left-radius: 4px; + -moz-border-radius-topleft: 4px; + border-top-left-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + -moz-border-radius-bottomleft: 4px; + border-bottom-left-radius: 4px; +} +.bootstrap-switch .bootstrap-switch-handle-off { + -webkit-border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; + border-top-right-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -moz-border-radius-bottomright: 4px; + border-bottom-right-radius: 4px; +} .bootstrap-switch input[type='radio'], .bootstrap-switch input[type='checkbox'] { position: absolute !important; diff --git a/vendor/assets/stylesheets/bootstrap3-switch.css.scss b/vendor/assets/stylesheets/bootstrap3-switch.css.scss index 8e9b762..7969bea 100644 --- a/vendor/assets/stylesheets/bootstrap3-switch.css.scss +++ b/vendor/assets/stylesheets/bootstrap3-switch.css.scss @@ -1,5 +1,5 @@ /* ======================================================================== - * bootstrap-switch - v3.0.2 + * bootstrap-switch - v3.1.0 * http://www.bootstrap-switch.org * ======================================================================== * Copyright 2012-2013 Mattia Larentis @@ -71,27 +71,6 @@ font-size: 16px; line-height: normal; } -.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container { - -webkit-transition: margin-left 0.5s; - transition: margin-left 0.5s; -} -.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container { - margin-left: 0%; -} -.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} -.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container { - margin-left: -50%; -} -.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} -.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container { - margin-left: -25%; -} .bootstrap-switch.bootstrap-switch-disabled, .bootstrap-switch.bootstrap-switch-readonly, .bootstrap-switch.bootstrap-switch-indeterminate { @@ -110,12 +89,50 @@ .bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label { cursor: default !important; } +.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container { + -webkit-transition: margin-left 0.5s; + transition: margin-left 0.5s; +} +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on { + border-bottom-left-radius: 0; + border-top-left-radius: 0; + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off { + border-bottom-right-radius: 0; + border-top-right-radius: 0; + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} .bootstrap-switch.bootstrap-switch-focused { border-color: #66afe9; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); } +.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-container { + margin-left: 0%; +} +.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-container { + margin-left: -50%; +} +.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} +.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container, +.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-indeterminate .bootstrap-switch-container { + margin-left: -25%; +} .bootstrap-switch .bootstrap-switch-container { display: inline-block; width: 150%; @@ -174,14 +191,6 @@ color: #000; background: #eeeeee; } -.bootstrap-switch .bootstrap-switch-handle-on { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} -.bootstrap-switch .bootstrap-switch-handle-off { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} .bootstrap-switch .bootstrap-switch-label { text-align: center; margin-top: -1px; @@ -191,6 +200,14 @@ color: #333333; background: #ffffff; } +.bootstrap-switch .bootstrap-switch-handle-on { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} +.bootstrap-switch .bootstrap-switch-handle-off { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} .bootstrap-switch input[type='radio'], .bootstrap-switch input[type='checkbox'] { position: absolute !important;