Commit d21369c1 authored by fat's avatar fat

fixes #10890

parent cd0ad94a
...@@ -157,8 +157,9 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery" ...@@ -157,8 +157,9 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery"
// ============================== // ==============================
var Button = function (element, options) { var Button = function (element, options) {
this.$element = $(element) this.$element = $(element)
this.options = $.extend({}, Button.DEFAULTS, options) this.options = $.extend({}, Button.DEFAULTS, options)
this.isLoading = false
} }
Button.DEFAULTS = { Button.DEFAULTS = {
...@@ -178,25 +179,26 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery" ...@@ -178,25 +179,26 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery"
$el[val](data[state] || this.options[state]) $el[val](data[state] || this.options[state])
// push to event loop to allow forms to submit // push to event loop to allow forms to submit
setTimeout(function () { setTimeout($.proxy(function () {
state == 'loadingText' ? if (state == 'loadingText') {
$el.addClass(d).attr(d, d) : this.isLoading = true
$el.removeClass(d).removeAttr(d); $el.addClass(d).attr(d, d)
}, 0) } else if (this.isLoading) {
this.isLoading = false
$el.removeClass(d).removeAttr(d)
}
}, this), 0)
} }
Button.prototype.toggle = function () { Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons"]')
var changed = true var changed = true
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) { if ($parent.length) {
var $input = this.$element.find('input') var $input = this.$element.find('input')
if ($input.prop('type') === 'radio') { if ($input.prop('type') == 'radio') {
// see if clicking on current one if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
if ($input.prop('checked') && this.$element.hasClass('active')) else $parent.find('.active').removeClass('active')
changed = false
else
$parent.find('.active').removeClass('active')
} }
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
// ============================== // ==============================
var Button = function (element, options) { var Button = function (element, options) {
this.$element = $(element) this.$element = $(element)
this.options = $.extend({}, Button.DEFAULTS, options) this.options = $.extend({}, Button.DEFAULTS, options)
this.isLoading = false
} }
Button.DEFAULTS = { Button.DEFAULTS = {
...@@ -34,25 +35,26 @@ ...@@ -34,25 +35,26 @@
$el[val](data[state] || this.options[state]) $el[val](data[state] || this.options[state])
// push to event loop to allow forms to submit // push to event loop to allow forms to submit
setTimeout(function () { setTimeout($.proxy(function () {
state == 'loadingText' ? if (state == 'loadingText') {
$el.addClass(d).attr(d, d) : this.isLoading = true
$el.removeClass(d).removeAttr(d); $el.addClass(d).attr(d, d)
}, 0) } else if (this.isLoading) {
this.isLoading = false
$el.removeClass(d).removeAttr(d)
}
}, this), 0)
} }
Button.prototype.toggle = function () { Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons"]')
var changed = true var changed = true
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) { if ($parent.length) {
var $input = this.$element.find('input') var $input = this.$element.find('input')
if ($input.prop('type') === 'radio') { if ($input.prop('type') == 'radio') {
// see if clicking on current one if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
if ($input.prop('checked') && this.$element.hasClass('active')) else $parent.find('.active').removeClass('active')
changed = false
else
$parent.find('.active').removeClass('active')
} }
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment