mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-06 13:46:42 +02:00
fixes #6159
This commit is contained in:
22
dist/js/bootstrap.js
vendored
22
dist/js/bootstrap.js
vendored
@@ -860,13 +860,13 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
||||
, show: true
|
||||
}
|
||||
|
||||
Modal.prototype.toggle = function () {
|
||||
return this[!this.isShown ? 'show' : 'hide']()
|
||||
Modal.prototype.toggle = function (_relatedTarget) {
|
||||
return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
|
||||
}
|
||||
|
||||
Modal.prototype.show = function () {
|
||||
Modal.prototype.show = function (_relatedTarget) {
|
||||
var that = this
|
||||
var e = $.Event('show.bs.modal')
|
||||
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
||||
|
||||
this.$element.trigger(e)
|
||||
|
||||
@@ -895,13 +895,15 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
||||
|
||||
that.enforceFocus()
|
||||
|
||||
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
||||
|
||||
transition ?
|
||||
that.$element
|
||||
.one($.support.transition.end, function () {
|
||||
that.$element.focus().trigger('shown.bs.modal')
|
||||
that.$element.focus().trigger(e)
|
||||
})
|
||||
.emulateTransitionEnd(300) :
|
||||
that.$element.focus().trigger('shown.bs.modal')
|
||||
that.$element.focus().trigger(e)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1014,15 +1016,15 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
||||
|
||||
var old = $.fn.modal
|
||||
|
||||
$.fn.modal = function (option) {
|
||||
$.fn.modal = function (option, _relatedTarget) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
var data = $this.data('bs.modal')
|
||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||
|
||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
else if (options.show) data.show()
|
||||
if (typeof option == 'string') data[option](_relatedTarget)
|
||||
else if (options.show) data.show(_relatedTarget)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1050,7 +1052,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
|
||||
e.preventDefault()
|
||||
|
||||
$target
|
||||
.modal(option)
|
||||
.modal(option, this)
|
||||
.one('hide', function () {
|
||||
$this.is(':visible') && $this.focus()
|
||||
})
|
||||
|
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
22
js/modal.js
22
js/modal.js
@@ -38,13 +38,13 @@
|
||||
, show: true
|
||||
}
|
||||
|
||||
Modal.prototype.toggle = function () {
|
||||
return this[!this.isShown ? 'show' : 'hide']()
|
||||
Modal.prototype.toggle = function (_relatedTarget) {
|
||||
return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
|
||||
}
|
||||
|
||||
Modal.prototype.show = function () {
|
||||
Modal.prototype.show = function (_relatedTarget) {
|
||||
var that = this
|
||||
var e = $.Event('show.bs.modal')
|
||||
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
||||
|
||||
this.$element.trigger(e)
|
||||
|
||||
@@ -73,13 +73,15 @@
|
||||
|
||||
that.enforceFocus()
|
||||
|
||||
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
||||
|
||||
transition ?
|
||||
that.$element
|
||||
.one($.support.transition.end, function () {
|
||||
that.$element.focus().trigger('shown.bs.modal')
|
||||
that.$element.focus().trigger(e)
|
||||
})
|
||||
.emulateTransitionEnd(300) :
|
||||
that.$element.focus().trigger('shown.bs.modal')
|
||||
that.$element.focus().trigger(e)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -192,15 +194,15 @@
|
||||
|
||||
var old = $.fn.modal
|
||||
|
||||
$.fn.modal = function (option) {
|
||||
$.fn.modal = function (option, _relatedTarget) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
var data = $this.data('bs.modal')
|
||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||
|
||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
else if (options.show) data.show()
|
||||
if (typeof option == 'string') data[option](_relatedTarget)
|
||||
else if (options.show) data.show(_relatedTarget)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -228,7 +230,7 @@
|
||||
e.preventDefault()
|
||||
|
||||
$target
|
||||
.modal(option)
|
||||
.modal(option, this)
|
||||
.one('hide', function () {
|
||||
$this.is(':visible') && $this.focus()
|
||||
})
|
||||
|
Reference in New Issue
Block a user