Commit bfebf0e4 authored by Mark Otto's avatar Mark Otto

Merge branch '3.0.0-wip' of github.com:twitter/bootstrap into 3.0.0-wip

parents 7cc34ea5 5396c408
...@@ -502,6 +502,10 @@ ...@@ -502,6 +502,10 @@
Collapse.prototype.show = function () { Collapse.prototype.show = function () {
if (this.transitioning || this.$element.hasClass('in')) return 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 dimension = this.dimension()
var scroll = $.camelCase(['scroll', dimension].join('-')) var scroll = $.camelCase(['scroll', dimension].join('-'))
var actives = this.$parent && this.$parent.find('> .accordion-group > .in') var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
...@@ -514,16 +518,21 @@ ...@@ -514,16 +518,21 @@
} }
this.$element[dimension](0) 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]) if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
} }
Collapse.prototype.hide = function () { Collapse.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('in')) return 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() var dimension = this.dimension()
this.reset(this.$element[dimension]()) this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide.bs.collapse'), 'hidden') this.transition('removeClass', 'shown.bs.hidden')
this.$element[dimension](0) this.$element[dimension](0)
} }
...@@ -540,18 +549,14 @@ ...@@ -540,18 +549,14 @@
return this return this
} }
Collapse.prototype.transition = function (method, startEvent, completeEvent) { Collapse.prototype.transition = function (method, completeEvent) {
var that = this var that = this
var complete = function () { var complete = function () {
if (startEvent.type == 'show') that.reset() if (completeEvent == 'shown.bs.collapse') that.reset()
that.transitioning = 0 that.transitioning = 0
that.$element.trigger(completeEvent) that.$element.trigger(completeEvent)
} }
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1 this.transitioning = 1
this.$element[method]('in') this.$element[method]('in')
......
This diff is collapsed.
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
Collapse.prototype.show = function () { Collapse.prototype.show = function () {
if (this.transitioning || this.$element.hasClass('in')) return 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 dimension = this.dimension()
var scroll = $.camelCase(['scroll', dimension].join('-')) var scroll = $.camelCase(['scroll', dimension].join('-'))
var actives = this.$parent && this.$parent.find('> .accordion-group > .in') var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
...@@ -56,16 +60,21 @@ ...@@ -56,16 +60,21 @@
} }
this.$element[dimension](0) 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]) if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
} }
Collapse.prototype.hide = function () { Collapse.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('in')) return 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() var dimension = this.dimension()
this.reset(this.$element[dimension]()) this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide.bs.collapse'), 'hidden') this.transition('removeClass', 'shown.bs.hidden')
this.$element[dimension](0) this.$element[dimension](0)
} }
...@@ -82,18 +91,14 @@ ...@@ -82,18 +91,14 @@
return this return this
} }
Collapse.prototype.transition = function (method, startEvent, completeEvent) { Collapse.prototype.transition = function (method, completeEvent) {
var that = this var that = this
var complete = function () { var complete = function () {
if (startEvent.type == 'show') that.reset() if (completeEvent == 'shown.bs.collapse') that.reset()
that.transitioning = 0 that.transitioning = 0
that.$element.trigger(completeEvent) that.$element.trigger(completeEvent)
} }
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1 this.transitioning = 1
this.$element[method]('in') this.$element[method]('in')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment