diff --git a/bower.json b/bower.json index 9d941df..727a69e 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "bootstrap-toggle", "description": "Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles", - "version": "2.2.1", + "version": "2.2.2", "keywords": [ "bootstrap", "toggle", diff --git a/css/bootstrap-toggle.css b/css/bootstrap-toggle.css index 057d08b..b9d590c 100644 --- a/css/bootstrap-toggle.css +++ b/css/bootstrap-toggle.css @@ -1,5 +1,5 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 + * Bootstrap Toggle: bootstrap-toggle.css v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company diff --git a/css/bootstrap-toggle.min.css b/css/bootstrap-toggle.min.css index 0d42ed0..9afc008 100644 --- a/css/bootstrap-toggle.min.css +++ b/css/bootstrap-toggle.min.css @@ -1,5 +1,5 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 + * Bootstrap Toggle: bootstrap-toggle.css v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company @@ -25,4 +25,4 @@ .toggle-off.btn-sm{padding-left:20px} .toggle.btn-xs{min-width:35px;min-height:22px} .toggle-on.btn-xs{padding-right:12px} -.toggle-off.btn-xs{padding-left:12px} \ No newline at end of file +.toggle-off.btn-xs{padding-left:12px} diff --git a/css/bootstrap2-toggle.css b/css/bootstrap2-toggle.css index 3f48927..9b8da63 100644 --- a/css/bootstrap2-toggle.css +++ b/css/bootstrap2-toggle.css @@ -1,5 +1,5 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap2-toggle.css v2.2.0 + * Bootstrap Toggle: bootstrap2-toggle.css v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company diff --git a/css/bootstrap2-toggle.min.css b/css/bootstrap2-toggle.min.css index 1509c57..cee70e9 100644 --- a/css/bootstrap2-toggle.min.css +++ b/css/bootstrap2-toggle.min.css @@ -1,5 +1,5 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap2-toggle.css v2.2.0 + * Bootstrap Toggle: bootstrap2-toggle.css v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company @@ -25,4 +25,4 @@ label.checkbox .toggle,label.checkbox.inline .toggle{margin-left:-20px;margin-ri .toggle-off.btn-small{padding-left:20px} .toggle.btn-mini{min-width:20px} .toggle-on.btn-mini{padding-right:12px} -.toggle-off.btn-mini{padding-left:12px} \ No newline at end of file +.toggle-off.btn-mini{padding-left:12px} diff --git a/index.html b/index.html index c255754..4fa849c 100644 --- a/index.html +++ b/index.html @@ -426,7 +426,7 @@

Animation Speed

Designed and built by Min Hur for The New York Times Company

-

Latest Version: 2.2.0 | Code licensed under MIT

+

Latest Version: 2.2.2 | Code licensed under MIT

@@ -446,4 +446,4 @@

Animation Speed

ga('send', 'pageview'); - \ No newline at end of file + diff --git a/js/bootstrap-toggle.js b/js/bootstrap-toggle.js index 533914e..5bc75fc 100644 --- a/js/bootstrap-toggle.js +++ b/js/bootstrap-toggle.js @@ -1,5 +1,5 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * Bootstrap Toggle: bootstrap-toggle.js v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company @@ -19,7 +19,7 @@ this.render() } - Toggle.VERSION = '2.2.0' + Toggle.VERSION = '2.2.2' Toggle.DEFAULTS = { on: 'On', @@ -75,6 +75,34 @@ var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2) var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight()) + function getOuterSize(obj) { + if ($(obj).length == 0) { + return false; + } + var clone = obj.clone(); + clone.css({ + visibility: "hidden", + width: "", + height: "", + maxWidth: "", + maxHeight: "" + }); + $("body").append(clone); + var width = clone.outerWidth(); + var height = clone.outerHeight(); + clone.remove(); + return { + width: width, + height: height + }; + } + if (width == 0 || height == 0) { + var toggleOnSize = getOuterSize($toggleOn); + var toggleOffSize = getOuterSize($toggleOff); + var toggleHandleSize = getOuterSize($toggleHandle); + width = this.options.width || Math.max(toggleOnSize.width, toggleOffSize.width) + toggleHandleSize.width / 2; + height = this.options.height || Math.max(toggleOnSize.height, toggleOffSize.height) + toggleHandleSize.height / 2; + } $toggleOn.addClass('toggle-on') $toggleOff.addClass('toggle-off') this.$toggle.css({ width: width, height: height }) @@ -178,3 +206,4 @@ }) }(jQuery); +// vim: set ts=8 sts=8 sw=8 noet sta : diff --git a/js/bootstrap-toggle.min.js b/js/bootstrap-toggle.min.js index 3711320..14aa1f8 100644 --- a/js/bootstrap-toggle.min.js +++ b/js/bootstrap-toggle.min.js @@ -1,9 +1,9 @@ /*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * Bootstrap Toggle: bootstrap-toggle.js v2.2.2 * http://www.bootstraptoggle.com * ======================================================================== * Copyright 2014 Min Hur, The New York Times Company * Licensed under MIT * ======================================================================== */ -+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('