info@54
|
1 |
/* ========================================================================
|
info@54
|
2 |
* Bootstrap: collapse.js v3.0.3
|
info@54
|
3 |
* http://getbootstrap.com/javascript/#collapse
|
info@54
|
4 |
* ========================================================================
|
info@54
|
5 |
* Copyright 2013 Twitter, Inc.
|
info@54
|
6 |
*
|
info@54
|
7 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
info@54
|
8 |
* you may not use this file except in compliance with the License.
|
info@54
|
9 |
* You may obtain a copy of the License at
|
info@54
|
10 |
*
|
info@54
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0
|
info@54
|
12 |
*
|
info@54
|
13 |
* Unless required by applicable law or agreed to in writing, software
|
info@54
|
14 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
info@54
|
15 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
info@54
|
16 |
* See the License for the specific language governing permissions and
|
info@54
|
17 |
* limitations under the License.
|
info@54
|
18 |
* ======================================================================== */
|
info@54
|
19 |
|
info@54
|
20 |
|
info@54
|
21 |
+function ($) { "use strict";
|
info@54
|
22 |
|
info@54
|
23 |
// COLLAPSE PUBLIC CLASS DEFINITION
|
info@54
|
24 |
// ================================
|
info@54
|
25 |
|
info@54
|
26 |
var Collapse = function (element, options) {
|
info@54
|
27 |
this.$element = $(element)
|
info@54
|
28 |
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
info@54
|
29 |
this.transitioning = null
|
info@54
|
30 |
|
info@54
|
31 |
if (this.options.parent) this.$parent = $(this.options.parent)
|
info@54
|
32 |
if (this.options.toggle) this.toggle()
|
info@54
|
33 |
}
|
info@54
|
34 |
|
info@54
|
35 |
Collapse.DEFAULTS = {
|
info@54
|
36 |
toggle: true
|
info@54
|
37 |
}
|
info@54
|
38 |
|
info@54
|
39 |
Collapse.prototype.dimension = function () {
|
info@54
|
40 |
var hasWidth = this.$element.hasClass('width')
|
info@54
|
41 |
return hasWidth ? 'width' : 'height'
|
info@54
|
42 |
}
|
info@54
|
43 |
|
info@54
|
44 |
Collapse.prototype.show = function () {
|
info@54
|
45 |
if (this.transitioning || this.$element.hasClass('in')) return
|
info@54
|
46 |
|
info@54
|
47 |
var startEvent = $.Event('show.bs.collapse')
|
info@54
|
48 |
this.$element.trigger(startEvent)
|
info@54
|
49 |
if (startEvent.isDefaultPrevented()) return
|
info@54
|
50 |
|
info@54
|
51 |
var actives = this.$parent && this.$parent.find('> .panel > .in')
|
info@54
|
52 |
|
info@54
|
53 |
if (actives && actives.length) {
|
info@54
|
54 |
var hasData = actives.data('bs.collapse')
|
info@54
|
55 |
if (hasData && hasData.transitioning) return
|
info@54
|
56 |
actives.collapse('hide')
|
info@54
|
57 |
hasData || actives.data('bs.collapse', null)
|
info@54
|
58 |
}
|
info@54
|
59 |
|
info@54
|
60 |
var dimension = this.dimension()
|
info@54
|
61 |
|
info@54
|
62 |
this.$element
|
info@54
|
63 |
.removeClass('collapse')
|
info@54
|
64 |
.addClass('collapsing')
|
info@54
|
65 |
[dimension](0)
|
info@54
|
66 |
|
info@54
|
67 |
this.transitioning = 1
|
info@54
|
68 |
|
info@54
|
69 |
var complete = function () {
|
info@54
|
70 |
this.$element
|
info@54
|
71 |
.removeClass('collapsing')
|
info@54
|
72 |
.addClass('in')
|
info@54
|
73 |
[dimension]('auto')
|
info@54
|
74 |
this.transitioning = 0
|
info@54
|
75 |
this.$element.trigger('shown.bs.collapse')
|
info@54
|
76 |
}
|
info@54
|
77 |
|
info@54
|
78 |
if (!$.support.transition) return complete.call(this)
|
info@54
|
79 |
|
info@54
|
80 |
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
|
info@54
|
81 |
|
info@54
|
82 |
this.$element
|
info@54
|
83 |
.one($.support.transition.end, $.proxy(complete, this))
|
info@54
|
84 |
.emulateTransitionEnd(350)
|
info@54
|
85 |
[dimension](this.$element[0][scrollSize])
|
info@54
|
86 |
}
|
info@54
|
87 |
|
info@54
|
88 |
Collapse.prototype.hide = function () {
|
info@54
|
89 |
if (this.transitioning || !this.$element.hasClass('in')) return
|
info@54
|
90 |
|
info@54
|
91 |
var startEvent = $.Event('hide.bs.collapse')
|
info@54
|
92 |
this.$element.trigger(startEvent)
|
info@54
|
93 |
if (startEvent.isDefaultPrevented()) return
|
info@54
|
94 |
|
info@54
|
95 |
var dimension = this.dimension()
|
info@54
|
96 |
|
info@54
|
97 |
this.$element
|
info@54
|
98 |
[dimension](this.$element[dimension]())
|
info@54
|
99 |
[0].offsetHeight
|
info@54
|
100 |
|
info@54
|
101 |
this.$element
|
info@54
|
102 |
.addClass('collapsing')
|
info@54
|
103 |
.removeClass('collapse')
|
info@54
|
104 |
.removeClass('in')
|
info@54
|
105 |
|
info@54
|
106 |
this.transitioning = 1
|
info@54
|
107 |
|
info@54
|
108 |
var complete = function () {
|
info@54
|
109 |
this.transitioning = 0
|
info@54
|
110 |
this.$element
|
info@54
|
111 |
.trigger('hidden.bs.collapse')
|
info@54
|
112 |
.removeClass('collapsing')
|
info@54
|
113 |
.addClass('collapse')
|
info@54
|
114 |
}
|
info@54
|
115 |
|
info@54
|
116 |
if (!$.support.transition) return complete.call(this)
|
info@54
|
117 |
|
info@54
|
118 |
this.$element
|
info@54
|
119 |
[dimension](0)
|
info@54
|
120 |
.one($.support.transition.end, $.proxy(complete, this))
|
info@54
|
121 |
.emulateTransitionEnd(350)
|
info@54
|
122 |
}
|
info@54
|
123 |
|
info@54
|
124 |
Collapse.prototype.toggle = function () {
|
info@54
|
125 |
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
info@54
|
126 |
}
|
info@54
|
127 |
|
info@54
|
128 |
|
info@54
|
129 |
// COLLAPSE PLUGIN DEFINITION
|
info@54
|
130 |
// ==========================
|
info@54
|
131 |
|
info@54
|
132 |
var old = $.fn.collapse
|
info@54
|
133 |
|
info@54
|
134 |
$.fn.collapse = function (option) {
|
info@54
|
135 |
return this.each(function () {
|
info@54
|
136 |
var $this = $(this)
|
info@54
|
137 |
var data = $this.data('bs.collapse')
|
info@54
|
138 |
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
info@54
|
139 |
|
info@54
|
140 |
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
info@54
|
141 |
if (typeof option == 'string') data[option]()
|
info@54
|
142 |
})
|
info@54
|
143 |
}
|
info@54
|
144 |
|
info@54
|
145 |
$.fn.collapse.Constructor = Collapse
|
info@54
|
146 |
|
info@54
|
147 |
|
info@54
|
148 |
// COLLAPSE NO CONFLICT
|
info@54
|
149 |
// ====================
|
info@54
|
150 |
|
info@54
|
151 |
$.fn.collapse.noConflict = function () {
|
info@54
|
152 |
$.fn.collapse = old
|
info@54
|
153 |
return this
|
info@54
|
154 |
}
|
info@54
|
155 |
|
info@54
|
156 |
|
info@54
|
157 |
// COLLAPSE DATA-API
|
info@54
|
158 |
// =================
|
info@54
|
159 |
|
info@54
|
160 |
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
|
info@54
|
161 |
var $this = $(this), href
|
info@54
|
162 |
var target = $this.attr('data-target')
|
info@54
|
163 |
|| e.preventDefault()
|
info@54
|
164 |
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
info@54
|
165 |
var $target = $(target)
|
info@54
|
166 |
var data = $target.data('bs.collapse')
|
info@54
|
167 |
var option = data ? 'toggle' : $this.data()
|
info@54
|
168 |
var parent = $this.attr('data-parent')
|
info@54
|
169 |
var $parent = parent && $(parent)
|
info@54
|
170 |
|
info@54
|
171 |
if (!data || !data.transitioning) {
|
info@54
|
172 |
if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
|
info@54
|
173 |
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
info@54
|
174 |
}
|
info@54
|
175 |
|
info@54
|
176 |
$target.collapse(option)
|
info@54
|
177 |
})
|
info@54
|
178 |
|
info@54
|
179 |
}(jQuery);
|