2013-05-21 22:30:33 -04:00
|
|
|
/* ========================================================================
|
2014-06-26 12:13:24 -04:00
|
|
|
* Bootstrap: collapse.js v3.2.0
|
2013-10-29 13:10:47 -04:00
|
|
|
* http://getbootstrap.com/javascript/#collapse
|
2013-05-21 22:30:33 -04:00
|
|
|
* ========================================================================
|
2014-01-06 19:05:24 -05:00
|
|
|
* Copyright 2011-2014 Twitter, Inc.
|
2013-12-18 18:28:08 -05:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
2013-05-21 22:30:33 -04:00
|
|
|
* ======================================================================== */
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2012-03-24 21:59:04 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
+function ($) {
|
|
|
|
'use strict';
|
2014-06-10 01:18:05 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// COLLAPSE PUBLIC CLASS DEFINITION
|
|
|
|
// ================================
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var Collapse = function (element, options) {
|
|
|
|
this.$element = $(element)
|
|
|
|
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
|
|
|
this.transitioning = null
|
2012-04-14 19:29:53 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (this.options.parent) this.$parent = $(this.options.parent)
|
|
|
|
if (this.options.toggle) this.toggle()
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-26 12:13:24 -04:00
|
|
|
Collapse.VERSION = '3.2.0'
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Collapse.DEFAULTS = {
|
|
|
|
toggle: true
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Collapse.prototype.dimension = function () {
|
|
|
|
var hasWidth = this.$element.hasClass('width')
|
|
|
|
return hasWidth ? 'width' : 'height'
|
|
|
|
}
|
2011-12-01 01:42:22 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Collapse.prototype.show = function () {
|
|
|
|
if (this.transitioning || this.$element.hasClass('in')) return
|
2013-07-17 22:28:43 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var startEvent = $.Event('show.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var actives = this.$parent && this.$parent.find('> .panel > .in')
|
2012-03-21 01:43:27 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (actives && actives.length) {
|
|
|
|
var hasData = actives.data('bs.collapse')
|
|
|
|
if (hasData && hasData.transitioning) return
|
|
|
|
Plugin.call(actives, 'hide')
|
|
|
|
hasData || actives.data('bs.collapse', null)
|
|
|
|
}
|
|
|
|
|
|
|
|
var dimension = this.dimension()
|
2013-07-26 23:34:39 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.$element
|
|
|
|
.removeClass('collapse')
|
|
|
|
.addClass('collapsing')[dimension](0)
|
2013-07-26 23:34:39 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.transitioning = 1
|
2013-07-26 23:34:39 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var complete = function () {
|
|
|
|
this.$element
|
|
|
|
.removeClass('collapsing')
|
|
|
|
.addClass('collapse in')[dimension]('')
|
|
|
|
this.transitioning = 0
|
2013-07-26 23:34:39 -04:00
|
|
|
this.$element
|
2014-06-23 14:07:18 -04:00
|
|
|
.trigger('shown.bs.collapse')
|
|
|
|
}
|
2013-07-26 23:34:39 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!$.support.transition) return complete.call(this)
|
2013-07-26 23:34:39 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
|
2012-03-21 01:43:27 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.$element
|
|
|
|
.one('bsTransitionEnd', $.proxy(complete, this))
|
|
|
|
.emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Collapse.prototype.hide = function () {
|
|
|
|
if (this.transitioning || !this.$element.hasClass('in')) return
|
2013-07-17 22:28:43 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var startEvent = $.Event('hide.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
2013-07-17 22:28:43 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var dimension = this.dimension()
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.$element[dimension](this.$element[dimension]())[0].offsetHeight
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.$element
|
|
|
|
.addClass('collapsing')
|
2014-07-06 02:28:44 -04:00
|
|
|
.removeClass('collapse in')
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.transitioning = 1
|
2012-03-12 16:37:44 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var complete = function () {
|
|
|
|
this.transitioning = 0
|
2013-07-26 23:34:39 -04:00
|
|
|
this.$element
|
2014-06-23 14:07:18 -04:00
|
|
|
.trigger('hidden.bs.collapse')
|
|
|
|
.removeClass('collapsing')
|
|
|
|
.addClass('collapse')
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!$.support.transition) return complete.call(this)
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
this.$element
|
|
|
|
[dimension](0)
|
|
|
|
.one('bsTransitionEnd', $.proxy(complete, this))
|
|
|
|
.emulateTransitionEnd(350)
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Collapse.prototype.toggle = function () {
|
2014-07-06 02:49:45 -04:00
|
|
|
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
2014-06-23 14:07:18 -04:00
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// COLLAPSE PLUGIN DEFINITION
|
|
|
|
// ==========================
|
2013-05-16 14:20:18 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
function Plugin(option) {
|
|
|
|
return this.each(function () {
|
|
|
|
var $this = $(this)
|
|
|
|
var data = $this.data('bs.collapse')
|
|
|
|
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!data && options.toggle && option == 'show') option = !option
|
|
|
|
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
|
|
|
if (typeof option == 'string') data[option]()
|
|
|
|
})
|
|
|
|
}
|
2014-04-22 01:03:33 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
var old = $.fn.collapse
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$.fn.collapse = Plugin
|
|
|
|
$.fn.collapse.Constructor = Collapse
|
2011-11-25 20:23:14 -05:00
|
|
|
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// COLLAPSE NO CONFLICT
|
|
|
|
// ====================
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$.fn.collapse.noConflict = function () {
|
|
|
|
$.fn.collapse = old
|
|
|
|
return this
|
|
|
|
}
|
2012-12-07 17:06:01 -05:00
|
|
|
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
// COLLAPSE DATA-API
|
|
|
|
// =================
|
2013-05-16 14:20:18 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
$(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
|
|
|
|
var href
|
|
|
|
var $this = $(this)
|
|
|
|
var target = $this.attr('data-target')
|
|
|
|
|| e.preventDefault()
|
|
|
|
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
|
|
|
|
var $target = $(target)
|
|
|
|
var data = $target.data('bs.collapse')
|
|
|
|
var option = data ? 'toggle' : $this.data()
|
|
|
|
var parent = $this.attr('data-parent')
|
|
|
|
var $parent = parent && $(parent)
|
2014-06-12 14:11:04 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
if (!data || !data.transitioning) {
|
|
|
|
if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
|
2014-07-06 02:49:45 -04:00
|
|
|
$this.toggleClass('collapsed', $target.hasClass('in'))
|
2014-06-23 14:07:18 -04:00
|
|
|
}
|
2013-07-17 23:29:41 -04:00
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
Plugin.call($target, option)
|
2011-11-25 20:23:14 -05:00
|
|
|
})
|
|
|
|
|
2014-06-23 14:07:18 -04:00
|
|
|
}(jQuery);
|