aboutsummaryrefslogtreecommitdiff
path: root/js/button.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/button.js')
-rw-r--r--js/button.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/js/button.js b/js/button.js
index 2cf67f6ad..34a61f58a 100644
--- a/js/button.js
+++ b/js/button.js
@@ -1,5 +1,5 @@
/* ========================================================================
- * Bootstrap: button.js v3.1.0
+ * Bootstrap: button.js v3.0.3
* http://getbootstrap.com/javascript/#buttons
* ========================================================================
* Copyright 2013 Twitter, Inc.
@@ -13,8 +13,9 @@
// ==============================
var Button = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, Button.DEFAULTS, options)
+ this.$element = $(element)
+ this.options = $.extend({}, Button.DEFAULTS, options)
+ this.isLoading = false
}
Button.DEFAULTS = {
@@ -34,25 +35,26 @@
$el[val](data[state] || this.options[state])
// push to event loop to allow forms to submit
- setTimeout(function () {
- state == 'loadingText' ?
- $el.addClass(d).attr(d, d) :
- $el.removeClass(d).removeAttr(d);
- }, 0)
+ setTimeout($.proxy(function () {
+ if (state == 'loadingText') {
+ this.isLoading = true
+ $el.addClass(d).attr(d, d)
+ } else if (this.isLoading) {
+ this.isLoading = false
+ $el.removeClass(d).removeAttr(d)
+ }
+ }, this), 0)
}
Button.prototype.toggle = function () {
- var $parent = this.$element.closest('[data-toggle="buttons"]')
var changed = true
+ var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) {
var $input = this.$element.find('input')
- 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 ($input.prop('type') == 'radio') {
+ 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')
}