From 13cad5061d46573c55def0e7a43cab1631317262 Mon Sep 17 00:00:00 2001 From: fat Date: Wed, 17 Jul 2013 19:28:43 -0700 Subject: [PATCH] maybe fix this old ass issue #5973 --- js/collapse.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/js/collapse.js b/js/collapse.js index 7c3c20da17..6b18e2577a 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -44,6 +44,10 @@ Collapse.prototype.show = function () { if (this.transitioning || this.$element.hasClass('in')) return + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + var dimension = this.dimension() var scroll = $.camelCase(['scroll', dimension].join('-')) var actives = this.$parent && this.$parent.find('> .accordion-group > .in') @@ -56,16 +60,21 @@ } this.$element[dimension](0) - this.transition('addClass', $.Event('show.bs.collapse'), 'shown.bs.collapse') + this.transition('addClass', 'shown.bs.collapse') if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) } Collapse.prototype.hide = function () { if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + var dimension = this.dimension() this.reset(this.$element[dimension]()) - this.transition('removeClass', $.Event('hide.bs.collapse'), 'hidden') + this.transition('removeClass', 'shown.bs.hidden') this.$element[dimension](0) } @@ -82,18 +91,14 @@ return this } - Collapse.prototype.transition = function (method, startEvent, completeEvent) { + Collapse.prototype.transition = function (method, completeEvent) { var that = this var complete = function () { - if (startEvent.type == 'show') that.reset() + if (completeEvent == 'shown.bs.collapse') that.reset() that.transitioning = 0 that.$element.trigger(completeEvent) } - this.$element.trigger(startEvent) - - if (startEvent.isDefaultPrevented()) return - this.transitioning = 1 this.$element[method]('in')