mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-06 13:46:42 +02:00
fixes #10890
This commit is contained in:
30
dist/js/bootstrap.js
vendored
30
dist/js/bootstrap.js
vendored
@@ -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"
|
|||||||
$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')
|
||||||
}
|
}
|
||||||
|
2
dist/js/bootstrap.min.js
vendored
2
dist/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
30
js/button.js
30
js/button.js
@@ -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 @@
|
|||||||
$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')
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user