fix-twitter-bootstrap-rails 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +213 -0
- data/Rakefile +14 -0
- data/lib/generators/bootstrap/install/install_generator.rb +53 -0
- data/lib/generators/bootstrap/install/templates/application.css +7 -0
- data/lib/generators/bootstrap/install/templates/application.js +10 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.coffee +4 -0
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +19 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +23 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +99 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +71 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +72 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +19 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +13 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +3 -0
- data/lib/generators/bootstrap/themed/templates/index.html.erb +30 -0
- data/lib/generators/bootstrap/themed/templates/index.html.haml +25 -0
- data/lib/generators/bootstrap/themed/templates/index.html.slim +25 -0
- data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -0
- data/lib/generators/bootstrap/themed/templates/new.html.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/new.html.slim +2 -0
- data/lib/generators/bootstrap/themed/templates/show.html.erb +14 -0
- data/lib/generators/bootstrap/themed/templates/show.html.haml +9 -0
- data/lib/generators/bootstrap/themed/templates/show.html.slim +9 -0
- data/lib/generators/bootstrap/themed/themed_generator.rb +96 -0
- data/lib/twitter-bootstrap-rails.rb +10 -0
- data/lib/twitter/bootstrap/rails/bootstrap.rb +2 -0
- data/lib/twitter/bootstrap/rails/engine.rb +17 -0
- data/lib/twitter/bootstrap/rails/version.rb +7 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +94 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +100 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +157 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +136 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +92 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +210 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +95 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +125 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +130 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +270 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +51 -0
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +271 -0
- data/vendor/toolkit/twitter/bootstrap/accordion.less +28 -0
- data/vendor/toolkit/twitter/bootstrap/alerts.less +70 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +62 -0
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +22 -0
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +148 -0
- data/vendor/toolkit/twitter/bootstrap/buttons.less +183 -0
- data/vendor/toolkit/twitter/bootstrap/carousel.less +121 -0
- data/vendor/toolkit/twitter/bootstrap/close.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/code.less +57 -0
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +130 -0
- data/vendor/toolkit/twitter/bootstrap/forms.less +522 -0
- data/vendor/toolkit/twitter/bootstrap/grid.less +8 -0
- data/vendor/toolkit/twitter/bootstrap/hero-unit.less +20 -0
- data/vendor/toolkit/twitter/bootstrap/labels.less +32 -0
- data/vendor/toolkit/twitter/bootstrap/layouts.less +17 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +590 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +83 -0
- data/vendor/toolkit/twitter/bootstrap/navbar.less +299 -0
- data/vendor/toolkit/twitter/bootstrap/navs.less +353 -0
- data/vendor/toolkit/twitter/bootstrap/pager.less +30 -0
- data/vendor/toolkit/twitter/bootstrap/pagination.less +55 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +49 -0
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +95 -0
- data/vendor/toolkit/twitter/bootstrap/reset.less +126 -0
- data/vendor/toolkit/twitter/bootstrap/responsive.less +327 -0
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +29 -0
- data/vendor/toolkit/twitter/bootstrap/sprites.less +158 -0
- data/vendor/toolkit/twitter/bootstrap/tables.less +150 -0
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +35 -0
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +35 -0
- data/vendor/toolkit/twitter/bootstrap/type.less +218 -0
- data/vendor/toolkit/twitter/bootstrap/utilities.less +23 -0
- data/vendor/toolkit/twitter/bootstrap/variables.less +107 -0
- data/vendor/toolkit/twitter/bootstrap/wells.less +17 -0
- data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
- metadata +172 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
module Bootstrap
|
5
|
+
module Rails
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
|
8
|
+
initializer 'twitter-bootstrap-rails.setup',
|
9
|
+
:after => 'less-rails.after.load_config_initializers',
|
10
|
+
:group => :all do |app|
|
11
|
+
app.config.less.paths << File.join(config.root, 'vendor', 'toolkit')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
//= require twitter/bootstrap/bootstrap-transition
|
2
|
+
//= require twitter/bootstrap/bootstrap-alert
|
3
|
+
//= require twitter/bootstrap/bootstrap-modal
|
4
|
+
//= require twitter/bootstrap/bootstrap-dropdown
|
5
|
+
//= require twitter/bootstrap/bootstrap-scrollspy
|
6
|
+
//= require twitter/bootstrap/bootstrap-tab
|
7
|
+
//= require twitter/bootstrap/bootstrap-tooltip
|
8
|
+
//= require twitter/bootstrap/bootstrap-popover
|
9
|
+
//= require twitter/bootstrap/bootstrap-button
|
10
|
+
//= require twitter/bootstrap/bootstrap-collapse
|
11
|
+
//= require twitter/bootstrap/bootstrap-carousel
|
12
|
+
//= require twitter/bootstrap/bootstrap-typeahead
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-alert.js v2.0.1
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
4
|
+
* ==========================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
!function( $ ){
|
22
|
+
|
23
|
+
"use strict"
|
24
|
+
|
25
|
+
/* ALERT CLASS DEFINITION
|
26
|
+
* ====================== */
|
27
|
+
|
28
|
+
var dismiss = '[data-dismiss="alert"]'
|
29
|
+
, Alert = function ( el ) {
|
30
|
+
$(el).on('click', dismiss, this.close)
|
31
|
+
}
|
32
|
+
|
33
|
+
Alert.prototype = {
|
34
|
+
|
35
|
+
constructor: Alert
|
36
|
+
|
37
|
+
, close: function ( e ) {
|
38
|
+
var $this = $(this)
|
39
|
+
, selector = $this.attr('data-target')
|
40
|
+
, $parent
|
41
|
+
|
42
|
+
if (!selector) {
|
43
|
+
selector = $this.attr('href')
|
44
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
45
|
+
}
|
46
|
+
|
47
|
+
$parent = $(selector)
|
48
|
+
$parent.trigger('close')
|
49
|
+
|
50
|
+
e && e.preventDefault()
|
51
|
+
|
52
|
+
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
53
|
+
|
54
|
+
$parent
|
55
|
+
.trigger('close')
|
56
|
+
.removeClass('in')
|
57
|
+
|
58
|
+
function removeElement() {
|
59
|
+
$parent
|
60
|
+
.trigger('closed')
|
61
|
+
.remove()
|
62
|
+
}
|
63
|
+
|
64
|
+
$.support.transition && $parent.hasClass('fade') ?
|
65
|
+
$parent.on($.support.transition.end, removeElement) :
|
66
|
+
removeElement()
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
/* ALERT PLUGIN DEFINITION
|
73
|
+
* ======================= */
|
74
|
+
|
75
|
+
$.fn.alert = function ( option ) {
|
76
|
+
return this.each(function () {
|
77
|
+
var $this = $(this)
|
78
|
+
, data = $this.data('alert')
|
79
|
+
if (!data) $this.data('alert', (data = new Alert(this)))
|
80
|
+
if (typeof option == 'string') data[option].call($this)
|
81
|
+
})
|
82
|
+
}
|
83
|
+
|
84
|
+
$.fn.alert.Constructor = Alert
|
85
|
+
|
86
|
+
|
87
|
+
/* ALERT DATA-API
|
88
|
+
* ============== */
|
89
|
+
|
90
|
+
$(function () {
|
91
|
+
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
92
|
+
})
|
93
|
+
|
94
|
+
}( window.jQuery );
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/* ============================================================
|
2
|
+
* bootstrap-button.js v2.0.1
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
4
|
+
* ============================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
!function( $ ){
|
21
|
+
|
22
|
+
"use strict"
|
23
|
+
|
24
|
+
/* BUTTON PUBLIC CLASS DEFINITION
|
25
|
+
* ============================== */
|
26
|
+
|
27
|
+
var Button = function ( element, options ) {
|
28
|
+
this.$element = $(element)
|
29
|
+
this.options = $.extend({}, $.fn.button.defaults, options)
|
30
|
+
}
|
31
|
+
|
32
|
+
Button.prototype = {
|
33
|
+
|
34
|
+
constructor: Button
|
35
|
+
|
36
|
+
, setState: function ( state ) {
|
37
|
+
var d = 'disabled'
|
38
|
+
, $el = this.$element
|
39
|
+
, data = $el.data()
|
40
|
+
, val = $el.is('input') ? 'val' : 'html'
|
41
|
+
|
42
|
+
state = state + 'Text'
|
43
|
+
data.resetText || $el.data('resetText', $el[val]())
|
44
|
+
|
45
|
+
$el[val](data[state] || this.options[state])
|
46
|
+
|
47
|
+
// push to event loop to allow forms to submit
|
48
|
+
setTimeout(function () {
|
49
|
+
state == 'loadingText' ?
|
50
|
+
$el.addClass(d).attr(d, d) :
|
51
|
+
$el.removeClass(d).removeAttr(d)
|
52
|
+
}, 0)
|
53
|
+
}
|
54
|
+
|
55
|
+
, toggle: function () {
|
56
|
+
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
57
|
+
|
58
|
+
$parent && $parent
|
59
|
+
.find('.active')
|
60
|
+
.removeClass('active')
|
61
|
+
|
62
|
+
this.$element.toggleClass('active')
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
/* BUTTON PLUGIN DEFINITION
|
69
|
+
* ======================== */
|
70
|
+
|
71
|
+
$.fn.button = function ( option ) {
|
72
|
+
return this.each(function () {
|
73
|
+
var $this = $(this)
|
74
|
+
, data = $this.data('button')
|
75
|
+
, options = typeof option == 'object' && option
|
76
|
+
if (!data) $this.data('button', (data = new Button(this, options)))
|
77
|
+
if (option == 'toggle') data.toggle()
|
78
|
+
else if (option) data.setState(option)
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
82
|
+
$.fn.button.defaults = {
|
83
|
+
loadingText: 'loading...'
|
84
|
+
}
|
85
|
+
|
86
|
+
$.fn.button.Constructor = Button
|
87
|
+
|
88
|
+
|
89
|
+
/* BUTTON DATA-API
|
90
|
+
* =============== */
|
91
|
+
|
92
|
+
$(function () {
|
93
|
+
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
94
|
+
var $btn = $(e.target)
|
95
|
+
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
96
|
+
$btn.button('toggle')
|
97
|
+
})
|
98
|
+
})
|
99
|
+
|
100
|
+
}( window.jQuery );
|
@@ -0,0 +1,157 @@
|
|
1
|
+
/* ==========================================================
|
2
|
+
* bootstrap-carousel.js v2.0.1
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
4
|
+
* ==========================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================== */
|
19
|
+
|
20
|
+
|
21
|
+
!function( $ ){
|
22
|
+
|
23
|
+
"use strict"
|
24
|
+
|
25
|
+
/* CAROUSEL CLASS DEFINITION
|
26
|
+
* ========================= */
|
27
|
+
|
28
|
+
var Carousel = function (element, options) {
|
29
|
+
this.$element = $(element)
|
30
|
+
this.options = $.extend({}, $.fn.carousel.defaults, options)
|
31
|
+
this.options.slide && this.slide(this.options.slide)
|
32
|
+
}
|
33
|
+
|
34
|
+
Carousel.prototype = {
|
35
|
+
|
36
|
+
cycle: function () {
|
37
|
+
this.interval = setInterval($.proxy(this.next, this), this.options.interval)
|
38
|
+
return this
|
39
|
+
}
|
40
|
+
|
41
|
+
, to: function (pos) {
|
42
|
+
var $active = this.$element.find('.active')
|
43
|
+
, children = $active.parent().children()
|
44
|
+
, activePos = children.index($active)
|
45
|
+
, that = this
|
46
|
+
|
47
|
+
if (pos > (children.length - 1) || pos < 0) return
|
48
|
+
|
49
|
+
if (this.sliding) {
|
50
|
+
return this.$element.one('slid', function () {
|
51
|
+
that.to(pos)
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
if (activePos == pos) {
|
56
|
+
return this.pause().cycle()
|
57
|
+
}
|
58
|
+
|
59
|
+
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
|
60
|
+
}
|
61
|
+
|
62
|
+
, pause: function () {
|
63
|
+
clearInterval(this.interval)
|
64
|
+
this.interval = null
|
65
|
+
return this
|
66
|
+
}
|
67
|
+
|
68
|
+
, next: function () {
|
69
|
+
if (this.sliding) return
|
70
|
+
return this.slide('next')
|
71
|
+
}
|
72
|
+
|
73
|
+
, prev: function () {
|
74
|
+
if (this.sliding) return
|
75
|
+
return this.slide('prev')
|
76
|
+
}
|
77
|
+
|
78
|
+
, slide: function (type, next) {
|
79
|
+
var $active = this.$element.find('.active')
|
80
|
+
, $next = next || $active[type]()
|
81
|
+
, isCycling = this.interval
|
82
|
+
, direction = type == 'next' ? 'left' : 'right'
|
83
|
+
, fallback = type == 'next' ? 'first' : 'last'
|
84
|
+
, that = this
|
85
|
+
|
86
|
+
if (!$next.length) return
|
87
|
+
|
88
|
+
this.sliding = true
|
89
|
+
|
90
|
+
isCycling && this.pause()
|
91
|
+
|
92
|
+
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
|
93
|
+
|
94
|
+
if (!$.support.transition && this.$element.hasClass('slide')) {
|
95
|
+
this.$element.trigger('slide')
|
96
|
+
$active.removeClass('active')
|
97
|
+
$next.addClass('active')
|
98
|
+
this.sliding = false
|
99
|
+
this.$element.trigger('slid')
|
100
|
+
} else {
|
101
|
+
$next.addClass(type)
|
102
|
+
$next[0].offsetWidth // force reflow
|
103
|
+
$active.addClass(direction)
|
104
|
+
$next.addClass(direction)
|
105
|
+
this.$element.trigger('slide')
|
106
|
+
this.$element.one($.support.transition.end, function () {
|
107
|
+
$next.removeClass([type, direction].join(' ')).addClass('active')
|
108
|
+
$active.removeClass(['active', direction].join(' '))
|
109
|
+
that.sliding = false
|
110
|
+
setTimeout(function () { that.$element.trigger('slid') }, 0)
|
111
|
+
})
|
112
|
+
}
|
113
|
+
|
114
|
+
isCycling && this.cycle()
|
115
|
+
|
116
|
+
return this
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
/* CAROUSEL PLUGIN DEFINITION
|
123
|
+
* ========================== */
|
124
|
+
|
125
|
+
$.fn.carousel = function ( option ) {
|
126
|
+
return this.each(function () {
|
127
|
+
var $this = $(this)
|
128
|
+
, data = $this.data('carousel')
|
129
|
+
, options = typeof option == 'object' && option
|
130
|
+
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
|
131
|
+
if (typeof option == 'number') data.to(option)
|
132
|
+
else if (typeof option == 'string' || (option = options.slide)) data[option]()
|
133
|
+
else data.cycle()
|
134
|
+
})
|
135
|
+
}
|
136
|
+
|
137
|
+
$.fn.carousel.defaults = {
|
138
|
+
interval: 5000
|
139
|
+
}
|
140
|
+
|
141
|
+
$.fn.carousel.Constructor = Carousel
|
142
|
+
|
143
|
+
|
144
|
+
/* CAROUSEL DATA-API
|
145
|
+
* ================= */
|
146
|
+
|
147
|
+
$(function () {
|
148
|
+
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
|
149
|
+
var $this = $(this), href
|
150
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
151
|
+
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
|
152
|
+
$target.carousel(options)
|
153
|
+
e.preventDefault()
|
154
|
+
})
|
155
|
+
})
|
156
|
+
|
157
|
+
}( window.jQuery );
|
@@ -0,0 +1,136 @@
|
|
1
|
+
/* =============================================================
|
2
|
+
* bootstrap-collapse.js v2.0.1
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
4
|
+
* =============================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
!function( $ ){
|
21
|
+
|
22
|
+
"use strict"
|
23
|
+
|
24
|
+
var Collapse = function ( element, options ) {
|
25
|
+
this.$element = $(element)
|
26
|
+
this.options = $.extend({}, $.fn.collapse.defaults, options)
|
27
|
+
|
28
|
+
if (this.options["parent"]) {
|
29
|
+
this.$parent = $(this.options["parent"])
|
30
|
+
}
|
31
|
+
|
32
|
+
this.options.toggle && this.toggle()
|
33
|
+
}
|
34
|
+
|
35
|
+
Collapse.prototype = {
|
36
|
+
|
37
|
+
constructor: Collapse
|
38
|
+
|
39
|
+
, dimension: function () {
|
40
|
+
var hasWidth = this.$element.hasClass('width')
|
41
|
+
return hasWidth ? 'width' : 'height'
|
42
|
+
}
|
43
|
+
|
44
|
+
, show: function () {
|
45
|
+
var dimension = this.dimension()
|
46
|
+
, scroll = $.camelCase(['scroll', dimension].join('-'))
|
47
|
+
, actives = this.$parent && this.$parent.find('.in')
|
48
|
+
, hasData
|
49
|
+
|
50
|
+
if (actives && actives.length) {
|
51
|
+
hasData = actives.data('collapse')
|
52
|
+
actives.collapse('hide')
|
53
|
+
hasData || actives.data('collapse', null)
|
54
|
+
}
|
55
|
+
|
56
|
+
this.$element[dimension](0)
|
57
|
+
this.transition('addClass', 'show', 'shown')
|
58
|
+
this.$element[dimension](this.$element[0][scroll])
|
59
|
+
|
60
|
+
}
|
61
|
+
|
62
|
+
, hide: function () {
|
63
|
+
var dimension = this.dimension()
|
64
|
+
this.reset(this.$element[dimension]())
|
65
|
+
this.transition('removeClass', 'hide', 'hidden')
|
66
|
+
this.$element[dimension](0)
|
67
|
+
}
|
68
|
+
|
69
|
+
, reset: function ( size ) {
|
70
|
+
var dimension = this.dimension()
|
71
|
+
|
72
|
+
this.$element
|
73
|
+
.removeClass('collapse')
|
74
|
+
[dimension](size || 'auto')
|
75
|
+
[0].offsetWidth
|
76
|
+
|
77
|
+
this.$element.addClass('collapse')
|
78
|
+
}
|
79
|
+
|
80
|
+
, transition: function ( method, startEvent, completeEvent ) {
|
81
|
+
var that = this
|
82
|
+
, complete = function () {
|
83
|
+
if (startEvent == 'show') that.reset()
|
84
|
+
that.$element.trigger(completeEvent)
|
85
|
+
}
|
86
|
+
|
87
|
+
this.$element
|
88
|
+
.trigger(startEvent)
|
89
|
+
[method]('in')
|
90
|
+
|
91
|
+
$.support.transition && this.$element.hasClass('collapse') ?
|
92
|
+
this.$element.one($.support.transition.end, complete) :
|
93
|
+
complete()
|
94
|
+
}
|
95
|
+
|
96
|
+
, toggle: function () {
|
97
|
+
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
98
|
+
}
|
99
|
+
|
100
|
+
}
|
101
|
+
|
102
|
+
/* COLLAPSIBLE PLUGIN DEFINITION
|
103
|
+
* ============================== */
|
104
|
+
|
105
|
+
$.fn.collapse = function ( option ) {
|
106
|
+
return this.each(function () {
|
107
|
+
var $this = $(this)
|
108
|
+
, data = $this.data('collapse')
|
109
|
+
, options = typeof option == 'object' && option
|
110
|
+
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
|
111
|
+
if (typeof option == 'string') data[option]()
|
112
|
+
})
|
113
|
+
}
|
114
|
+
|
115
|
+
$.fn.collapse.defaults = {
|
116
|
+
toggle: true
|
117
|
+
}
|
118
|
+
|
119
|
+
$.fn.collapse.Constructor = Collapse
|
120
|
+
|
121
|
+
|
122
|
+
/* COLLAPSIBLE DATA-API
|
123
|
+
* ==================== */
|
124
|
+
|
125
|
+
$(function () {
|
126
|
+
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
|
127
|
+
var $this = $(this), href
|
128
|
+
, target = $this.attr('data-target')
|
129
|
+
|| e.preventDefault()
|
130
|
+
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
131
|
+
, option = $(target).data('collapse') ? 'toggle' : $this.data()
|
132
|
+
$(target).collapse(option)
|
133
|
+
})
|
134
|
+
})
|
135
|
+
|
136
|
+
}( window.jQuery );
|