vendor/assets/javascripts/bootstrap-modal.js in bootstrap-modal-rails-2.2.4 vs vendor/assets/javascripts/bootstrap-modal.js in bootstrap-modal-rails-2.2.5

- old
+ new

@@ -1,7 +1,7 @@ /* =========================================================== - * bootstrap-modal.js v2.2.4 + * bootstrap-modal.js v2.2.5 * =========================================================== * Copyright 2012 Jordan Schroter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,11 +79,11 @@ e = $.Event('hide'); this.$element.trigger(e); - if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = false); + if (!this.isShown || e.isDefaultPrevented()) return; this.isShown = false; this.escape(); @@ -292,32 +292,29 @@ }, destroy: function () { var e = $.Event('destroy'); + this.$element.trigger(e); + if (e.isDefaultPrevented()) return; - this.teardown(); - }, - - teardown: function () { - if (!this.$parent.length){ + this.$element + .off('.modal') + .removeData('modal') + .removeClass('in') + .attr('aria-hidden', true); + + if (this.$parent !== this.$element.parent()) { + this.$element.appendTo(this.$parent); + } else if (!this.$parent.length) { + // modal is not part of the DOM so remove it. this.$element.remove(); this.$element = null; - return; } - if (this.$parent !== this.$element.parent()){ - this.$element.appendTo(this.$parent); - } - - this.$element.off('.modal'); - this.$element.removeData('modal'); - this.$element - .removeClass('in') - .attr('aria-hidden', true) - .trigger('destroyed'); + this.$element.trigger('destroyed'); } }; /* MODAL PLUGIN DEFINITION