twitter-bootstrap-rails 3.2.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of twitter-bootstrap-rails might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +263 -247
- data/app/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.svg +273 -214
- data/app/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/assets/javascripts/twitter/bootstrap/affix.js +60 -35
- data/app/assets/javascripts/twitter/bootstrap/alert.js +15 -9
- data/app/assets/javascripts/twitter/bootstrap/button.js +33 -20
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +79 -47
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +84 -43
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +65 -47
- data/app/assets/javascripts/twitter/bootstrap/modal.js +138 -44
- data/app/assets/javascripts/twitter/bootstrap/popover.js +12 -14
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +57 -38
- data/app/assets/javascripts/twitter/bootstrap/tab.js +54 -24
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +202 -87
- data/app/assets/javascripts/twitter/bootstrap/transition.js +19 -8
- data/app/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -1
- data/app/assets/stylesheets/twitter-bootstrap-static/sprites.css.erb +1 -1
- data/app/helpers/bootstrap_flash_helper.rb +8 -3
- data/app/helpers/form_errors_helper.rb +11 -11
- data/app/helpers/glyph_helper.rb +7 -3
- data/app/helpers/modal_helper.rb +9 -13
- data/app/helpers/navbar_helper.rb +5 -2
- data/app/helpers/twitter_breadcrumbs_helper.rb +4 -1
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +5 -5
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.css +3 -4
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +7 -15
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +5 -5
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +3 -3
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +3 -5
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +12 -9
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +7 -5
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -6
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/index.html.erb +2 -0
- data/lib/generators/bootstrap/themed/templates/index.html.haml +1 -0
- data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -3
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +1 -1
- data/lib/twitter/bootstrap/rails/breadcrumbs.rb +24 -13
- data/lib/twitter/bootstrap/rails/engine.rb +17 -12
- data/lib/twitter/bootstrap/rails/version.rb +1 -1
- data/spec/lib/breadcrumbs_spec.rb +42 -17
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +10 -4
- data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +128 -0
- data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +148 -0
- data/spec/lib/twitter_bootstrap_rails/glyph_helper_spec.rb +24 -0
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +2 -2
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +62 -12
- data/spec/spec_helper.rb +5 -1
- data/vendor/assets/stylesheets/twitter-bootstrap-static/bootstrap.css.erb +1 -3
- data/vendor/toolkit/twitter/bootstrap/alerts.less +5 -0
- data/vendor/toolkit/twitter/bootstrap/badges.less +14 -3
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +6 -1
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +13 -14
- data/vendor/toolkit/twitter/bootstrap/buttons.less +14 -7
- data/vendor/toolkit/twitter/bootstrap/carousel.less +34 -7
- data/vendor/toolkit/twitter/bootstrap/close.less +1 -0
- data/vendor/toolkit/twitter/bootstrap/code.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/component-animations.less +3 -1
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +9 -8
- data/vendor/toolkit/twitter/bootstrap/forms.less +110 -41
- data/vendor/toolkit/twitter/bootstrap/glyphicons.less +75 -3
- data/vendor/toolkit/twitter/bootstrap/grid.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/input-groups.less +8 -3
- data/vendor/toolkit/twitter/bootstrap/jumbotron.less +10 -4
- data/vendor/toolkit/twitter/bootstrap/labels.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/list-group.less +11 -13
- data/vendor/toolkit/twitter/bootstrap/media.less +40 -30
- data/vendor/toolkit/twitter/bootstrap/mixins/alerts.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/background-variant.less +2 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/border-radius.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/buttons.less +19 -6
- data/vendor/toolkit/twitter/bootstrap/mixins/center-block.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/clearfix.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/forms.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/gradients.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/grid-framework.less +4 -4
- data/vendor/toolkit/twitter/bootstrap/mixins/grid.less +4 -4
- data/vendor/toolkit/twitter/bootstrap/mixins/hide-text.less +2 -2
- data/vendor/toolkit/twitter/bootstrap/mixins/image.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/labels.less +1 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/list-group.less +2 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-divider.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/nav-vertical-align.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/opacity.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/pagination.less +2 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/panels.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/progress-bar.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/reset-filter.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/reset-text.less +18 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/resize.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/responsive-visibility.less +1 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/size.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/tab-focus.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/table-row.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/text-emphasis.less +2 -1
- data/vendor/toolkit/twitter/bootstrap/mixins/text-overflow.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/mixins/vendor-prefixes.less +8 -5
- data/vendor/toolkit/twitter/bootstrap/mixins.less +1 -0
- data/vendor/toolkit/twitter/bootstrap/modals.less +3 -3
- data/vendor/toolkit/twitter/bootstrap/navbar.less +6 -1
- data/vendor/toolkit/twitter/bootstrap/navs.less +1 -1
- data/vendor/toolkit/twitter/bootstrap/normalize.less +12 -13
- data/vendor/toolkit/twitter/bootstrap/pager.less +1 -2
- data/vendor/toolkit/twitter/bootstrap/pagination.less +5 -4
- data/vendor/toolkit/twitter/bootstrap/panels.less +27 -4
- data/vendor/toolkit/twitter/bootstrap/popovers.less +5 -7
- data/vendor/toolkit/twitter/bootstrap/print.less +96 -96
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +1 -14
- data/vendor/toolkit/twitter/bootstrap/responsive-embed.less +10 -9
- data/vendor/toolkit/twitter/bootstrap/responsive-utilities.less +0 -0
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +12 -1
- data/vendor/toolkit/twitter/bootstrap/tables.less +6 -5
- data/vendor/toolkit/twitter/bootstrap/theme.less +47 -16
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +1 -1
- data/vendor/toolkit/twitter/bootstrap/tooltip.less +13 -7
- data/vendor/toolkit/twitter/bootstrap/type.less +2 -8
- data/vendor/toolkit/twitter/bootstrap/utilities.less +0 -1
- data/vendor/toolkit/twitter/bootstrap/variables.less +36 -14
- data/vendor/toolkit/twitter/bootstrap/wells.less +0 -0
- metadata +76 -52
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +0 -504
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
- data/app/assets/stylesheets/twitter-bootstrap-static/fontawesome.css.erb +0 -4
- data/vendor/static-source/fontawesome.less +0 -8
- data/vendor/toolkit/fontawesome/bordered-pulled.less +0 -16
- data/vendor/toolkit/fontawesome/core.less +0 -12
- data/vendor/toolkit/fontawesome/fixed-width.less +0 -6
- data/vendor/toolkit/fontawesome/font-awesome.less +0 -17
- data/vendor/toolkit/fontawesome/icons.less +0 -506
- data/vendor/toolkit/fontawesome/larger.less +0 -13
- data/vendor/toolkit/fontawesome/list.less +0 -19
- data/vendor/toolkit/fontawesome/mixins.less +0 -20
- data/vendor/toolkit/fontawesome/path.less +0 -14
- data/vendor/toolkit/fontawesome/rotated-flipped.less +0 -9
- data/vendor/toolkit/fontawesome/spinning.less +0 -32
- data/vendor/toolkit/fontawesome/stacked.less +0 -20
- data/vendor/toolkit/fontawesome/variables.less +0 -515
@@ -1,8 +1,8 @@
|
|
1
1
|
/* ========================================================================
|
2
|
-
* Bootstrap: collapse.js v3.
|
2
|
+
* Bootstrap: collapse.js v3.3.6
|
3
3
|
* http://getbootstrap.com/javascript/#collapse
|
4
4
|
* ========================================================================
|
5
|
-
* Copyright 2011-
|
5
|
+
* Copyright 2011-2015 Twitter, Inc.
|
6
6
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
7
7
|
* ======================================================================== */
|
8
8
|
|
@@ -16,12 +16,23 @@
|
|
16
16
|
var Collapse = function (element, options) {
|
17
17
|
this.$element = $(element)
|
18
18
|
this.options = $.extend({}, Collapse.DEFAULTS, options)
|
19
|
+
this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
|
20
|
+
'[data-toggle="collapse"][data-target="#' + element.id + '"]')
|
19
21
|
this.transitioning = null
|
20
22
|
|
21
|
-
if (this.options.parent)
|
23
|
+
if (this.options.parent) {
|
24
|
+
this.$parent = this.getParent()
|
25
|
+
} else {
|
26
|
+
this.addAriaAndCollapsedClass(this.$element, this.$trigger)
|
27
|
+
}
|
28
|
+
|
22
29
|
if (this.options.toggle) this.toggle()
|
23
30
|
}
|
24
31
|
|
32
|
+
Collapse.VERSION = '3.3.6'
|
33
|
+
|
34
|
+
Collapse.TRANSITION_DURATION = 350
|
35
|
+
|
25
36
|
Collapse.DEFAULTS = {
|
26
37
|
toggle: true
|
27
38
|
}
|
@@ -34,35 +45,43 @@
|
|
34
45
|
Collapse.prototype.show = function () {
|
35
46
|
if (this.transitioning || this.$element.hasClass('in')) return
|
36
47
|
|
48
|
+
var activesData
|
49
|
+
var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')
|
50
|
+
|
51
|
+
if (actives && actives.length) {
|
52
|
+
activesData = actives.data('bs.collapse')
|
53
|
+
if (activesData && activesData.transitioning) return
|
54
|
+
}
|
55
|
+
|
37
56
|
var startEvent = $.Event('show.bs.collapse')
|
38
57
|
this.$element.trigger(startEvent)
|
39
58
|
if (startEvent.isDefaultPrevented()) return
|
40
59
|
|
41
|
-
var actives = this.$parent && this.$parent.find('> .panel > .in')
|
42
|
-
|
43
60
|
if (actives && actives.length) {
|
44
|
-
|
45
|
-
|
46
|
-
actives.collapse('hide')
|
47
|
-
hasData || actives.data('bs.collapse', null)
|
61
|
+
Plugin.call(actives, 'hide')
|
62
|
+
activesData || actives.data('bs.collapse', null)
|
48
63
|
}
|
49
64
|
|
50
65
|
var dimension = this.dimension()
|
51
66
|
|
52
67
|
this.$element
|
53
68
|
.removeClass('collapse')
|
54
|
-
.addClass('collapsing')
|
55
|
-
|
69
|
+
.addClass('collapsing')[dimension](0)
|
70
|
+
.attr('aria-expanded', true)
|
71
|
+
|
72
|
+
this.$trigger
|
73
|
+
.removeClass('collapsed')
|
74
|
+
.attr('aria-expanded', true)
|
56
75
|
|
57
76
|
this.transitioning = 1
|
58
77
|
|
59
78
|
var complete = function () {
|
60
79
|
this.$element
|
61
80
|
.removeClass('collapsing')
|
62
|
-
.addClass('collapse in')
|
63
|
-
[dimension]('auto')
|
81
|
+
.addClass('collapse in')[dimension]('')
|
64
82
|
this.transitioning = 0
|
65
|
-
this.$element
|
83
|
+
this.$element
|
84
|
+
.trigger('shown.bs.collapse')
|
66
85
|
}
|
67
86
|
|
68
87
|
if (!$.support.transition) return complete.call(this)
|
@@ -70,9 +89,8 @@
|
|
70
89
|
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
|
71
90
|
|
72
91
|
this.$element
|
73
|
-
.one(
|
74
|
-
.emulateTransitionEnd(
|
75
|
-
[dimension](this.$element[0][scrollSize])
|
92
|
+
.one('bsTransitionEnd', $.proxy(complete, this))
|
93
|
+
.emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])
|
76
94
|
}
|
77
95
|
|
78
96
|
Collapse.prototype.hide = function () {
|
@@ -84,55 +102,85 @@
|
|
84
102
|
|
85
103
|
var dimension = this.dimension()
|
86
104
|
|
87
|
-
this.$element
|
88
|
-
[dimension](this.$element[dimension]())
|
89
|
-
[0].offsetHeight
|
105
|
+
this.$element[dimension](this.$element[dimension]())[0].offsetHeight
|
90
106
|
|
91
107
|
this.$element
|
92
108
|
.addClass('collapsing')
|
93
|
-
.removeClass('collapse')
|
94
|
-
.
|
109
|
+
.removeClass('collapse in')
|
110
|
+
.attr('aria-expanded', false)
|
111
|
+
|
112
|
+
this.$trigger
|
113
|
+
.addClass('collapsed')
|
114
|
+
.attr('aria-expanded', false)
|
95
115
|
|
96
116
|
this.transitioning = 1
|
97
117
|
|
98
118
|
var complete = function () {
|
99
119
|
this.transitioning = 0
|
100
120
|
this.$element
|
101
|
-
.trigger('hidden.bs.collapse')
|
102
121
|
.removeClass('collapsing')
|
103
122
|
.addClass('collapse')
|
123
|
+
.trigger('hidden.bs.collapse')
|
104
124
|
}
|
105
125
|
|
106
126
|
if (!$.support.transition) return complete.call(this)
|
107
127
|
|
108
128
|
this.$element
|
109
129
|
[dimension](0)
|
110
|
-
.one(
|
111
|
-
.emulateTransitionEnd(
|
130
|
+
.one('bsTransitionEnd', $.proxy(complete, this))
|
131
|
+
.emulateTransitionEnd(Collapse.TRANSITION_DURATION)
|
112
132
|
}
|
113
133
|
|
114
134
|
Collapse.prototype.toggle = function () {
|
115
135
|
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
116
136
|
}
|
117
137
|
|
138
|
+
Collapse.prototype.getParent = function () {
|
139
|
+
return $(this.options.parent)
|
140
|
+
.find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]')
|
141
|
+
.each($.proxy(function (i, element) {
|
142
|
+
var $element = $(element)
|
143
|
+
this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)
|
144
|
+
}, this))
|
145
|
+
.end()
|
146
|
+
}
|
147
|
+
|
148
|
+
Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
|
149
|
+
var isOpen = $element.hasClass('in')
|
150
|
+
|
151
|
+
$element.attr('aria-expanded', isOpen)
|
152
|
+
$trigger
|
153
|
+
.toggleClass('collapsed', !isOpen)
|
154
|
+
.attr('aria-expanded', isOpen)
|
155
|
+
}
|
156
|
+
|
157
|
+
function getTargetFromTrigger($trigger) {
|
158
|
+
var href
|
159
|
+
var target = $trigger.attr('data-target')
|
160
|
+
|| (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
|
161
|
+
|
162
|
+
return $(target)
|
163
|
+
}
|
164
|
+
|
118
165
|
|
119
166
|
// COLLAPSE PLUGIN DEFINITION
|
120
167
|
// ==========================
|
121
168
|
|
122
|
-
|
123
|
-
|
124
|
-
$.fn.collapse = function (option) {
|
169
|
+
function Plugin(option) {
|
125
170
|
return this.each(function () {
|
126
171
|
var $this = $(this)
|
127
172
|
var data = $this.data('bs.collapse')
|
128
173
|
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
129
174
|
|
130
|
-
if (!data && options.toggle && option
|
175
|
+
if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false
|
131
176
|
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
|
132
177
|
if (typeof option == 'string') data[option]()
|
133
178
|
})
|
134
179
|
}
|
135
180
|
|
181
|
+
var old = $.fn.collapse
|
182
|
+
|
183
|
+
$.fn.collapse = Plugin
|
136
184
|
$.fn.collapse.Constructor = Collapse
|
137
185
|
|
138
186
|
|
@@ -148,23 +196,16 @@
|
|
148
196
|
// COLLAPSE DATA-API
|
149
197
|
// =================
|
150
198
|
|
151
|
-
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
|
152
|
-
var $this = $(this)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
var $target = $
|
199
|
+
$(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
|
200
|
+
var $this = $(this)
|
201
|
+
|
202
|
+
if (!$this.attr('data-target')) e.preventDefault()
|
203
|
+
|
204
|
+
var $target = getTargetFromTrigger($this)
|
157
205
|
var data = $target.data('bs.collapse')
|
158
206
|
var option = data ? 'toggle' : $this.data()
|
159
|
-
var parent = $this.attr('data-parent')
|
160
|
-
var $parent = parent && $(parent)
|
161
|
-
|
162
|
-
if (!data || !data.transitioning) {
|
163
|
-
if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
|
164
|
-
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
165
|
-
}
|
166
207
|
|
167
|
-
$target
|
208
|
+
Plugin.call($target, option)
|
168
209
|
})
|
169
210
|
|
170
211
|
}(jQuery);
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/* ========================================================================
|
2
|
-
* Bootstrap: dropdown.js v3.
|
2
|
+
* Bootstrap: dropdown.js v3.3.6
|
3
3
|
* http://getbootstrap.com/javascript/#dropdowns
|
4
4
|
* ========================================================================
|
5
|
-
* Copyright 2011-
|
5
|
+
* Copyright 2011-2015 Twitter, Inc.
|
6
6
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
7
7
|
* ======================================================================== */
|
8
8
|
|
@@ -14,11 +14,47 @@
|
|
14
14
|
// =========================
|
15
15
|
|
16
16
|
var backdrop = '.dropdown-backdrop'
|
17
|
-
var toggle = '[data-toggle=dropdown]'
|
17
|
+
var toggle = '[data-toggle="dropdown"]'
|
18
18
|
var Dropdown = function (element) {
|
19
19
|
$(element).on('click.bs.dropdown', this.toggle)
|
20
20
|
}
|
21
21
|
|
22
|
+
Dropdown.VERSION = '3.3.6'
|
23
|
+
|
24
|
+
function getParent($this) {
|
25
|
+
var selector = $this.attr('data-target')
|
26
|
+
|
27
|
+
if (!selector) {
|
28
|
+
selector = $this.attr('href')
|
29
|
+
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
30
|
+
}
|
31
|
+
|
32
|
+
var $parent = selector && $(selector)
|
33
|
+
|
34
|
+
return $parent && $parent.length ? $parent : $this.parent()
|
35
|
+
}
|
36
|
+
|
37
|
+
function clearMenus(e) {
|
38
|
+
if (e && e.which === 3) return
|
39
|
+
$(backdrop).remove()
|
40
|
+
$(toggle).each(function () {
|
41
|
+
var $this = $(this)
|
42
|
+
var $parent = getParent($this)
|
43
|
+
var relatedTarget = { relatedTarget: this }
|
44
|
+
|
45
|
+
if (!$parent.hasClass('open')) return
|
46
|
+
|
47
|
+
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
|
48
|
+
|
49
|
+
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
|
50
|
+
|
51
|
+
if (e.isDefaultPrevented()) return
|
52
|
+
|
53
|
+
$this.attr('aria-expanded', 'false')
|
54
|
+
$parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
|
55
|
+
})
|
56
|
+
}
|
57
|
+
|
22
58
|
Dropdown.prototype.toggle = function (e) {
|
23
59
|
var $this = $(this)
|
24
60
|
|
@@ -32,7 +68,10 @@
|
|
32
68
|
if (!isActive) {
|
33
69
|
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
|
34
70
|
// if mobile we use a backdrop because click events don't delegate
|
35
|
-
$('
|
71
|
+
$(document.createElement('div'))
|
72
|
+
.addClass('dropdown-backdrop')
|
73
|
+
.insertAfter($(this))
|
74
|
+
.on('click', clearMenus)
|
36
75
|
}
|
37
76
|
|
38
77
|
var relatedTarget = { relatedTarget: this }
|
@@ -40,18 +79,20 @@
|
|
40
79
|
|
41
80
|
if (e.isDefaultPrevented()) return
|
42
81
|
|
82
|
+
$this
|
83
|
+
.trigger('focus')
|
84
|
+
.attr('aria-expanded', 'true')
|
85
|
+
|
43
86
|
$parent
|
44
87
|
.toggleClass('open')
|
45
|
-
.trigger('shown.bs.dropdown', relatedTarget)
|
46
|
-
|
47
|
-
$this.focus()
|
88
|
+
.trigger($.Event('shown.bs.dropdown', relatedTarget))
|
48
89
|
}
|
49
90
|
|
50
91
|
return false
|
51
92
|
}
|
52
93
|
|
53
94
|
Dropdown.prototype.keydown = function (e) {
|
54
|
-
if (!/(38|40|27)/.test(e.
|
95
|
+
if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
|
55
96
|
|
56
97
|
var $this = $(this)
|
57
98
|
|
@@ -63,57 +104,30 @@
|
|
63
104
|
var $parent = getParent($this)
|
64
105
|
var isActive = $parent.hasClass('open')
|
65
106
|
|
66
|
-
if (!isActive ||
|
67
|
-
if (e.which == 27) $parent.find(toggle).focus
|
68
|
-
return $this.click
|
107
|
+
if (!isActive && e.which != 27 || isActive && e.which == 27) {
|
108
|
+
if (e.which == 27) $parent.find(toggle).trigger('focus')
|
109
|
+
return $this.trigger('click')
|
69
110
|
}
|
70
111
|
|
71
|
-
var desc = ' li:not(.
|
72
|
-
var $items = $parent.find('
|
112
|
+
var desc = ' li:not(.disabled):visible a'
|
113
|
+
var $items = $parent.find('.dropdown-menu' + desc)
|
73
114
|
|
74
115
|
if (!$items.length) return
|
75
116
|
|
76
|
-
var index = $items.index(
|
77
|
-
|
78
|
-
if (e.keyCode == 38 && index > 0) index-- // up
|
79
|
-
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
80
|
-
if (!~index) index = 0
|
81
|
-
|
82
|
-
$items.eq(index).focus()
|
83
|
-
}
|
84
|
-
|
85
|
-
function clearMenus(e) {
|
86
|
-
$(backdrop).remove()
|
87
|
-
$(toggle).each(function () {
|
88
|
-
var $parent = getParent($(this))
|
89
|
-
var relatedTarget = { relatedTarget: this }
|
90
|
-
if (!$parent.hasClass('open')) return
|
91
|
-
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
|
92
|
-
if (e.isDefaultPrevented()) return
|
93
|
-
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
|
94
|
-
})
|
95
|
-
}
|
96
|
-
|
97
|
-
function getParent($this) {
|
98
|
-
var selector = $this.attr('data-target')
|
99
|
-
|
100
|
-
if (!selector) {
|
101
|
-
selector = $this.attr('href')
|
102
|
-
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
103
|
-
}
|
117
|
+
var index = $items.index(e.target)
|
104
118
|
|
105
|
-
|
119
|
+
if (e.which == 38 && index > 0) index-- // up
|
120
|
+
if (e.which == 40 && index < $items.length - 1) index++ // down
|
121
|
+
if (!~index) index = 0
|
106
122
|
|
107
|
-
|
123
|
+
$items.eq(index).trigger('focus')
|
108
124
|
}
|
109
125
|
|
110
126
|
|
111
127
|
// DROPDOWN PLUGIN DEFINITION
|
112
128
|
// ==========================
|
113
129
|
|
114
|
-
|
115
|
-
|
116
|
-
$.fn.dropdown = function (option) {
|
130
|
+
function Plugin(option) {
|
117
131
|
return this.each(function () {
|
118
132
|
var $this = $(this)
|
119
133
|
var data = $this.data('bs.dropdown')
|
@@ -123,6 +137,9 @@
|
|
123
137
|
})
|
124
138
|
}
|
125
139
|
|
140
|
+
var old = $.fn.dropdown
|
141
|
+
|
142
|
+
$.fn.dropdown = Plugin
|
126
143
|
$.fn.dropdown.Constructor = Dropdown
|
127
144
|
|
128
145
|
|
@@ -142,6 +159,7 @@
|
|
142
159
|
.on('click.bs.dropdown.data-api', clearMenus)
|
143
160
|
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
144
161
|
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
145
|
-
.on('keydown.bs.dropdown.data-api', toggle
|
162
|
+
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
|
163
|
+
.on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
|
146
164
|
|
147
165
|
}(jQuery);
|