bootstrap-sass-extensions 2.3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ module Bootstrap
2
+ module Sass
3
+ module Extensions
4
+ class Engine < ::Rails::Engine
5
+ # auto wire assets
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,139 @@
1
+ /* ================================================================
2
+ * bootstrap-autocomplete.js v2.3.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#autocomplete
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"; // jshint ;_;
24
+
25
+
26
+ var Typeahead = $.fn.typeahead.Constructor;
27
+
28
+
29
+ /* AUTOCOMPLETE PUBLIC CLASS DEFINITION
30
+ * ==================================== */
31
+
32
+ var Autocomplete = function(element, options) {
33
+ Typeahead.apply(this, [element, options])
34
+ this.options = $.extend({}, $.fn.autocomplete.defaults, options)
35
+ this.$hidden_input = this.$element.prev('input:hidden')
36
+ if (this.source_is_remote) {
37
+ this.initializeForRemoteSource()
38
+ } else {
39
+ this.initializeForHashSource()
40
+ }
41
+ }
42
+
43
+
44
+ /* NOTE: AUTOCOMPLETE EXTENDS BOOTSTRAP-TYPEAHEAD.js
45
+ * ================================================= */
46
+
47
+ Autocomplete.prototype = $.extend({}, Typeahead.prototype, {
48
+
49
+ constructor: Autocomplete
50
+
51
+ , initializeForRemoteSource: function() {
52
+ var that = this,
53
+ label = this.$element.val()
54
+ this.source(label, function (items) {
55
+ that.last_processed_source = items
56
+ })
57
+ }
58
+
59
+ , initializeForHashSource: function() {
60
+ if (this.$element.val() == '') {
61
+ var value = this.$hidden_input.val()
62
+ var label = this.source[value]
63
+ this.$element.val(label)
64
+ }
65
+ this.last_processed_source = this.source
66
+ }
67
+
68
+ , process: function (items) {
69
+ this.last_processed_source = items
70
+ var labels = $.map(items, function(v) { return v })
71
+ return Typeahead.prototype.process.apply(this, [labels])
72
+ }
73
+
74
+ , updater: function (label) {
75
+ var found_values = $.map(this.last_processed_source, function (v, k) { if (v == label) return k })
76
+ var value = found_values[0]
77
+ if (!this.options.arbitrary && typeof value == 'undefined') {
78
+ label = ''
79
+ }
80
+ this.$hidden_input.val(value)
81
+ return Typeahead.prototype.updater.apply(this, [label])
82
+ }
83
+
84
+ , blur: function (e) {
85
+ if (typeof this.last_processed_source != 'undefined') {
86
+ var label = this.$element.val()
87
+ this.$element.val(this.updater(label))
88
+ }
89
+ return Typeahead.prototype.blur.apply(this, [e])
90
+ }
91
+
92
+ })
93
+
94
+
95
+ /* AUTOCOMPLETE PLUGIN DEFINITION
96
+ * ============================== */
97
+
98
+ var old = $.fn.autocomplete
99
+
100
+ $.fn.autocomplete = function (option) {
101
+ return this.each(function () {
102
+ var $this = $(this)
103
+ , data = $this.data('autocomplete')
104
+ , options = typeof option == 'object' && option
105
+ if (!data) $this.data('autocomplete', (data = new Autocomplete(this, options)))
106
+ if (typeof option == 'string') data[option]()
107
+ })
108
+ }
109
+
110
+ $.fn.autocomplete.defaults = $.extend({}, $.fn.typeahead.defaults, {
111
+ arbitrary: false
112
+ })
113
+
114
+ $.fn.autocomplete.Constructor = Autocomplete
115
+
116
+
117
+ /* AUTOCOMPLETE NO CONFLICT
118
+ * ======================== */
119
+
120
+ $.fn.autocomplete.noConflict = function () {
121
+ $.fn.autocomplete = old
122
+ return this
123
+ }
124
+
125
+
126
+ /* AUTOCOMPLETE DATA-API
127
+ * ===================== */
128
+
129
+ function init() {
130
+ $('[data-provide="autocomplete"]').each(function () {
131
+ var $this = $(this)
132
+ $this.autocomplete($this.data())
133
+ })
134
+ }
135
+
136
+ $(function () { init() })
137
+ $(document).on('ajaxComplete', function () { init() })
138
+
139
+ }(window.jQuery);
@@ -0,0 +1,357 @@
1
+ /* =============================================================
2
+ * bootstrap-typeahead.js v2.3.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#typeahead
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"; // jshint ;_;
24
+
25
+
26
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
27
+ * ================================= */
28
+
29
+ var Typeahead = function (element, options) {
30
+ this.$element = $(element)
31
+ this.$element.attr('autocomplete', 'off')
32
+ this.options = $.extend({}, $.fn.typeahead.defaults, options)
33
+ this.matcher = this.options.matcher || this.matcher
34
+ this.sorter = this.options.sorter || this.sorter
35
+ this.highlighter = this.options.highlighter || this.highlighter
36
+ this.updater = this.options.updater || this.updater
37
+ this.source = this.options.source
38
+ this.$menu = $(this.options.menu)
39
+
40
+ if (typeof this.source == 'string' && (this.source.match("^https?://") || this.source.match("^/"))) {
41
+ this.source_is_remote = true
42
+ var template = this.source
43
+ this.source = function (query, process_function) {
44
+ var url = template.replace('%query%', query)
45
+ $.getJSON(url, function (json) {
46
+ process_function(json)
47
+ })
48
+ }
49
+ } else {
50
+ this.source_is_remote = false
51
+ }
52
+
53
+ this.shown = false
54
+ this.listen()
55
+ }
56
+
57
+ Typeahead.prototype = {
58
+
59
+ constructor: Typeahead
60
+
61
+ , select: function () {
62
+ var val = this.$menu.find('.active').attr('data-value')
63
+ this.$element
64
+ .val(this.updater(val))
65
+ .change()
66
+ return this.hide()
67
+ }
68
+
69
+ , updater: function (item) {
70
+ return item
71
+ }
72
+
73
+ , show: function () {
74
+ var pos = $.extend({}, this.$element.position(), {
75
+ height: this.$element[0].offsetHeight
76
+ })
77
+
78
+ this.$menu
79
+ .insertAfter(this.$element)
80
+ .css({
81
+ top: pos.top + pos.height
82
+ , left: pos.left
83
+ })
84
+ .show()
85
+
86
+ this.shown = true
87
+ return this
88
+ }
89
+
90
+ , hide: function () {
91
+ this.$menu.hide()
92
+ this.shown = false
93
+ return this
94
+ }
95
+
96
+ , lookup: function (event) {
97
+ var items
98
+
99
+ this.query = this.$element.val()
100
+
101
+ if (!this.query || this.query.length < this.options.minLength) {
102
+ return this.shown ? this.hide() : this
103
+ }
104
+
105
+ items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
106
+
107
+ return items ? this.process(items) : this
108
+ }
109
+
110
+ , process: function (items) {
111
+ var that = this
112
+
113
+ items = $.grep(items, function (item) {
114
+ return that.matcher(item)
115
+ })
116
+
117
+ items = this.sorter(items)
118
+
119
+ if (!items.length) {
120
+ return this.shown ? this.hide() : this
121
+ }
122
+
123
+ return this.render(items.slice(0, this.options.items)).show()
124
+ }
125
+
126
+ , matcher: function (item) {
127
+ return this.source_is_remote ? true : ~item.toLowerCase().indexOf(this.query.toLowerCase())
128
+ }
129
+
130
+ , sorter: function (items) {
131
+ var beginswith = []
132
+ , caseSensitive = []
133
+ , caseInsensitive = []
134
+ , item
135
+
136
+ while (item = items.shift()) {
137
+ if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
138
+ else if (~item.indexOf(this.query)) caseSensitive.push(item)
139
+ else caseInsensitive.push(item)
140
+ }
141
+
142
+ return beginswith.concat(caseSensitive, caseInsensitive)
143
+ }
144
+
145
+ , highlighter: function (item) {
146
+ var words = $.trim(this.query).split(' ')
147
+ for(var i in words) {
148
+ var word = words[i].replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
149
+ item = item.replace(new RegExp('(' + word + ')', 'ig'), function ($1, match) {
150
+ return '<strong>' + match + '</strong>'
151
+ })
152
+ }
153
+ return item
154
+ }
155
+
156
+ , render: function (items) {
157
+ var that = this
158
+
159
+ items = $(items).map(function (i, item) {
160
+ i = $(that.options.item).attr('data-value', item)
161
+ i.find('a').html(that.highlighter(item))
162
+ return i[0]
163
+ })
164
+
165
+ items.first().addClass('active')
166
+ this.$menu.html(items)
167
+ return this
168
+ }
169
+
170
+ , next: function (event) {
171
+ var active = this.$menu.find('.active').removeClass('active')
172
+ , next = active.next()
173
+
174
+ if (!next.length) {
175
+ next = $(this.$menu.find('li')[0])
176
+ }
177
+
178
+ next.addClass('active')
179
+ }
180
+
181
+ , prev: function (event) {
182
+ var active = this.$menu.find('.active').removeClass('active')
183
+ , prev = active.prev()
184
+
185
+ if (!prev.length) {
186
+ prev = this.$menu.find('li').last()
187
+ }
188
+
189
+ prev.addClass('active')
190
+ }
191
+
192
+ , listen: function () {
193
+ this.$element
194
+ .on('focus', $.proxy(this.focus, this))
195
+ .on('blur', $.proxy(this.blur, this))
196
+ .on('keypress', $.proxy(this.keypress, this))
197
+ .on('keyup', $.proxy(this.keyup, this))
198
+
199
+ if (this.eventSupported('keydown')) {
200
+ this.$element.on('keydown', $.proxy(this.keydown, this))
201
+ }
202
+
203
+ this.$menu
204
+ .on('click', $.proxy(this.click, this))
205
+ .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
206
+ .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
207
+ }
208
+
209
+ , eventSupported: function(eventName) {
210
+ var isSupported = eventName in this.$element
211
+ if (!isSupported) {
212
+ this.$element.setAttribute(eventName, 'return;')
213
+ isSupported = typeof this.$element[eventName] === 'function'
214
+ }
215
+ return isSupported
216
+ }
217
+
218
+ , move: function (e) {
219
+ if (!this.shown) return
220
+
221
+ switch(e.keyCode) {
222
+ case 9: // tab
223
+ this.select()
224
+ break
225
+
226
+ case 13: // enter
227
+ case 27: // escape
228
+ e.preventDefault()
229
+ break
230
+
231
+ case 38: // up arrow
232
+ e.preventDefault()
233
+ this.prev()
234
+ break
235
+
236
+ case 40: // down arrow
237
+ e.preventDefault()
238
+ this.next()
239
+ break
240
+ }
241
+
242
+ e.stopPropagation()
243
+ }
244
+
245
+ , keydown: function (e) {
246
+ this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
247
+ this.move(e)
248
+ }
249
+
250
+ , keypress: function (e) {
251
+ if (this.suppressKeyPressRepeat) return
252
+ this.move(e)
253
+ }
254
+
255
+ , keyup: function (e) {
256
+ switch(e.keyCode) {
257
+ case 40: // down arrow
258
+ case 38: // up arrow
259
+ case 16: // shift
260
+ case 17: // ctrl
261
+ case 18: // alt
262
+ break
263
+
264
+ case 9: // tab
265
+ case 13: // enter
266
+ if (!this.shown) return
267
+ this.select()
268
+ break
269
+
270
+ case 27: // escape
271
+ if (!this.shown) return
272
+ this.hide()
273
+ break
274
+
275
+ default:
276
+ this.lookup()
277
+ }
278
+
279
+ e.stopPropagation()
280
+ e.preventDefault()
281
+ }
282
+
283
+ , focus: function (e) {
284
+ this.focused = true
285
+ }
286
+
287
+ , blur: function (e) {
288
+ this.focused = false
289
+ if (!this.mousedover && this.shown) this.hide()
290
+ }
291
+
292
+ , click: function (e) {
293
+ e.stopPropagation()
294
+ e.preventDefault()
295
+ this.select()
296
+ this.$element.focus()
297
+ }
298
+
299
+ , mouseenter: function (e) {
300
+ this.mousedover = true
301
+ this.$menu.find('.active').removeClass('active')
302
+ $(e.currentTarget).addClass('active')
303
+ }
304
+
305
+ , mouseleave: function (e) {
306
+ this.mousedover = false
307
+ if (!this.focused && this.shown) this.hide()
308
+ }
309
+
310
+ }
311
+
312
+
313
+ /* TYPEAHEAD PLUGIN DEFINITION
314
+ * =========================== */
315
+
316
+ var old = $.fn.typeahead
317
+
318
+ $.fn.typeahead = function (option) {
319
+ return this.each(function () {
320
+ var $this = $(this)
321
+ , data = $this.data('typeahead')
322
+ , options = typeof option == 'object' && option
323
+ if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
324
+ if (typeof option == 'string') data[option]()
325
+ })
326
+ }
327
+
328
+ $.fn.typeahead.defaults = {
329
+ source: []
330
+ , items: 8
331
+ , menu: '<ul class="typeahead dropdown-menu"></ul>'
332
+ , item: '<li><a href="#"></a></li>'
333
+ , minLength: 1
334
+ }
335
+
336
+ $.fn.typeahead.Constructor = Typeahead
337
+
338
+
339
+ /* TYPEAHEAD NO CONFLICT
340
+ * =================== */
341
+
342
+ $.fn.typeahead.noConflict = function () {
343
+ $.fn.typeahead = old
344
+ return this
345
+ }
346
+
347
+
348
+ /* TYPEAHEAD DATA-API
349
+ * ================== */
350
+
351
+ $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
352
+ var $this = $(this)
353
+ if ($this.data('typeahead')) return
354
+ $this.typeahead($this.data())
355
+ })
356
+
357
+ }(window.jQuery);
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootstrap-sass-extensions
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 2.3.2.2
6
+ platform: ruby
7
+ authors:
8
+ - Michael Bashkirov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.2.1
20
+ none: false
21
+ name: bootstrap-sass
22
+ type: :runtime
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 2.3.2.1
29
+ none: false
30
+ description: New and improved Bootstrap features on the foundation of bootstrap-sass
31
+ gem.
32
+ email: bashmish@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - vendor/assets/javascripts/bootstrap-autocomplete.js
38
+ - vendor/assets/javascripts/bootstrap-typeahead.js
39
+ - lib/bootstrap-sass-extensions.rb
40
+ homepage: http://github.com/bashmish/bootstrap-sass-extensions
41
+ licenses: []
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ none: false
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ none: false
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 1.8.23
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Extensions for bootstrap-sass gem.
64
+ test_files: []
65
+ has_rdoc: