annotate static/bootstrap/js/collapse.js @ 158:e53a3b64dfd8

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