From b058c018eba059811f0c26074b813b843cfb5cb7 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 19 May 2014 01:25:52 -0700 Subject: Hopefully a fix for #12364 * register the callback before invoking the toggling * listen for `hidden` instead of `hide` * account for the possibility of the associated `show` event being preventDefault-ed Adds relevant unit tests. --- js/modal.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/modal.js') diff --git a/js/modal.js b/js/modal.js index a89eb0c09..20c6712b3 100644 --- a/js/modal.js +++ b/js/modal.js @@ -268,10 +268,13 @@ if ($this.is('a')) e.preventDefault() - Plugin.call($target, option, this) - $target.one('hide.bs.modal', function () { - $this.is(':visible') && $this.trigger('focus') + $target.one('show.bs.modal', function (showEvent) { + if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown + $target.one('hidden.bs.modal', function () { + $this.is(':visible') && $this.trigger('focus') + }) }) + Plugin.call($target, option, this) }) }(jQuery); -- cgit v1.2.3 From 7b0acf14d8a7c7c6089035a848cba540ed963f36 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Mar 2014 09:12:55 +0200 Subject: Comply to the new style. --- js/modal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/modal.js') diff --git a/js/modal.js b/js/modal.js index a89eb0c09..21f8ddfd1 100644 --- a/js/modal.js +++ b/js/modal.js @@ -188,7 +188,7 @@ } else if (!this.isShown && this.$backdrop) { this.$backdrop.removeClass('in') - var callbackRemove = function() { + var callbackRemove = function () { that.removeBackdrop() callback && callback() } @@ -209,7 +209,7 @@ } Modal.prototype.setScrollbar = function () { - var bodyPad = parseInt(this.$body.css('padding-right') || 0) + var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) } -- cgit v1.2.3 From e2cabe4971927e3dbbbda4c81ae8f74abdee2d15 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 29 May 2014 07:35:22 +0300 Subject: Minor style tweaks. --- js/modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/modal.js') diff --git a/js/modal.js b/js/modal.js index 21f8ddfd1..2004a23de 100644 --- a/js/modal.js +++ b/js/modal.js @@ -208,7 +208,7 @@ this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar() } - Modal.prototype.setScrollbar = function () { + Modal.prototype.setScrollbar = function () { var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) } -- cgit v1.2.3