app/assets/javascripts/twitter/bootstrap/button.js in twitter-bootswatch-rails-3.0.2.0 vs app/assets/javascripts/twitter/bootstrap/button.js in twitter-bootswatch-rails-3.0.3.0

- old
+ new

@@ -1,7 +1,7 @@ /* ======================================================================== - * Bootstrap: button.js v3.0.2 + * Bootstrap: button.js v3.0.3 * http://getbootstrap.com/javascript/#buttons * ======================================================================== * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,18 +52,24 @@ }, 0) } Button.prototype.toggle = function () { var $parent = this.$element.closest('[data-toggle="buttons"]') + var changed = true if ($parent.length) { var $input = this.$element.find('input') - .prop('checked', !this.$element.hasClass('active')) - .trigger('change') - if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + if ($input.prop('type') === 'radio') { + // see if clicking on current one + if ($input.prop('checked') && this.$element.hasClass('active')) + changed = false + else + $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } - this.$element.toggleClass('active') + if (changed) this.$element.toggleClass('active') } // BUTTON PLUGIN DEFINITION // ========================