2013-05-22 04:30:33 +02:00
|
|
|
/* ========================================================================
|
2013-05-16 20:06:30 +02:00
|
|
|
* Bootstrap: collapse.js v3.0.0
|
2012-01-24 20:08:03 +01:00
|
|
|
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
2013-05-22 04:30:33 +02:00
|
|
|
* ========================================================================
|
2012-01-15 08:28:48 +01:00
|
|
|
* Copyright 2012 Twitter, Inc.
|
2011-11-26 02:23:14 +01: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-22 04:30:33 +02:00
|
|
|
* ======================================================================== */
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2012-03-25 03:59:04 +02:00
|
|
|
|
2013-05-22 04:30:33 +02:00
|
|
|
+function ($) { "use strict";
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
// COLLAPSE PUBLIC CLASS DEFINITION
|
|
|
|
// ================================
|
2012-04-15 01:29:53 +02:00
|
|
|
|
|
|
|
var Collapse = function (element, options) {
|
2013-05-16 20:20:18 +02:00
|
|
|
this.$element = $(element)
|
|
|
|
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
|
|
|
this.transitioning = null
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
if (this.options.parent) this.$parent = $(this.options.parent)
|
|
|
|
if (this.options.toggle) this.toggle()
|
|
|
|
}
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.DEFAULTS = {
|
|
|
|
toggle: true
|
2011-11-26 02:23:14 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.prototype.dimension = function () {
|
|
|
|
var hasWidth = this.$element.hasClass('width')
|
|
|
|
return hasWidth ? 'width' : 'height'
|
|
|
|
}
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.prototype.show = function () {
|
|
|
|
if (this.transitioning || this.$element.hasClass('in')) return
|
2011-12-01 07:42:22 +01:00
|
|
|
|
2013-07-18 04:28:43 +02:00
|
|
|
var startEvent = $.Event('show.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
var dimension = this.dimension()
|
|
|
|
var scroll = $.camelCase(['scroll', dimension].join('-'))
|
2013-07-24 03:44:08 +02:00
|
|
|
var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
if (actives && actives.length) {
|
2013-07-18 05:29:41 +02:00
|
|
|
var hasData = actives.data('bs.collapse')
|
2013-05-16 20:20:18 +02:00
|
|
|
if (hasData && hasData.transitioning) return
|
|
|
|
actives.collapse('hide')
|
2013-07-18 05:29:41 +02:00
|
|
|
hasData || actives.data('bs.collapse', null)
|
2013-05-16 20:20:18 +02:00
|
|
|
}
|
2012-03-21 06:43:27 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
this.$element[dimension](0)
|
2013-07-18 04:28:43 +02:00
|
|
|
this.transition('addClass', 'shown.bs.collapse')
|
2012-03-21 06:43:27 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
|
|
|
|
}
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.prototype.hide = function () {
|
|
|
|
if (this.transitioning || !this.$element.hasClass('in')) return
|
2013-07-18 04:28:43 +02:00
|
|
|
|
|
|
|
var startEvent = $.Event('hide.bs.collapse')
|
|
|
|
this.$element.trigger(startEvent)
|
|
|
|
if (startEvent.isDefaultPrevented()) return
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
var dimension = this.dimension()
|
|
|
|
this.reset(this.$element[dimension]())
|
2013-07-18 04:28:43 +02:00
|
|
|
this.transition('removeClass', 'shown.bs.hidden')
|
2013-05-16 20:20:18 +02:00
|
|
|
this.$element[dimension](0)
|
|
|
|
}
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.prototype.reset = function (size) {
|
|
|
|
var dimension = this.dimension()
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
this.$element
|
|
|
|
.removeClass('collapse')
|
|
|
|
[dimension](size || 'auto')
|
|
|
|
[0].offsetWidth
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-06-28 04:19:22 +02:00
|
|
|
this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
return this
|
|
|
|
}
|
2012-03-12 21:37:44 +01:00
|
|
|
|
2013-07-18 04:28:43 +02:00
|
|
|
Collapse.prototype.transition = function (method, completeEvent) {
|
2013-05-16 20:20:18 +02:00
|
|
|
var that = this
|
|
|
|
var complete = function () {
|
2013-07-18 04:28:43 +02:00
|
|
|
if (completeEvent == 'shown.bs.collapse') that.reset()
|
2013-05-16 20:20:18 +02:00
|
|
|
that.transitioning = 0
|
|
|
|
that.$element.trigger(completeEvent)
|
2011-11-26 02:23:14 +01:00
|
|
|
}
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
this.transitioning = 1
|
2012-03-21 06:43:27 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
this.$element[method]('in')
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
$.support.transition && this.$element.hasClass('collapse') ?
|
2013-07-24 03:44:08 +02:00
|
|
|
this.$element
|
|
|
|
.one($.support.transition.end, complete)
|
|
|
|
.emulateTransitionEnd(350) :
|
2013-05-16 20:20:18 +02:00
|
|
|
complete()
|
|
|
|
}
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
Collapse.prototype.toggle = function () {
|
|
|
|
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
2011-11-26 02:23:14 +01:00
|
|
|
}
|
|
|
|
|
2012-04-15 01:29:53 +02:00
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
// COLLAPSE PLUGIN DEFINITION
|
|
|
|
// ==========================
|
2012-12-07 23:06:01 +01:00
|
|
|
|
|
|
|
var old = $.fn.collapse
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2012-04-15 01:29:53 +02:00
|
|
|
$.fn.collapse = function (option) {
|
2011-11-26 02:23:14 +01:00
|
|
|
return this.each(function () {
|
2013-05-16 20:20:18 +02:00
|
|
|
var $this = $(this)
|
2013-07-18 05:29:41 +02:00
|
|
|
var data = $this.data('bs.collapse')
|
2013-05-16 20:20:18 +02:00
|
|
|
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
|
|
|
|
2013-07-18 05:29:41 +02:00
|
|
|
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
2011-11-26 02:23:14 +01:00
|
|
|
if (typeof option == 'string') data[option]()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2011-12-21 08:28:48 +01:00
|
|
|
$.fn.collapse.Constructor = Collapse
|
2011-11-26 02:23:14 +01:00
|
|
|
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
// COLLAPSE NO CONFLICT
|
|
|
|
// ====================
|
2011-11-26 02:23:14 +01:00
|
|
|
|
2012-12-07 23:06:01 +01:00
|
|
|
$.fn.collapse.noConflict = function () {
|
|
|
|
$.fn.collapse = old
|
|
|
|
return this
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-16 20:20:18 +02:00
|
|
|
// COLLAPSE DATA-API
|
|
|
|
// =================
|
2012-12-07 23:06:01 +01:00
|
|
|
|
2013-05-25 08:15:04 +02:00
|
|
|
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
|
2013-07-18 08:52:29 +02:00
|
|
|
var $this = $(this), href
|
|
|
|
var target = $this.attr('data-target')
|
2012-09-28 00:00:02 +02:00
|
|
|
|| e.preventDefault()
|
|
|
|
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
2013-07-18 08:52:29 +02: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 10:06:31 +02:00
|
|
|
var $parent = parent && $(parent)
|
2013-05-16 20:20:18 +02:00
|
|
|
|
2013-07-18 05:29:41 +02:00
|
|
|
if (!data || !data.transitioning) {
|
|
|
|
if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed')
|
2013-07-18 08:52:29 +02:00
|
|
|
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
2013-07-18 05:29:41 +02:00
|
|
|
}
|
|
|
|
|
2013-07-18 08:52:29 +02:00
|
|
|
$target.collapse(option)
|
2011-11-26 02:23:14 +01:00
|
|
|
})
|
|
|
|
|
2013-04-23 09:34:27 +02:00
|
|
|
}(window.jQuery);
|