aboutsummaryrefslogtreecommitdiff
path: root/js/button.js
diff options
context:
space:
mode:
authorfat <[email protected]>2013-12-26 19:40:18 -0800
committerfat <[email protected]>2013-12-26 19:40:18 -0800
commitd21369c1ed97d5719f6ccf360602150fc8ed16b3 (patch)
tree343593de1e189432ee4bd29121f3bd6b9f871f40 /js/button.js
parentcd0ad94aae42926e2bf86c2f14c6a8856c9b34ff (diff)
downloadbootstrap-d21369c1ed97d5719f6ccf360602150fc8ed16b3.tar.xz
bootstrap-d21369c1ed97d5719f6ccf360602150fc8ed16b3.zip
fixes #10890
Diffstat (limited to 'js/button.js')
-rw-r--r--js/button.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/js/button.js b/js/button.js
index f9cca154a..34a61f58a 100644
--- a/js/button.js
+++ b/js/button.js
@@ -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')
}