twitter-bootstrap-rails 2.0 → 2.0.1.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.
- data/README.md +31 -37
- data/Rakefile +11 -0
- data/lib/generators/bootstrap/install/install_generator.rb +37 -13
- data/lib/generators/bootstrap/install/templates/application.css +0 -1
- data/lib/generators/bootstrap/install/templates/bootstrap.coffee +6 -15
- data/lib/generators/bootstrap/install/templates/bootstrap_and_overrides.less +13 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +4 -4
- data/lib/generators/bootstrap/layout/templates/layout.html.erb +96 -49
- data/lib/generators/bootstrap/layout/templates/layout.html.haml +76 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +77 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.erb +5 -4
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +11 -0
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +11 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -2
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +3 -0
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +3 -0
- data/lib/generators/bootstrap/themed/templates/index.html.erb +27 -28
- 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.haml +2 -0
- data/lib/generators/bootstrap/themed/templates/new.html.slim +2 -0
- data/lib/generators/bootstrap/themed/templates/show.html.erb +5 -4
- 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 +13 -13
- data/lib/twitter/bootstrap/rails/version.rb +1 -1
- 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/bootstrap-alert.js +16 -7
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +3 -3
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +7 -4
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +7 -5
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +16 -7
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +12 -7
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +5 -5
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +4 -3
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +11 -6
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +2 -2
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +3 -3
- data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +40 -21
- data/vendor/toolkit/twitter/bootstrap/accordion.less +5 -4
- data/vendor/toolkit/twitter/bootstrap/alerts.less +1 -0
- data/vendor/toolkit/twitter/bootstrap/bootstrap.less +10 -8
- data/vendor/toolkit/twitter/bootstrap/breadcrumbs.less +1 -1
- data/vendor/toolkit/twitter/bootstrap/button-groups.less +49 -17
- data/vendor/toolkit/twitter/bootstrap/buttons.less +156 -89
- data/vendor/toolkit/twitter/bootstrap/carousel.less +12 -5
- data/vendor/toolkit/twitter/bootstrap/code.less +57 -0
- data/vendor/toolkit/twitter/bootstrap/dropdowns.less +24 -4
- data/vendor/toolkit/twitter/bootstrap/forms.less +117 -91
- 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 +23 -7
- data/vendor/toolkit/twitter/bootstrap/layouts.less +17 -0
- data/vendor/toolkit/twitter/bootstrap/mixins.less +253 -36
- data/vendor/toolkit/twitter/bootstrap/modals.less +20 -2
- data/vendor/toolkit/twitter/bootstrap/navbar.less +82 -34
- data/vendor/toolkit/twitter/bootstrap/navs.less +87 -72
- data/vendor/toolkit/twitter/bootstrap/pager.less +7 -2
- data/vendor/toolkit/twitter/bootstrap/pagination.less +1 -0
- data/vendor/toolkit/twitter/bootstrap/popovers.less +25 -25
- data/vendor/toolkit/twitter/bootstrap/progress-bars.less +14 -18
- data/vendor/toolkit/twitter/bootstrap/reset.less +3 -4
- data/vendor/toolkit/twitter/bootstrap/responsive.less +224 -165
- data/vendor/toolkit/twitter/bootstrap/scaffolding.less +6 -89
- data/vendor/toolkit/twitter/bootstrap/sprites.less +139 -99
- data/vendor/toolkit/twitter/bootstrap/tables.less +15 -57
- data/vendor/toolkit/twitter/bootstrap/thumbnails.less +4 -2
- data/vendor/toolkit/twitter/bootstrap/type.less +15 -44
- data/vendor/toolkit/twitter/bootstrap/variables.less +38 -21
- data/vendor/toolkit/twitter/bootstrap_base.less +2 -0
- metadata +36 -21
- data/lib/generators/bootstrap/install/templates/bootstrap.less +0 -5
- data/vendor/assets/stylesheets/twitter/bootstrap.css.less +0 -1
- data/vendor/toolkit/twitter/bootstrap.less +0 -1
- data/vendor/toolkit/twitter/bootstrap/patterns.less +0 -30
- data/vendor/toolkit/twitter/bootstrap/print.less +0 -18
Binary file
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ==========================================================
|
2
|
-
* bootstrap-alert.js v2.0.
|
2
|
+
* bootstrap-alert.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
4
4
|
* ==========================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -36,20 +36,29 @@
|
|
36
36
|
|
37
37
|
, close: function ( e ) {
|
38
38
|
var $this = $(this)
|
39
|
-
, selector = $this.attr('data-target')
|
40
|
-
, $parent
|
39
|
+
, selector = $this.attr('data-target')
|
40
|
+
, $parent
|
41
41
|
|
42
|
+
if (!selector) {
|
43
|
+
selector = $this.attr('href')
|
44
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
45
|
+
}
|
46
|
+
|
47
|
+
$parent = $(selector)
|
42
48
|
$parent.trigger('close')
|
43
49
|
|
44
50
|
e && e.preventDefault()
|
45
51
|
|
46
52
|
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
47
53
|
|
48
|
-
$parent
|
54
|
+
$parent
|
55
|
+
.trigger('close')
|
56
|
+
.removeClass('in')
|
49
57
|
|
50
58
|
function removeElement() {
|
51
|
-
$parent
|
52
|
-
|
59
|
+
$parent
|
60
|
+
.trigger('closed')
|
61
|
+
.remove()
|
53
62
|
}
|
54
63
|
|
55
64
|
$.support.transition && $parent.hasClass('fade') ?
|
@@ -82,4 +91,4 @@
|
|
82
91
|
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
83
92
|
})
|
84
93
|
|
85
|
-
}( window.jQuery )
|
94
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ============================================================
|
2
|
-
* bootstrap-button.js v2.0.
|
2
|
+
* bootstrap-button.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
4
4
|
* ============================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -91,8 +91,8 @@
|
|
91
91
|
|
92
92
|
$(function () {
|
93
93
|
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
|
94
|
-
$(e.
|
94
|
+
$(e.currentTarget).button('toggle')
|
95
95
|
})
|
96
96
|
})
|
97
97
|
|
98
|
-
}( window.jQuery )
|
98
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ==========================================================
|
2
|
-
* bootstrap-carousel.js v2.0.
|
2
|
+
* bootstrap-carousel.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
4
4
|
* ==========================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -61,6 +61,7 @@
|
|
61
61
|
|
62
62
|
, pause: function () {
|
63
63
|
clearInterval(this.interval)
|
64
|
+
this.interval = null
|
64
65
|
return this
|
65
66
|
}
|
66
67
|
|
@@ -82,6 +83,8 @@
|
|
82
83
|
, fallback = type == 'next' ? 'first' : 'last'
|
83
84
|
, that = this
|
84
85
|
|
86
|
+
if (!$next.length) return
|
87
|
+
|
85
88
|
this.sliding = true
|
86
89
|
|
87
90
|
isCycling && this.pause()
|
@@ -143,12 +146,12 @@
|
|
143
146
|
|
144
147
|
$(function () {
|
145
148
|
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
|
146
|
-
var $this = $(this)
|
147
|
-
, $target = $($this.attr('data-target') || $this.attr('href'))
|
149
|
+
var $this = $(this), href
|
150
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
148
151
|
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
|
149
152
|
$target.carousel(options)
|
150
153
|
e.preventDefault()
|
151
154
|
})
|
152
155
|
})
|
153
156
|
|
154
|
-
}( window.jQuery )
|
157
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =============================================================
|
2
|
-
* bootstrap-collapse.js v2.0.
|
2
|
+
* bootstrap-collapse.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
4
4
|
* =============================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -71,7 +71,7 @@
|
|
71
71
|
|
72
72
|
this.$element
|
73
73
|
.removeClass('collapse')
|
74
|
-
[dimension](size || '')
|
74
|
+
[dimension](size || 'auto')
|
75
75
|
[0].offsetWidth
|
76
76
|
|
77
77
|
this.$element.addClass('collapse')
|
@@ -124,11 +124,13 @@
|
|
124
124
|
|
125
125
|
$(function () {
|
126
126
|
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
|
127
|
-
var $this = $(this)
|
128
|
-
, target = $this.attr('data-target')
|
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
|
129
131
|
, option = $(target).data('collapse') ? 'toggle' : $this.data()
|
130
132
|
$(target).collapse(option)
|
131
133
|
})
|
132
134
|
})
|
133
135
|
|
134
|
-
}( window.jQuery )
|
136
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ============================================================
|
2
|
-
* bootstrap-dropdown.js v2.0.
|
2
|
+
* bootstrap-dropdown.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
4
4
|
* ============================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -27,7 +27,10 @@
|
|
27
27
|
|
28
28
|
var toggle = '[data-toggle="dropdown"]'
|
29
29
|
, Dropdown = function ( element ) {
|
30
|
-
$(element).
|
30
|
+
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
31
|
+
$('html').on('click.dropdown.data-api', function () {
|
32
|
+
$el.parent().removeClass('open')
|
33
|
+
})
|
31
34
|
}
|
32
35
|
|
33
36
|
Dropdown.prototype = {
|
@@ -36,15 +39,21 @@
|
|
36
39
|
|
37
40
|
, toggle: function ( e ) {
|
38
41
|
var $this = $(this)
|
39
|
-
, selector = $this.attr('data-target')
|
40
|
-
, $parent
|
42
|
+
, selector = $this.attr('data-target')
|
43
|
+
, $parent
|
41
44
|
, isActive
|
42
45
|
|
46
|
+
if (!selector) {
|
47
|
+
selector = $this.attr('href')
|
48
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
49
|
+
}
|
50
|
+
|
51
|
+
$parent = $(selector)
|
43
52
|
$parent.length || ($parent = $this.parent())
|
53
|
+
|
44
54
|
isActive = $parent.hasClass('open')
|
45
55
|
|
46
56
|
clearMenus()
|
47
|
-
|
48
57
|
!isActive && $parent.toggleClass('open')
|
49
58
|
|
50
59
|
return false
|
@@ -76,8 +85,8 @@
|
|
76
85
|
* =================================== */
|
77
86
|
|
78
87
|
$(function () {
|
79
|
-
$(
|
88
|
+
$('html').on('click.dropdown.data-api', clearMenus)
|
80
89
|
$('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
81
90
|
})
|
82
91
|
|
83
|
-
}( window.jQuery )
|
92
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =========================================================
|
2
|
-
* bootstrap-modal.js v2.0.
|
2
|
+
* bootstrap-modal.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#modals
|
4
4
|
* =========================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -26,7 +26,7 @@
|
|
26
26
|
* ====================== */
|
27
27
|
|
28
28
|
var Modal = function ( content, options ) {
|
29
|
-
this.options =
|
29
|
+
this.options = options
|
30
30
|
this.$element = $(content)
|
31
31
|
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
|
32
32
|
}
|
@@ -44,6 +44,8 @@
|
|
44
44
|
|
45
45
|
if (this.isShown) return
|
46
46
|
|
47
|
+
$('body').addClass('modal-open')
|
48
|
+
|
47
49
|
this.isShown = true
|
48
50
|
this.$element.trigger('show')
|
49
51
|
|
@@ -77,6 +79,8 @@
|
|
77
79
|
var that = this
|
78
80
|
this.isShown = false
|
79
81
|
|
82
|
+
$('body').removeClass('modal-open')
|
83
|
+
|
80
84
|
escape.call(this)
|
81
85
|
|
82
86
|
this.$element
|
@@ -173,16 +177,17 @@
|
|
173
177
|
return this.each(function () {
|
174
178
|
var $this = $(this)
|
175
179
|
, data = $this.data('modal')
|
176
|
-
, options = typeof option == 'object' && option
|
180
|
+
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
|
177
181
|
if (!data) $this.data('modal', (data = new Modal(this, options)))
|
178
182
|
if (typeof option == 'string') data[option]()
|
179
|
-
else data.show()
|
183
|
+
else if (options.show) data.show()
|
180
184
|
})
|
181
185
|
}
|
182
186
|
|
183
187
|
$.fn.modal.defaults = {
|
184
188
|
backdrop: true
|
185
189
|
, keyboard: true
|
190
|
+
, show: true
|
186
191
|
}
|
187
192
|
|
188
193
|
$.fn.modal.Constructor = Modal
|
@@ -193,8 +198,8 @@
|
|
193
198
|
|
194
199
|
$(function () {
|
195
200
|
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
196
|
-
var $this = $(this)
|
197
|
-
, $target = $($this.attr('data-target') || $this.attr('href'))
|
201
|
+
var $this = $(this), href
|
202
|
+
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
198
203
|
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
|
199
204
|
|
200
205
|
e.preventDefault()
|
@@ -202,4 +207,4 @@
|
|
202
207
|
})
|
203
208
|
})
|
204
209
|
|
205
|
-
}( window.jQuery )
|
210
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ===========================================================
|
2
|
-
* bootstrap-popover.js v2.0.
|
2
|
+
* bootstrap-popover.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
4
4
|
* ===========================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -38,8 +38,8 @@
|
|
38
38
|
, title = this.getTitle()
|
39
39
|
, content = this.getContent()
|
40
40
|
|
41
|
-
$tip.find('.title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
|
42
|
-
$tip.find('.content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content)
|
41
|
+
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
|
42
|
+
$tip.find('.popover-content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content)
|
43
43
|
|
44
44
|
$tip.removeClass('fade top bottom left right in')
|
45
45
|
}
|
@@ -89,7 +89,7 @@
|
|
89
89
|
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
|
90
90
|
placement: 'right'
|
91
91
|
, content: ''
|
92
|
-
, template: '<div class="popover"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>'
|
92
|
+
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
|
93
93
|
})
|
94
94
|
|
95
|
-
}( window.jQuery )
|
95
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =============================================================
|
2
|
-
* bootstrap-scrollspy.js v2.0.
|
2
|
+
* bootstrap-scrollspy.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
|
4
4
|
* =============================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -27,10 +27,11 @@
|
|
27
27
|
function ScrollSpy( element, options) {
|
28
28
|
var process = $.proxy(this.process, this)
|
29
29
|
, $element = $(element).is('body') ? $(window) : $(element)
|
30
|
+
, href
|
30
31
|
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
|
31
32
|
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
|
32
33
|
this.selector = (this.options.target
|
33
|
-
|| $(element).attr('href')
|
34
|
+
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
34
35
|
|| '') + ' .nav li > a'
|
35
36
|
this.$body = $('body').on('click.scroll.data-api', this.selector, process)
|
36
37
|
this.refresh()
|
@@ -121,4 +122,4 @@
|
|
121
122
|
})
|
122
123
|
})
|
123
124
|
|
124
|
-
}( window.jQuery )
|
125
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ========================================================
|
2
|
-
* bootstrap-tab.js v2.0.
|
2
|
+
* bootstrap-tab.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
4
4
|
* ========================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -36,9 +36,14 @@
|
|
36
36
|
, show: function () {
|
37
37
|
var $this = this.element
|
38
38
|
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
39
|
-
,
|
39
|
+
, selector = $this.attr('data-target')
|
40
40
|
, previous
|
41
|
-
, $
|
41
|
+
, $target
|
42
|
+
|
43
|
+
if (!selector) {
|
44
|
+
selector = $this.attr('href')
|
45
|
+
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
46
|
+
}
|
42
47
|
|
43
48
|
if ( $this.parent('li').hasClass('active') ) return
|
44
49
|
|
@@ -49,10 +54,10 @@
|
|
49
54
|
, relatedTarget: previous
|
50
55
|
})
|
51
56
|
|
52
|
-
$
|
57
|
+
$target = $(selector)
|
53
58
|
|
54
59
|
this.activate($this.parent('li'), $ul)
|
55
|
-
this.activate($
|
60
|
+
this.activate($target, $target.parent(), function () {
|
56
61
|
$this.trigger({
|
57
62
|
type: 'shown'
|
58
63
|
, relatedTarget: previous
|
@@ -122,4 +127,4 @@
|
|
122
127
|
})
|
123
128
|
})
|
124
129
|
|
125
|
-
}( window.jQuery )
|
130
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ===========================================================
|
2
|
-
* bootstrap-tooltip.js v2.0.
|
2
|
+
* bootstrap-tooltip.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
4
4
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
5
5
|
* ===========================================================
|
@@ -267,4 +267,4 @@
|
|
267
267
|
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
|
268
268
|
}
|
269
269
|
|
270
|
-
}( window.jQuery )
|
270
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* ===================================================
|
2
|
-
* bootstrap-transition.js v2.0.
|
2
|
+
* bootstrap-transition.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#transitions
|
4
4
|
* ===================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -47,5 +47,5 @@
|
|
47
47
|
})()
|
48
48
|
|
49
49
|
})
|
50
|
-
|
51
|
-
}( window.jQuery )
|
50
|
+
|
51
|
+
}( window.jQuery );
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* =============================================================
|
2
|
-
* bootstrap-typeahead.js v2.0.
|
2
|
+
* bootstrap-typeahead.js v2.0.1
|
3
3
|
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
4
4
|
* =============================================================
|
5
5
|
* Copyright 2012 Twitter, Inc.
|
@@ -24,8 +24,11 @@
|
|
24
24
|
var Typeahead = function ( element, options ) {
|
25
25
|
this.$element = $(element)
|
26
26
|
this.options = $.extend({}, $.fn.typeahead.defaults, options)
|
27
|
+
this.matcher = this.options.matcher || this.matcher
|
28
|
+
this.sorter = this.options.sorter || this.sorter
|
29
|
+
this.highlighter = this.options.highlighter || this.highlighter
|
27
30
|
this.$menu = $(this.options.menu).appendTo('body')
|
28
|
-
this.
|
31
|
+
this.source = this.options.source
|
29
32
|
this.shown = false
|
30
33
|
this.listen()
|
31
34
|
}
|
@@ -34,11 +37,6 @@
|
|
34
37
|
|
35
38
|
constructor: Typeahead
|
36
39
|
|
37
|
-
, matcher: function (item, query) {
|
38
|
-
// ;_; http://jsperf.com/asdfdfasdfa
|
39
|
-
return ~item.toLowerCase().indexOf(query)
|
40
|
-
}
|
41
|
-
|
42
40
|
, select: function () {
|
43
41
|
var val = this.$menu.find('.active').attr('data-value')
|
44
42
|
this.$element.val(val)
|
@@ -77,12 +75,12 @@
|
|
77
75
|
return this.shown ? this.hide() : this
|
78
76
|
}
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
items = this.data.filter(function (item) {
|
83
|
-
if (that.matcher(item, q)) return item
|
78
|
+
items = $.grep(this.source, function (item) {
|
79
|
+
if (that.matcher(item)) return item
|
84
80
|
})
|
85
81
|
|
82
|
+
items = this.sorter(items)
|
83
|
+
|
86
84
|
if (!items.length) {
|
87
85
|
return this.shown ? this.hide() : this
|
88
86
|
}
|
@@ -90,17 +88,37 @@
|
|
90
88
|
return this.render(items.slice(0, this.options.items)).show()
|
91
89
|
}
|
92
90
|
|
91
|
+
, matcher: function (item) {
|
92
|
+
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
|
93
|
+
}
|
94
|
+
|
95
|
+
, sorter: function (items) {
|
96
|
+
var beginswith = []
|
97
|
+
, caseSensitive = []
|
98
|
+
, caseInsensitive = []
|
99
|
+
, item
|
100
|
+
|
101
|
+
while (item = items.shift()) {
|
102
|
+
if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
|
103
|
+
else if (~item.indexOf(this.query)) caseSensitive.push(item)
|
104
|
+
else caseInsensitive.push(item)
|
105
|
+
}
|
106
|
+
|
107
|
+
return beginswith.concat(caseSensitive, caseInsensitive)
|
108
|
+
}
|
109
|
+
|
110
|
+
, highlighter: function (item) {
|
111
|
+
return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) {
|
112
|
+
return '<strong>' + match + '</strong>'
|
113
|
+
})
|
114
|
+
}
|
115
|
+
|
93
116
|
, render: function (items) {
|
94
117
|
var that = this
|
95
|
-
, QUERY = new RegExp('(' + this.query + ')', 'ig')
|
96
118
|
|
97
119
|
items = $(items).map(function (i, item) {
|
98
120
|
i = $(that.options.item).attr('data-value', item)
|
99
|
-
|
100
|
-
i.find('a').html(item.replace(QUERY, function ($1, match) {
|
101
|
-
return '<strong>' + match + '</strong>'
|
102
|
-
}))
|
103
|
-
|
121
|
+
i.find('a').html(that.highlighter(item))
|
104
122
|
return i[0]
|
105
123
|
})
|
106
124
|
|
@@ -157,6 +175,7 @@
|
|
157
175
|
|
158
176
|
case 9: // tab
|
159
177
|
case 13: // enter
|
178
|
+
if (!this.shown) return
|
160
179
|
this.select()
|
161
180
|
break
|
162
181
|
|
@@ -172,6 +191,7 @@
|
|
172
191
|
|
173
192
|
, keypress: function (e) {
|
174
193
|
e.stopPropagation()
|
194
|
+
if (!this.shown) return
|
175
195
|
|
176
196
|
switch(e.keyCode) {
|
177
197
|
case 9: // tab
|
@@ -181,13 +201,11 @@
|
|
181
201
|
break
|
182
202
|
|
183
203
|
case 38: // up arrow
|
184
|
-
if (!this.shown) return
|
185
204
|
e.preventDefault()
|
186
205
|
this.prev()
|
187
206
|
break
|
188
207
|
|
189
208
|
case 40: // down arrow
|
190
|
-
if (!this.shown) return
|
191
209
|
e.preventDefault()
|
192
210
|
this.next()
|
193
211
|
break
|
@@ -229,7 +247,8 @@
|
|
229
247
|
}
|
230
248
|
|
231
249
|
$.fn.typeahead.defaults = {
|
232
|
-
|
250
|
+
source: []
|
251
|
+
, items: 8
|
233
252
|
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
234
253
|
, item: '<li><a href="#"></a></li>'
|
235
254
|
}
|
@@ -249,4 +268,4 @@
|
|
249
268
|
})
|
250
269
|
})
|
251
270
|
|
252
|
-
}( window.jQuery )
|
271
|
+
}( window.jQuery );
|