From dbed9da77403337235acb652c3128ebc84672d60 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 9 Aug 2013 00:16:47 -0700 Subject: fixes #6159 --- dist/js/bootstrap.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 5bd8c5b84..b56349703 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -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) }) } @@ -1045,12 +1047,12 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") } var $this = $(this) var href = $this.attr('href') var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 - var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) + var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) e.preventDefault() $target - .modal(option) + .modal(option, this) .one('hide', function () { $this.is(':visible') && $this.focus() }) -- cgit v1.2.3