2013-05-21 22:30:33 -04:00
|
|
|
/* ========================================================================
|
2013-12-01 22:31:52 -05:00
|
|
|
* Bootstrap: collapse.js v3.0.3
|
2013-10-29 13:10:47 -04:00
|
|
|
* http://getbootstrap.com/javascript/#collapse
|
2013-05-21 22:30:33 -04:00
|
|
|
* ========================================================================
|
2013-10-22 12:41:33 -04:00
|
|
|
* Copyright 2013 Twitter, Inc.
|
2011-11-25 20:23:14 -05:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the 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
|
|
|
|
2013-09-18 12:50:02 -04:00
|
|
|
+function ($) { 'use strict';
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
// COLLAPSE PUBLIC CLASS DEFINITION
|
|
|
|
// ================================
|
2012-04-14 19:29:53 -04:00
|
|
|
|
|
|
|
var Collapse = function (element, options) {
|
2013-05-16 14:20:18 -04:00
|
|
|
this.$element = $(element)
|
|
|
|
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
|
|
|
this.transitioning = null
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20: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
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
Collapse.DEFAULTS = {
|
|
|
|
toggle: true
|
2011-11-25 20:23:14 -05:00
|
|
|
}
|
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
Collapse.prototype.dimension = function () {
|
|
|
|
var hasWidth = this.$element.hasClass('width')
|
|
|
|
return hasWidth ? 'width' : 'height'
|
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
Collapse.prototype.show = function () {
|
|
|
|
if (this.transitioning || this.$element.hasClass('in')) return
|
2011-12-01 01:42:22 -05:00
|
|
|
|
2013-07-17 22:28:43 -04:00
|
|
|
var startEvent = $.Event('show.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
|
|
|
|
2013-08-13 02:36:25 -04:00
|
|
|
var actives = this.$parent && this.$parent.find('> .panel > .in')
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
if (actives && actives.length) {
|
2013-07-17 23:29:41 -04:00
|
|
|
var hasData = actives.data('bs.collapse')
|
2013-05-16 14:20:18 -04:00
|
|
|
if (hasData && hasData.transitioning) return
|
|
|
|
actives.collapse('hide')
|
2013-07-17 23:29:41 -04:00
|
|
|
hasData || actives.data('bs.collapse', null)
|
2013-05-16 14:20:18 -04:00
|
|
|
}
|
2012-03-21 01:43:27 -04:00
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
var dimension = this.dimension()
|
|
|
|
|
|
|
|
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('-'))
|
2012-03-21 01:43:27 -04:00
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
this.$element
|
|
|
|
.one($.support.transition.end, $.proxy(complete, this))
|
|
|
|
.emulateTransitionEnd(350)
|
|
|
|
[dimension](this.$element[0][scrollSize])
|
2013-05-16 14:20:18 -04:00
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
Collapse.prototype.hide = function () {
|
|
|
|
if (this.transitioning || !this.$element.hasClass('in')) return
|
2013-07-17 22:28:43 -04:00
|
|
|
|
|
|
|
var startEvent = $.Event('hide.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
var dimension = this.dimension()
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
this.$element
|
|
|
|
[dimension](this.$element[dimension]())
|
|
|
|
[0].offsetHeight
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
this.$element
|
2013-07-26 23:34:39 -04:00
|
|
|
.addClass('collapsing')
|
2013-05-16 14:20:18 -04:00
|
|
|
.removeClass('collapse')
|
2013-07-26 23:34:39 -04:00
|
|
|
.removeClass('in')
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
this.transitioning = 1
|
2012-03-12 16:37:44 -04:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
var complete = function () {
|
2013-07-26 23:34:39 -04:00
|
|
|
this.transitioning = 0
|
|
|
|
this.$element
|
|
|
|
.trigger('hidden.bs.collapse')
|
|
|
|
.removeClass('collapsing')
|
|
|
|
.addClass('collapse')
|
2011-11-25 20:23:14 -05:00
|
|
|
}
|
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
if (!$.support.transition) return complete.call(this)
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-07-26 23:34:39 -04:00
|
|
|
this.$element
|
|
|
|
[dimension](0)
|
|
|
|
.one($.support.transition.end, $.proxy(complete, this))
|
|
|
|
.emulateTransitionEnd(350)
|
2013-05-16 14:20:18 -04:00
|
|
|
}
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
Collapse.prototype.toggle = function () {
|
|
|
|
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
2011-11-25 20:23:14 -05:00
|
|
|
}
|
|
|
|
|
2012-04-14 19:29:53 -04:00
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
// COLLAPSE PLUGIN DEFINITION
|
|
|
|
// ==========================
|
2012-12-07 17:06:01 -05:00
|
|
|
|
|
|
|
var old = $.fn.collapse
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2012-04-14 19:29:53 -04:00
|
|
|
$.fn.collapse = function (option) {
|
2011-11-25 20:23:14 -05:00
|
|
|
return this.each(function () {
|
2013-05-16 14:20:18 -04:00
|
|
|
var $this = $(this)
|
2013-07-17 23:29:41 -04:00
|
|
|
var data = $this.data('bs.collapse')
|
2013-05-16 14:20:18 -04:00
|
|
|
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
|
|
|
|
2013-07-17 23:29:41 -04:00
|
|
|
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
2011-11-25 20:23:14 -05:00
|
|
|
if (typeof option == 'string') data[option]()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2011-12-21 02:28:48 -05:00
|
|
|
$.fn.collapse.Constructor = Collapse
|
2011-11-25 20:23:14 -05:00
|
|
|
|
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
// COLLAPSE NO CONFLICT
|
|
|
|
// ====================
|
2011-11-25 20:23:14 -05:00
|
|
|
|
2012-12-07 17:06:01 -05:00
|
|
|
$.fn.collapse.noConflict = function () {
|
|
|
|
$.fn.collapse = old
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-16 14:20:18 -04:00
|
|
|
// COLLAPSE DATA-API
|
|
|
|
// =================
|
2012-12-07 17:06:01 -05:00
|
|
|
|
2013-05-25 02:15:04 -04:00
|
|
|
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
|
2013-07-18 02:52:29 -04:00
|
|
|
var $this = $(this), href
|
|
|
|
var target = $this.attr('data-target')
|
2012-09-27 18:00:02 -04:00
|
|
|
|| e.preventDefault()
|
|
|
|
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
2013-07-18 02:52:29 -04:00
|
|
|
var $target = $(target)
|
|
|
|
var data = $target.data('bs.collapse')
|
|
|
|
var option = data ? 'toggle' : $this.data()
|
|
|
|
var parent = $this.attr('data-parent')
|
2013-05-27 04:06:31 -04:00
|
|
|
var $parent = parent && $(parent)
|
2013-05-16 14:20:18 -04:00
|
|
|
|
2013-07-17 23:29:41 -04:00
|
|
|
if (!data || !data.transitioning) {
|
2013-08-05 02:59:57 -04:00
|
|
|
if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
|
2013-07-18 02:52:29 -04:00
|
|
|
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
2013-07-17 23:29:41 -04:00
|
|
|
}
|
|
|
|
|
2013-07-18 02:52:29 -04:00
|
|
|
$target.collapse(option)
|
2011-11-25 20:23:14 -05:00
|
|
|
})
|
|
|
|
|
2013-08-22 14:50:15 -04:00
|
|
|
}(jQuery);
|