From dd99e2d0488c503d929909e431a544e472782178 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 6 Jan 2012 18:30:32 -0800 Subject: start of autocomplete plugin --- js/bootstrap-typeahead.js | 190 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 js/bootstrap-typeahead.js (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js new file mode 100644 index 000000000..52ced3fef --- /dev/null +++ b/js/bootstrap-typeahead.js @@ -0,0 +1,190 @@ +/* ============================================================= + * bootstrap-typeahead.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#collapsible + * ============================================================= + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +!function( $ ){ + + "use strict" + + var Typeahead = function ( element, options ) { + this.$element = $(element) + this.options = $.extend({}, $.fn.typeahead.defaults, options) + this.$menu = $(this.options.menu).appendTo('body') + this.data = this.options.data + this.shown = false + this.listen() + } + + Typeahead.prototype = { + + constructor: Typeahead + + , matcher: function(item, query) { + return ~item.indexOf(query) + } + + , select: function(event) { + this.$element.val($(event.target).attr('data-value')) + this.hide() + } + + , show: function () { + this.shown = true + this.$menu.show() + return this + } + + , hide: function () { + this.shown = false + this.$menu.hide() + return this + } + + , lookup: function (event) { + var query = this.$element.val() + , that = this + + var items = this.data.filter(function (item) { + if (that.matcher(item, query)) { + return item + } + }) + + if (!items.length) { + return this.shown ? this.hide() : this + } + + return this.render(items).show() + } + + , render: function(items) { + var that = this + + items = $(items).map(function (i, item) { + return $(that.options.item) + .text(item) + .attr('data-value', item)[0] + }) + + items.first().addClass('active') + + this.$menu.append(items) + + return this + } + + , next: function (event) { + var active = this.$menu.find('.active').removeClass('active') + , next = active.next() || $(this.$menu.find('li')[0]) + + next.addClass('active') + } + + , prev: function (event) { + var active = this.$menu.find('.active').removeClass('active') + , next = active.prev() || this.$menu.find('li').last() + + next.addClass('active') + } + + , keyup: function () { + event + .stopPropagation() + .preventDefault() + + switch(event.keyCode) { + case 9: // tab + case 13: // enter + this.select() + break + + case 27: // escape + this.hide() + break + + default: + this.lookup() + } + } + + , keypress: function (event) { + event.stopPropagation() + switch(event.keyCode) { + case 9: // tab + case 13: // enter + case 27: // escape + event.preventDefault() + break + + case 38: // up arrow + this.prev() + event.preventDefault() + break + + case 40: // down arrow + this.next() + event.preventDefault() + break + } + } + + , listen: function () { + this.$element + .on('focus', this.show) + .on('blur', $.proxy(this.hide, this)) + .on('keypress', $.proxy(this.keypress, this)) + .on('keyup', this.keyup) + .on('change', $.proxy(this.lookup, this)) + + if ($.browser.webkit || $.browser.msie) { + this.$element.on('keydown', this.keypress) + } + + this.$menu + .on('click', '* > *', $.proxy(this.select, this)) + .on('mouseenter', function () { + /* remove selected class, add to mouseover */ + }) + } + } + + /* TYPEAHEAD PLUGIN DEFINITION + * ============================== */ + + $.fn.typeahead = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('typeahead') + , options = typeof option == 'object' && option + if (!data) $this.data('typeahead', (data = new Typeahead(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.typeahead.defaults = { + data: null + , items: 8 + , empty: false + , noresults: false + , menu: '' + , item: '
  • ' + } + + $.fn.typeahead.Constructor = Typeahead + +}( window.jQuery ) \ No newline at end of file -- cgit v1.2.3 From 4478df768168fe41599508688046612bf5f1e526 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sun, 8 Jan 2012 00:49:38 -0800 Subject: first pass at ultra basic autocomplete --- js/bootstrap-typeahead.js | 147 ++++++++++++++++++++++++++++++---------------- 1 file changed, 98 insertions(+), 49 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 52ced3fef..4933f9605 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -34,80 +34,102 @@ constructor: Typeahead - , matcher: function(item, query) { + , matcher: function (item, query) { return ~item.indexOf(query) } - , select: function(event) { - this.$element.val($(event.target).attr('data-value')) - this.hide() + , select: function () { + var val = this.$menu.find('.active').attr('data-value') + this.$element.val(val) + return this.hide() } , show: function () { - this.shown = true + var pos = $.extend({}, this.$element.offset(), { + height: this.$element[0].offsetHeight + }) + + this.$menu.css({ + top: pos.top + pos.height + , left: pos.left + }) + this.$menu.show() + this.shown = true return this } , hide: function () { - this.shown = false this.$menu.hide() + this.shown = false return this } , lookup: function (event) { var query = this.$element.val() , that = this + , items + + if (!query) { + return this.shown ? this.hide() : this + } - var items = this.data.filter(function (item) { - if (that.matcher(item, query)) { - return item - } + items = this.data.filter(function (item) { + if (that.matcher(item, query)) return item }) if (!items.length) { return this.shown ? this.hide() : this } - return this.render(items).show() + return this.render(items.slice(0, this.options.items)).show() } - , render: function(items) { + , render: function (items) { var that = this items = $(items).map(function (i, item) { - return $(that.options.item) - .text(item) - .attr('data-value', item)[0] + i = $(that.options.item).attr('data-value', item) + i.find('a').text(item) + return i[0] }) items.first().addClass('active') - - this.$menu.append(items) - + this.$menu.html(items) return this } , next: function (event) { var active = this.$menu.find('.active').removeClass('active') - , next = active.next() || $(this.$menu.find('li')[0]) + , next = active.next() + + if (!next.length) { + next = $(this.$menu.find('li')[0]) + } next.addClass('active') } , prev: function (event) { var active = this.$menu.find('.active').removeClass('active') - , next = active.prev() || this.$menu.find('li').last() + , prev = active.prev() - next.addClass('active') + if (!prev.length) { + prev = this.$menu.find('li').last() + } + + prev.addClass('active') } - , keyup: function () { - event - .stopPropagation() - .preventDefault() + , keyup: function (e) { + e.stopPropagation() + e.preventDefault() + + switch(e.keyCode) { + case 40: // down arrow + case 38: // up arrow + break - switch(event.keyCode) { case 9: // tab case 13: // enter this.select() @@ -120,51 +142,68 @@ default: this.lookup() } + } - , keypress: function (event) { - event.stopPropagation() - switch(event.keyCode) { + , keypress: function (e) { + e.stopPropagation() + + switch(e.keyCode) { case 9: // tab case 13: // enter case 27: // escape - event.preventDefault() + e.preventDefault() break case 38: // up arrow + e.preventDefault() this.prev() - event.preventDefault() break case 40: // down arrow + e.preventDefault() this.next() - event.preventDefault() break } - } + } + + , blur: function (e) { + var that = this + e.stopPropagation() + e.preventDefault() + setTimeout(function () { that.hide() }, 150) + } + + , click: function (e) { + e.stopPropagation() + e.preventDefault() + this.select() + } + + , mouseenter: function (e) { + this.$menu.find('.active').removeClass('active') + $(e.currentTarget).addClass('active') + } , listen: function () { this.$element - .on('focus', this.show) - .on('blur', $.proxy(this.hide, this)) + .on('blur', $.proxy(this.blur, this)) .on('keypress', $.proxy(this.keypress, this)) - .on('keyup', this.keyup) - .on('change', $.proxy(this.lookup, this)) + .on('keyup', $.proxy(this.keyup, this)) if ($.browser.webkit || $.browser.msie) { - this.$element.on('keydown', this.keypress) + this.$element.on('keydown', $.proxy(this.keypress, this)) } this.$menu - .on('click', '* > *', $.proxy(this.select, this)) - .on('mouseenter', function () { - /* remove selected class, add to mouseover */ - }) + .on('click', $.proxy(this.click, this)) + .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) } } + /* TYPEAHEAD PLUGIN DEFINITION - * ============================== */ + * =========================== */ $.fn.typeahead = function ( option ) { return this.each(function () { @@ -177,14 +216,24 @@ } $.fn.typeahead.defaults = { - data: null - , items: 8 - , empty: false - , noresults: false - , menu: '' - , item: '
  • ' + items: 8 + , menu: '' + , item: '
  • ' } $.fn.typeahead.Constructor = Typeahead + + /* TYPEAHEAD DATA-API + * ================== */ + + $(function () { + $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { + var $this = $(this) + if ($this.data('typeahead')) return + e.preventDefault() + $this.typeahead($this.data()) + }) + }) + }( window.jQuery ) \ No newline at end of file -- cgit v1.2.3 From 6f2f947a4309a8fdeb7067612447c0f1a15dcfd9 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 11 Jan 2012 21:42:55 -0800 Subject: add build tool for js + rename twipsy to tooltip + lots of little doc cleanup --- js/bootstrap-typeahead.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 4933f9605..180466a74 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -156,11 +156,13 @@ break case 38: // up arrow + if (!this.shown) return e.preventDefault() this.prev() break case 40: // down arrow + if (!this.shown) return e.preventDefault() this.next() break -- cgit v1.2.3 From 16eccc43d9fa6317818b5d1621d0477150214488 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 14 Jan 2012 23:28:48 -0800 Subject: dates updated to 2012 --- js/bootstrap-typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 180466a74..b4957c3f6 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -2,7 +2,7 @@ * bootstrap-typeahead.js v2.0.0 * http://twitter.github.com/bootstrap/javascript.html#collapsible * ============================================================= - * Copyright 2011 Twitter, Inc. + * Copyright 2012 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3 From 4fe11342d049f708c3416e5b29fa3ed5bfc3b393 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 21 Jan 2012 21:46:47 -0800 Subject: make case lookahead case insensitive --- js/bootstrap-typeahead.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index b4957c3f6..16539fefb 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -35,7 +35,8 @@ constructor: Typeahead , matcher: function (item, query) { - return ~item.indexOf(query) + // ;_; http://jsperf.com/asdfdfasdfa + return ~item.toLowerCase().indexOf(query.toLowerCase()) } , select: function () { -- cgit v1.2.3 From 6e490628d1be1a165d95ecf9817fdc7070069947 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 21 Jan 2012 22:06:36 -0800 Subject: more efficient matcher + bold matched query in item --- js/bootstrap-typeahead.js | 50 ++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 16539fefb..b8ff5aab0 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -36,7 +36,7 @@ , matcher: function (item, query) { // ;_; http://jsperf.com/asdfdfasdfa - return ~item.toLowerCase().indexOf(query.toLowerCase()) + return ~item.toLowerCase().indexOf(query) } , select: function () { @@ -67,16 +67,20 @@ } , lookup: function (event) { - var query = this.$element.val() - , that = this + var that = this , items + , q + + this.query = this.$element.val() - if (!query) { + if (!this.query) { return this.shown ? this.hide() : this } + q = this.query.toLowerCase() + items = this.data.filter(function (item) { - if (that.matcher(item, query)) return item + if (that.matcher(item, q)) return item }) if (!items.length) { @@ -88,10 +92,15 @@ , render: function (items) { var that = this + , QUERY = new RegExp('(' + this.query + ')', 'ig') items = $(items).map(function (i, item) { i = $(that.options.item).attr('data-value', item) - i.find('a').text(item) + + i.find('a').html(item.replace(QUERY, function ($1, match) { + return '' + match + '' + })) + return i[0] }) @@ -122,6 +131,21 @@ prev.addClass('active') } + , listen: function () { + this.$element + .on('blur', $.proxy(this.blur, this)) + .on('keypress', $.proxy(this.keypress, this)) + .on('keyup', $.proxy(this.keyup, this)) + + if ($.browser.webkit || $.browser.msie) { + this.$element.on('keydown', $.proxy(this.keypress, this)) + } + + this.$menu + .on('click', $.proxy(this.click, this)) + .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) + } + , keyup: function (e) { e.stopPropagation() e.preventDefault() @@ -188,20 +212,6 @@ $(e.currentTarget).addClass('active') } - , listen: function () { - this.$element - .on('blur', $.proxy(this.blur, this)) - .on('keypress', $.proxy(this.keypress, this)) - .on('keyup', $.proxy(this.keyup, this)) - - if ($.browser.webkit || $.browser.msie) { - this.$element.on('keydown', $.proxy(this.keypress, this)) - } - - this.$menu - .on('click', $.proxy(this.click, this)) - .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) - } } -- cgit v1.2.3 From 84a8aa1beac447cbbe77983730f7590fc955b312 Mon Sep 17 00:00:00 2001 From: Jon Stevens Date: Tue, 24 Jan 2012 11:08:03 -0800 Subject: 2.0-wip: fix js heads --- js/bootstrap-typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index b8ff5aab0..f64fcca01 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -1,6 +1,6 @@ /* ============================================================= * bootstrap-typeahead.js v2.0.0 - * http://twitter.github.com/bootstrap/javascript.html#collapsible + * http://twitter.github.com/bootstrap/javascript.html#typeahead * ============================================================= * Copyright 2012 Twitter, Inc. * -- cgit v1.2.3 From 1f04481092f6021c721f48465b57f7a829f186f5 Mon Sep 17 00:00:00 2001 From: Pete Hopkins Date: Thu, 26 Jan 2012 17:07:06 -0500 Subject: Switches from Array#filter to jQuery.grep for IE<=8 support --- js/bootstrap-typeahead.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index f64fcca01..1205a99ca 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -79,7 +79,7 @@ q = this.query.toLowerCase() - items = this.data.filter(function (item) { + items = jQuery.grep(this.data, function (item) { if (that.matcher(item, q)) return item }) @@ -249,4 +249,4 @@ }) }) -}( window.jQuery ) \ No newline at end of file +}( window.jQuery ) -- cgit v1.2.3 From 5844aa550d5a2d22d527d80cfa42443914d28c1f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 26 Jan 2012 15:00:59 -0800 Subject: consistent new lines at ends of files --- js/bootstrap-typeahead.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index f64fcca01..fad28ea46 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -249,4 +249,4 @@ }) }) -}( window.jQuery ) \ No newline at end of file +}( window.jQuery ) -- cgit v1.2.3 From b9589fcb8076aa6b2559553c56d7e65808568a86 Mon Sep 17 00:00:00 2001 From: David N Date: Thu, 26 Jan 2012 17:23:09 -0600 Subject: Enable default browser key behaviour when typeahead isn't showing. --- js/bootstrap-typeahead.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index fad28ea46..82188f592 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -157,6 +157,7 @@ case 9: // tab case 13: // enter + if (!this.shown) return this.select() break @@ -172,6 +173,7 @@ , keypress: function (e) { e.stopPropagation() + if (!this.shown) return switch(e.keyCode) { case 9: // tab @@ -181,13 +183,11 @@ break case 38: // up arrow - if (!this.shown) return e.preventDefault() this.prev() break case 40: // down arrow - if (!this.shown) return e.preventDefault() this.next() break -- cgit v1.2.3 From aa594501bd24d51181dc3504602aa4aaefb1cb60 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Thu, 26 Jan 2012 23:16:02 -0800 Subject: change typeahead to data-source instead of data-data and add to docs --- js/bootstrap-typeahead.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 1205a99ca..82c318831 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -25,7 +25,7 @@ this.$element = $(element) this.options = $.extend({}, $.fn.typeahead.defaults, options) this.$menu = $(this.options.menu).appendTo('body') - this.data = this.options.data + this.source = this.options.source this.shown = false this.listen() } @@ -79,7 +79,7 @@ q = this.query.toLowerCase() - items = jQuery.grep(this.data, function (item) { + items = jQuery.grep(this.source, function (item) { if (that.matcher(item, q)) return item }) @@ -229,7 +229,8 @@ } $.fn.typeahead.defaults = { - items: 8 + source: [] + , items: 8 , menu: '' , item: '
  • ' } -- cgit v1.2.3 From 7cbb5868259ef95aacbd16812c25ac73ea76ca2d Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 27 Jan 2012 22:27:06 -0800 Subject: move the matcher and sorter into the options - encourage people to override them... --- js/bootstrap-typeahead.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index b4d839c93..39331816e 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -24,6 +24,8 @@ var Typeahead = function ( element, options ) { this.$element = $(element) this.options = $.extend({}, $.fn.typeahead.defaults, options) + this.matcher = this.options.matcher + this.sorter = this.options.sorter this.$menu = $(this.options.menu).appendTo('body') this.source = this.options.source this.shown = false @@ -34,11 +36,6 @@ constructor: Typeahead - , matcher: function (item, query) { - // ;_; http://jsperf.com/asdfdfasdfa - return ~item.toLowerCase().indexOf(query) - } - , select: function () { var val = this.$menu.find('.active').attr('data-value') this.$element.val(val) @@ -77,12 +74,12 @@ return this.shown ? this.hide() : this } - q = this.query.toLowerCase() - - items = jQuery.grep(this.source, function (item) { - if (that.matcher(item, q)) return item + items = $.grep(this.source, function (item) { + if (that.matcher(item)) return item }) + items = this.sorter(items) + if (!items.length) { return this.shown ? this.hide() : this } @@ -233,6 +230,12 @@ , items: 8 , menu: '' , item: '
  • ' + , matcher: function (item) { + return ~item.indexOf(this.query) + } + , sorter: function (items) { + return items + } } $.fn.typeahead.Constructor = Typeahead -- cgit v1.2.3 From 6935f693b3bce10f9bfe7b7e1f3c2705ff2b6ca2 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 28 Jan 2012 13:16:05 -0800 Subject: typahead does case insensitive matching with simple sorter + accepts highlighter option --- js/bootstrap-typeahead.js | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'js/bootstrap-typeahead.js') diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 39331816e..1426185af 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -24,8 +24,9 @@ var Typeahead = function ( element, options ) { this.$element = $(element) this.options = $.extend({}, $.fn.typeahead.defaults, options) - this.matcher = this.options.matcher - this.sorter = this.options.sorter + this.matcher = this.options.matcher || this.matcher + this.sorter = this.options.sorter || this.sorter + this.highlighter = this.options.highlighter || this.highlighter this.$menu = $(this.options.menu).appendTo('body') this.source = this.options.source this.shown = false @@ -87,17 +88,37 @@ return this.render(items.slice(0, this.options.items)).show() } + , matcher: function (item) { + return ~item.toLowerCase().indexOf(this.query.toLowerCase()) + } + + , sorter: function (items) { + var beginswith = [] + , caseSensitive = [] + , caseInsensitive = [] + , item + + while (item = items.shift()) { + if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item) + else if (~item.indexOf(this.query)) caseSensitive.push(item) + else caseInsensitive.push(item) + } + + return beginswith.concat(caseSensitive, caseInsensitive) + } + + , highlighter: function (item) { + return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) { + return '' + match + '' + }) + } + , render: function (items) { var that = this - , QUERY = new RegExp('(' + this.query + ')', 'ig') items = $(items).map(function (i, item) { i = $(that.options.item).attr('data-value', item) - - i.find('a').html(item.replace(QUERY, function ($1, match) { - return '' + match + '' - })) - + i.find('a').html(that.highlighter(item)) return i[0] }) @@ -230,12 +251,6 @@ , items: 8 , menu: '' , item: '
  • ' - , matcher: function (item) { - return ~item.indexOf(this.query) - } - , sorter: function (items) { - return items - } } $.fn.typeahead.Constructor = Typeahead -- cgit v1.2.3