1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-10 07:37:27 +02:00

change how collapse works - collapse, collapsing, and in

This commit is contained in:
fat
2013-07-26 20:34:39 -07:00
parent 178d8e98de
commit e2d4cf5f68
8 changed files with 108 additions and 80 deletions

78
dist/js/bootstrap.js vendored
View File

@@ -53,6 +53,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
$(this).one('webkitTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') }
setTimeout(callback, duration)
return this
}
$(function () {
@@ -532,8 +533,6 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
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')
if (actives && actives.length) {
@@ -543,10 +542,32 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
hasData || actives.data('bs.collapse', null)
}
this.$element[dimension](0)
this.transition('addClass', 'shown.bs.collapse')
var dimension = this.dimension()
if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
this.$element
.removeClass('collapse')
.addClass('collapsing')
[dimension](0)
this.transitioning = 1
var complete = function () {
this.$element
.removeClass('collapsing')
.addClass('in')
[dimension]('auto')
this.transitioning = 0
this.$element.trigger('shown.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
[dimension](this.$element[0][scrollSize])
}
Collapse.prototype.hide = function () {
@@ -556,42 +577,33 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', 'hidden.bs.collapse')
this.$element[dimension](0)
}
Collapse.prototype.reset = function (size) {
var dimension = this.dimension()
this.$element
[dimension](this.$element[dimension]())
[0].offsetHeight
this.$element
.addClass('collapsing')
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth
this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
return this
}
Collapse.prototype.transition = function (method, completeEvent) {
var that = this
var complete = function () {
if (completeEvent == 'shown.bs.collapse') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
.removeClass('in')
this.transitioning = 1
this.$element[method]('in')
$.support.transition && this.$element.hasClass('collapse') ?
var complete = function () {
this.transitioning = 0
this.$element
.one($.support.transition.end, complete)
.emulateTransitionEnd(350) :
complete()
.trigger('hidden.bs.collapse')
.removeClass('collapsing')
.addClass('collapse')
}
if (!$.support.transition) return complete.call(this)
this.$element
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
}
Collapse.prototype.toggle = function () {

File diff suppressed because one or more lines are too long