From 1ae1811571ab86c036bde1e9eef1a9e96ad4681e Mon Sep 17 00:00:00 2001 From: Ilya Kozlov Date: Fri, 31 May 2013 02:55:48 +0400 Subject: [PATCH 1/2] Support for returning modal results Allow passing an arbitrary parameter to modal.hide() method which is accessible as event object property in 'hide' and 'hidden' events --- js/bootstrap-modal.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index fbc540e..4d67ea7 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -69,10 +69,17 @@ this.options.loading && this.loading(); }, - hide: function (e) { - e && e.preventDefault(); + hide: function (obj) { + var result; + if (obj){ + if (obj instanceof $.Event || obj.preventDefault){ + obj.preventDefault(); + } else { + result = { modalResult: obj }; + } + } - e = $.Event('hide'); + var e = $.Event('hide', result); this.$element.trigger(e); @@ -96,8 +103,8 @@ .attr('aria-hidden', true); $.support.transition && this.$element.hasClass('fade') ? - this.hideWithTransition() : - this.hideModal(); + this.hideWithTransition(result) : + this.hideModal(result); }, layout: function () { @@ -188,7 +195,7 @@ } }, - hideWithTransition: function () { + hideWithTransition: function (result) { var that = this , timeout = setTimeout(function () { that.$element.off($.support.transition.end); @@ -197,11 +204,11 @@ this.$element.one($.support.transition.end, function () { clearTimeout(timeout); - that.hideModal(); + that.hideModal(result); }); }, - hideModal: function () { + hideModal: function (result) { var prop = this.options.height ? 'height' : 'max-height'; var value = this.options.height || this.options.maxHeight; @@ -213,7 +220,7 @@ this.$element .hide() - .trigger('hidden'); + .trigger($.Event('hidden', result)); }, removeLoading: function () { From 97c42ea0157f92fbeaf7d966e1bdb20001bcf89a Mon Sep 17 00:00:00 2001 From: Ilya Kozlov Date: Fri, 31 May 2013 03:03:12 +0400 Subject: [PATCH 2/2] Adds WebStorm/IDEA to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5ebd21a..5f61da8 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,6 @@ pip-log.txt # Mac crap .DS_Store + +# JetBrains WebStorm/IntelliJ IDEA +.idea