diff options
| author | Jacob Thornton <[email protected]> | 2013-08-09 00:16:47 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2013-08-09 00:16:47 -0700 |
| commit | dbed9da77403337235acb652c3128ebc84672d60 (patch) | |
| tree | 269656f615aba5a4505e0b16e645bad2a6ae9420 /js | |
| parent | e46708f7cee19ebe4acf04c71ef71947e6c2e20f (diff) | |
| download | bootstrap-dbed9da77403337235acb652c3128ebc84672d60.tar.xz bootstrap-dbed9da77403337235acb652c3128ebc84672d60.zip | |
fixes #6159
Diffstat (limited to 'js')
| -rw-r--r-- | js/modal.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/js/modal.js b/js/modal.js index d53cc9eaf..89c705a38 100644 --- a/js/modal.js +++ b/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) }) } @@ -223,12 +225,12 @@ 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() }) |
