Merge commit '8a2550e7d5cd19e25616087052915e1c9978e0ad'

This commit is contained in:
Eldon Koyle
2016-01-05 17:35:26 -07:00
32 changed files with 547 additions and 559 deletions

View File

@@ -1,6 +1,6 @@
language: node_js
env:
matrix:
env:
matrix:
- TEST_SUITE=unit
- TEST_SUITE=integration BROWSER='firefox'
- TEST_SUITE=integration BROWSER='firefox:3.5'
@@ -13,16 +13,21 @@ env:
- TEST_SUITE=integration BROWSER='internet explorer:10'
- TEST_SUITE=integration BROWSER='internet explorer:11'
- TEST_SUITE=integration BROWSER='chrome'
global:
global:
- secure: VY4J2ERfrMEin++f4+UDDtTMWLuE3jaYAVchRxfO2c6PQUYgR+SW4SMekz855U/BuptMtiVMR2UUoNGMgOSKIFkIXpPfHhx47G5a541v0WNjXfQ2qzivXAWaXNK3l3C58z4dKxgPWsFY9JtMVCddJd2vQieAILto8D8G09p7bpo=
- secure: kehbNCoYUG2gLnhmCH/oKhlJG6LoxgcOPMCtY7KOI4ropG8qlypb+O2b/19+BWeO3aIuMB0JajNh3p2NL0UKgLmUK7EYBA9fQz+vesFReRk0V/KqMTSxHJuseM4aLOWA2Wr9US843VGltfODVvDN5sNrfY7RcoRx2cTK/k1CXa8=
node_js:
- 0.11.13
before_script:
node_js:
- "4.1"
cache:
directories:
- node_modules
- bower_components
before_install:
- npm install -g grunt-cli@0.1.13
- npm install -g node-static@0.7.3
- npm install -g bower@1.3.8
- bower install
install:
- npm install
before_script:
- grunt build
script: test/ci
addons:

View File

@@ -1,249 +0,0 @@
Changelog
=========
For transparency and insight into our release cycle, releases will be numbered
with the follow format:
`<major>.<minor>.<patch>`
And constructed with the following guidelines:
* Breaking backwards compatibility bumps the major
* New additions without breaking backwards compatibility bumps the minor
* Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit http://semver.org/.
---
### 0.11.1 April 26, 2015
* Add prepare option to prefetch. [#1181]
* Handle QuotaExceededError. [#1110]
* Escape HTML entities from suggestion display value when rendering with default
template. [#964]
* List jquery as a dependency in package.json. [#1143]
### 0.11.0 April 25, 2015
An overhaul of typeahead.js  consider this a release candidate for v1. There
are bunch of API changes with this release so don't expect backwards
compatibility with previous versions. There are also many new undocumented
features that have been introduced. Documentation for those features will be
added before v1 ships.
Beware that since this release is pretty much a rewrite, there are bound to be
some bugs. To be safe, you should consider this release beta software and
throughly test your integration of it before using it in production
environments. This caveat only applies to this release as subsequent releases
will address any issues that come up.
### 0.10.5 August 7, 2014
* Increase supported version range for jQuery dependency. [#917]
### 0.10.4 July 13, 2014
**Hotfix**
* Fix regression that breaks Bloodhound instances when more than 1 instance is
relying on remote data. [#899]
### 0.10.3 July 10, 2014
**Bug fixes**
* `Bloodhound#clearPrefetchCache` now works with cache keys that contain regex
characters. [#771]
* Prevent outdated network requests from being sent. [#809]
* Add support to object tokenizers for multiple property tokenization. [#811]
* Fix broken `jQuery#typeahead('val')` method. [#815]
* Remove `disabled` attribute from the hint input control. [#839]
* Add `tt-highlight` class to highlighted text. [#833]
* Handle non-string types that are passed to `jQuery#typeahead('val', val)`. [#881]
### 0.10.2 March 10, 2014
* Prevent flickering of dropdown menu when requesting remote suggestions. [#718]
* Reduce hint flickering. [#754]
* Added `Bloodhound#{clear, clearPrefetchCache, clearRemoteCache}` and made it
possible to reinitialize Bloodhound instances. [#703]
* Invoke `local` function during initialization. [#687]
* In addition to HTML strings, templates can now return DOM nodes. [#742]
* Prevent `jQuery#typeahead('val', val)` from opening dropdown menus of
non-active typeaheads. [#646]
* Fix bug in IE that resulted in dropdown menus with overflow being closed
when clicking on the scrollbar. [#705]
* Only show dropdown menu if `minLength` is satisfied. [#710]
### 0.10.1 February 9, 2014
**Hotfix**
* Fixed bug that prevented some ajax configs from being respected. [#630]
* Event delegation on suggestion clicks is no longer broken. [#118]
* Ensure dataset names are valid class name suffixes. [#610]
* Added support for `displayKey` to be a function. [#633]
* `jQuery#typeahead('val')` now mirrors `jQuery#val()`. [#659]
* Datasets can now be passed to jQuery plugin as an array. [#664]
* Added a `noConflict` method to the jQuery plugin. [#612]
* Bloodhound's `local` property can now be a function. [#485]
### 0.10.0 February 2, 2014
**Introducting Bloodhound**
This release was almost a complete rewrite of typeahead.js and will hopefully
lay the foundation for the 1.0.0 release. It's impossible to enumerate all of
the issues that were fixed. If you want to get an idea of what issues 0.10.0
resolved, take a look at the closed issues in the [0.10.0 milestone].
The most important change in 0.10.0 is that typeahead.js was broken up into 2
individual components: Bloodhound and jQuery#typeahead. Bloodhound is an
feature-rich suggestion engine. jQuery#typeahead is a jQuery plugin that turns
input controls into typeaheads.
It's impossible to write a typeahead library that supports every use-case out
of the box  that was the main motivation behind decomposing typeahead.js.
Previously, some prospective typeahead.js users were unable to use the library
because either the suggestion engine or the typeahead UI did not meet their
requirements. In those cases, they were either forced to fork typeahead.js and
make the necessary modifications or they had to give up on using typeahead.js
entirely. Now they have the option of swapping out the component that doesn't
work for them with a custom implementation.
### 0.9.3 June 24, 2013
* Ensure cursor visibility in menus with overflow. [#209]
* Fixed bug that led to the menu staying open when it should have been closed. [#260]
* Private browsing in Safari no longer breaks prefetch. [#270]
* Pressing tab while a suggestion is highlighted now results in a selection. [#266]
* Dataset name is now passed as an argument for typeahead:selected event. [#207]
### 0.9.2 April 14, 2013
* Prefetch usage no longer breaks when cookies are disabled. [#190]
* Precompiled templates are now wrapped in the appropriate DOM element. [#172]
### 0.9.1 April 1, 2013
* Multiple requests no longer get sent for a query when datasets share a remote source. [#152]
* Datasets now support precompiled templates. [#137]
* Cached remote suggestions now get rendered immediately. [#156]
* Added typeahead:autocompleted event. [#132]
* Added a plugin method for programmatically setting the query. Experimental. [#159]
* Added minLength option for datasets. Experimental. [#131]
* Prefetch objects now support thumbprint option. Experimental. [#157]
### 0.9.0 March 24, 2013
**Custom events, no more typeahead.css, and an improved API**
* Implemented the triggering of custom events. [#106]
* Got rid of typeahead.css and now apply styling through JavaScript. [#15]
* Made the API more flexible and addressed a handful of remote issues by rewriting the transport component. [#25]
* Added support for dataset headers and footers. [#81]
* No longer cache unnamed datasets. [#116]
* Made the key name of the value property configurable. [#115]
* Input values set before initialization of typeaheads are now respected. [#109]
* Fixed an input value/hint casing bug. [#108]
### 0.8.2 March 04, 2013
* Fixed bug causing error to be thrown when initializing a typeahead on multiple elements. [#51]
* Tokens with falsy values are now filtered out was causing wonky behavior. [#75]
* No longer making remote requests for blank queries. [#74]
* Datums with regex characters in their value no longer cause errors. [#77]
* Now compatible with the Closure Compiler. [#48]
* Reference to jQuery is now obtained through window.jQuery, not window.$. [#47]
* Added a plugin method for destroying typeaheads. Won't be documented until v0.9 and might change before then. [#59]
### 0.8.1 February 25, 2013
* Fixed bug preventing local and prefetch from being used together. [#39]
* No longer prevent default browser behavior when up or down arrow is pressed with a modifier. [#6]
* Hint is hidden when user entered query is wider than the input. [#26]
* Data stored in localStorage now expires properly. [#34]
* Normalized search tokens and fixed query tokenization. [#38]
* Remote suggestions now are appended, not prepended to suggestions list. [#40]
* Fixed some typos through the codebase. [#3]
### 0.8.0 February 19, 2013
**Initial public release**
* Prefetch and search data locally insanely fast.
* Search hard-coded, prefetched, and/or remote data.
* Hinting.
* RTL/IME/international support.
* Search multiple datasets.
* Share datasets (and caching) between multiple inputs.
* And much, much more...
[0.10.0 milestone]: https://github.com/twitter/typeahead.js/issues?milestone=8&page=1&state=closed
[#1181]: https://github.com/twitter/typeahead.js/pull/1181
[#1143]: https://github.com/twitter/typeahead.js/pull/1143
[#1110]: https://github.com/twitter/typeahead.js/pull/1110
[#964]: https://github.com/twitter/typeahead.js/pull/964
[#917]: https://github.com/twitter/typeahead.js/pull/917
[#899]: https://github.com/twitter/typeahead.js/pull/899
[#881]: https://github.com/twitter/typeahead.js/pull/881
[#839]: https://github.com/twitter/typeahead.js/pull/839
[#833]: https://github.com/twitter/typeahead.js/pull/833
[#815]: https://github.com/twitter/typeahead.js/pull/815
[#811]: https://github.com/twitter/typeahead.js/pull/811
[#809]: https://github.com/twitter/typeahead.js/pull/809
[#771]: https://github.com/twitter/typeahead.js/pull/771
[#754]: https://github.com/twitter/typeahead.js/pull/754
[#742]: https://github.com/twitter/typeahead.js/pull/742
[#718]: https://github.com/twitter/typeahead.js/pull/718
[#710]: https://github.com/twitter/typeahead.js/pull/710
[#705]: https://github.com/twitter/typeahead.js/pull/705
[#703]: https://github.com/twitter/typeahead.js/pull/703
[#687]: https://github.com/twitter/typeahead.js/pull/687
[#664]: https://github.com/twitter/typeahead.js/pull/664
[#659]: https://github.com/twitter/typeahead.js/pull/659
[#646]: https://github.com/twitter/typeahead.js/pull/646
[#633]: https://github.com/twitter/typeahead.js/pull/633
[#630]: https://github.com/twitter/typeahead.js/pull/630
[#612]: https://github.com/twitter/typeahead.js/pull/612
[#610]: https://github.com/twitter/typeahead.js/pull/610
[#485]: https://github.com/twitter/typeahead.js/pull/485
[#270]: https://github.com/twitter/typeahead.js/pull/270
[#266]: https://github.com/twitter/typeahead.js/pull/266
[#260]: https://github.com/twitter/typeahead.js/pull/260
[#209]: https://github.com/twitter/typeahead.js/pull/209
[#207]: https://github.com/twitter/typeahead.js/pull/207
[#190]: https://github.com/twitter/typeahead.js/pull/190
[#172]: https://github.com/twitter/typeahead.js/pull/172
[#159]: https://github.com/twitter/typeahead.js/pull/159
[#157]: https://github.com/twitter/typeahead.js/pull/157
[#156]: https://github.com/twitter/typeahead.js/pull/156
[#152]: https://github.com/twitter/typeahead.js/pull/152
[#137]: https://github.com/twitter/typeahead.js/pull/137
[#132]: https://github.com/twitter/typeahead.js/pull/132
[#131]: https://github.com/twitter/typeahead.js/pull/131
[#118]: https://github.com/twitter/typeahead.js/pull/118
[#116]: https://github.com/twitter/typeahead.js/pull/116
[#115]: https://github.com/twitter/typeahead.js/pull/115
[#109]: https://github.com/twitter/typeahead.js/pull/109
[#108]: https://github.com/twitter/typeahead.js/pull/108
[#106]: https://github.com/twitter/typeahead.js/pull/106
[#81]: https://github.com/twitter/typeahead.js/pull/81
[#77]: https://github.com/twitter/typeahead.js/pull/77
[#75]: https://github.com/twitter/typeahead.js/pull/75
[#74]: https://github.com/twitter/typeahead.js/pull/74
[#59]: https://github.com/twitter/typeahead.js/pull/59
[#51]: https://github.com/twitter/typeahead.js/pull/51
[#48]: https://github.com/twitter/typeahead.js/pull/48
[#47]: https://github.com/twitter/typeahead.js/pull/47
[#40]: https://github.com/twitter/typeahead.js/pull/40
[#39]: https://github.com/twitter/typeahead.js/pull/39
[#38]: https://github.com/twitter/typeahead.js/pull/38
[#34]: https://github.com/twitter/typeahead.js/pull/34
[#26]: https://github.com/twitter/typeahead.js/pull/26
[#25]: https://github.com/twitter/typeahead.js/pull/25
[#15]: https://github.com/twitter/typeahead.js/pull/15
[#6]: https://github.com/twitter/typeahead.js/pull/6
[#3]: https://github.com/twitter/typeahead.js/pull/3

View File

@@ -135,7 +135,6 @@ module.exports = function(grunt) {
bloodhound: {
src: '<%= tempDir %>/bloodhound.js',
objectToExport: 'Bloodhound',
amdModuleId: 'bloodhound',
deps: {
default: ['$'],
amd: ['jquery'],
@@ -145,7 +144,6 @@ module.exports = function(grunt) {
},
typeahead: {
src: '<%= tempDir %>/typeahead.jquery.js',
amdModuleId: 'typeahead.js',
deps: {
default: ['$'],
amd: ['jquery'],

View File

@@ -1,188 +0,0 @@
[![build status](https://secure.travis-ci.org/twitter/typeahead.js.svg?branch=master)](http://travis-ci.org/twitter/typeahead.js)
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
[typeahead.js][gh-page]
=======================
Inspired by [twitter.com]'s autocomplete search functionality, typeahead.js is
a flexible JavaScript library that provides a strong foundation for building
robust typeaheads.
The typeahead.js library consists of 2 components: the suggestion engine,
[Bloodhound], and the UI view, [Typeahead].
The suggestion engine is responsible for computing suggestions for a given
query. The UI view is responsible for rendering suggestions and handling DOM
interactions. Both components can be used separately, but when used together,
they can provide a rich typeahead experience.
<!-- section links -->
[gh-page]: http://twitter.github.io/typeahead.js/
[twitter.com]: https://twitter.com
[Bloodhound]: https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md
[Typeahead]: https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md
Getting Started
---------------
How you acquire typeahead.js is up to you.
Preferred method:
* Install with [Bower]: `$ bower install typeahead.js`
Other methods:
* [Download zipball of latest release][zipball].
* Download the latest dist files individually:
* *[bloodhound.js]* (standalone suggestion engine)
* *[typeahead.jquery.js]* (standalone UI view)
* *[typeahead.bundle.js]* (*bloodhound.js* + *typeahead.jquery.js*)
* *[typeahead.bundle.min.js]*
**Note:** both *bloodhound.js* and *typeahead.jquery.js* have a dependency on
[jQuery] 1.9+.
<!-- section links -->
[Bower]: http://bower.io/
[zipball]: http://twitter.github.com/typeahead.js/releases/latest/typeahead.js.zip
[bloodhound.js]: http://twitter.github.com/typeahead.js/releases/latest/bloodhound.js
[typeahead.jquery.js]: http://twitter.github.com/typeahead.js/releases/latest/typeahead.jquery.js
[typeahead.bundle.js]: http://twitter.github.com/typeahead.js/releases/latest/typeahead.bundle.js
[typeahead.bundle.min.js]: http://twitter.github.com/typeahead.js/releases/latest/typeahead.bundle.min.js
[jQuery]: http://jquery.com/
Documentation
-------------
* [Typeahead Docs]
* [Bloodhound Docs]
[Typeahead Docs]: https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md
[Bloodhound Docs]: https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md
Examples
--------
For some working examples of typeahead.js, visit the [examples page].
<!-- section links -->
[examples page]: http://twitter.github.io/typeahead.js/examples
Browser Support
---------------
* Chrome
* Firefox 3.5+
* Safari 4+
* Internet Explorer 8+
* Opera 11+
**NOTE:** typeahead.js is not tested on mobile browsers.
Customer Support
----------------
For general questions about typeahead.js, tweet at [@typeahead].
For technical questions, you should post a question on [Stack Overflow] and tag
it with [typeahead.js][so tag].
<!-- section links -->
[Stack Overflow]: http://stackoverflow.com/
[@typeahead]: https://twitter.com/typeahead
[so tag]: http://stackoverflow.com/questions/tagged/typeahead.js
Issues
------
Discovered a bug? Please create an issue here on GitHub!
https://github.com/twitter/typeahead.js/issues
Versioning
----------
For transparency and insight into our release cycle, releases will be numbered
with the following format:
`<major>.<minor>.<patch>`
And constructed with the following guidelines:
* Breaking backwards compatibility bumps the major
* New additions without breaking backwards compatibility bumps the minor
* Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit http://semver.org/.
Testing
-------
Tests are written using [Jasmine] and ran with [Karma]. To run
the test suite with PhantomJS, run `$ npm test`.
<!-- section links -->
[Jasmine]: http://jasmine.github.io/
[Karma]: http://karma-runner.github.io/
Developers
----------
If you plan on contributing to typeahead.js, be sure to read the
[contributing guidelines]. A good starting place for new contributors are issues
labeled with [entry-level]. Entry-level issues tend to require minor changes
and provide developers a chance to get more familiar with typeahead.js before
taking on more challenging work.
In order to build and test typeahead.js, you'll need to install its dev
dependencies (`$ npm install`) and have [grunt-cli]
installed (`$ npm install -g grunt-cli`). Below is an overview of the available
Grunt tasks that'll be useful in development.
* `grunt build` Builds *typeahead.js* from source.
* `grunt lint` Runs source and test files through JSHint.
* `grunt watch` Rebuilds *typeahead.js* whenever a source file is modified.
* `grunt server` Serves files from the root of typeahead.js on localhost:8888.
Useful for using *test/playground.html* for debugging/testing.
* `grunt dev` Runs `grunt watch` and `grunt server` in parallel.
<!-- section links -->
[contributing guidelines]: https://github.com/twitter/typeahead.js/blob/master/CONTRIBUTING.md
[entry-level]: https://github.com/twitter/typeahead.js/issues?&labels=entry-level&state=open
[grunt-cli]: https://github.com/gruntjs/grunt-cli
Maintainers
-----------
* **Jake Harding**
* [@JakeHarding](https://twitter.com/JakeHarding)
* [GitHub](https://github.com/jharding)
* **You?**
Authors
-------
* **Jake Harding**
* [@JakeHarding](https://twitter.com/JakeHarding)
* [GitHub](https://github.com/jharding)
* **Veljko Skarich**
* [@vskarich](https://twitter.com/vskarich)
* [GitHub](https://github.com/vskarich)
* **Tim Trueman**
* [@timtrueman](https://twitter.com/timtrueman)
* [GitHub](https://github.com/timtrueman)
License
-------
Copyright 2013 Twitter, Inc.
Licensed under the MIT License

View File

@@ -1,5 +1,5 @@
{
"name": "typeahead.js",
"name": "corejs-typeahead",
"version": "0.11.1",
"main": "dist/typeahead.bundle.js",
"dependencies": {
@@ -8,6 +8,9 @@
"devDependencies": {
"jquery": "~1.7",
"jasmine-ajax": "~1.3.1",
"jasmine-jquery": "~1.5.2"
"jasmine-jquery": "~1.7.0"
},
"resolutions": {
"jquery": "1.7.2"
}
}
}

171
lib/typeahead/changelog.md Normal file
View File

@@ -0,0 +1,171 @@
# Changelog
### 0.11.2 TBD, 2015
* Add matchAnyQueryToken option. [#2](https://github.com/corejavascript/typeahead.js/pull/2)
* Update rendered-count after async results have displayed. [#8](https://github.com/corejavascript/typeahead.js/pull/8)
* Add default on option to stop propagation when selecting an entry. [#13](https://github.com/corejavascript/typeahead.js/pull/13)
### 0.11.1 April 26, 2015
* Add prepare option to prefetch. [#1181](https://github.com/twitter/typeahead.js/pull/1181)
* Handle QuotaExceededError. [#1110](https://github.com/twitter/typeahead.js/pull/1110)
* Escape HTML entities from suggestion display value when rendering with default
template. [#964](https://github.com/twitter/typeahead.js/pull/964)
* List jquery as a dependency in package.json. [#1143](https://github.com/twitter/typeahead.js/pull/1143)
### 0.11.0 April 25, 2015
An overhaul of typeahead.js  consider this a release candidate for v1. There
are bunch of API changes with this release so don't expect backwards
compatibility with previous versions. There are also many new undocumented
features that have been introduced. Documentation for those features will be
added before v1 ships.
Beware that since this release is pretty much a rewrite, there are bound to be
some bugs. To be safe, you should consider this release beta software and
throughly test your integration of it before using it in production
environments. This caveat only applies to this release as subsequent releases
will address any issues that come up.
### 0.10.5 August 7, 2014
* Increase supported version range for jQuery dependency. [#917](https://github.com/twitter/typeahead.js/pull/917)
### 0.10.4 July 13, 2014
**Hotfix**
* Fix regression that breaks Bloodhound instances when more than 1 instance is
relying on remote data. [#899](https://github.com/twitter/typeahead.js/pull/899)
### 0.10.3 July 10, 2014
**Bug fixes**
* `Bloodhound#clearPrefetchCache` now works with cache keys that contain regex
characters. [#771](https://github.com/twitter/typeahead.js/pull/771)
* Prevent outdated network requests from being sent. [#809](https://github.com/twitter/typeahead.js/pull/809)
* Add support to object tokenizers for multiple property tokenization. [#811](https://github.com/twitter/typeahead.js/pull/811)
* Fix broken `jQuery#typeahead('val')` method. [#815](https://github.com/twitter/typeahead.js/pull/815)
* Remove `disabled` attribute from the hint input control. [#839](https://github.com/twitter/typeahead.js/pull/839)
* Add `tt-highlight` class to highlighted text. [#833](https://github.com/twitter/typeahead.js/pull/833)
* Handle non-string types that are passed to `jQuery#typeahead('val', val)`. [#881](https://github.com/twitter/typeahead.js/pull/881)
### 0.10.2 March 10, 2014
* Prevent flickering of dropdown menu when requesting remote suggestions. [#718](https://github.com/twitter/typeahead.js/pull/718)
* Reduce hint flickering. [#754](https://github.com/twitter/typeahead.js/pull/754)
* Added `Bloodhound#{clear, clearPrefetchCache, clearRemoteCache}` and made it
possible to reinitialize Bloodhound instances. [#703](https://github.com/twitter/typeahead.js/pull/703)
* Invoke `local` function during initialization. [#687](https://github.com/twitter/typeahead.js/pull/687)
* In addition to HTML strings, templates can now return DOM nodes. [#742](https://github.com/twitter/typeahead.js/pull/742)
* Prevent `jQuery#typeahead('val', val)` from opening dropdown menus of
non-active typeaheads. [#646](https://github.com/twitter/typeahead.js/pull/646)
* Fix bug in IE that resulted in dropdown menus with overflow being closed
when clicking on the scrollbar. [#705](https://github.com/twitter/typeahead.js/pull/705)
* Only show dropdown menu if `minLength` is satisfied. [#710](https://github.com/twitter/typeahead.js/pull/710)
### 0.10.1 February 9, 2014
**Hotfix**
* Fixed bug that prevented some ajax configs from being respected. [#630](https://github.com/twitter/typeahead.js/pull/630)
* Event delegation on suggestion clicks is no longer broken. [#118](https://github.com/twitter/typeahead.js/pull/118)
* Ensure dataset names are valid class name suffixes. [#610](https://github.com/twitter/typeahead.js/pull/610)
* Added support for `displayKey` to be a function. [#633](https://github.com/twitter/typeahead.js/pull/633)
* `jQuery#typeahead('val')` now mirrors `jQuery#val()`. [#659](https://github.com/twitter/typeahead.js/pull/659)
* Datasets can now be passed to jQuery plugin as an array. [#664](https://github.com/twitter/typeahead.js/pull/664)
* Added a `noConflict` method to the jQuery plugin. [#612](https://github.com/twitter/typeahead.js/pull/612)
* Bloodhound's `local` property can now be a function. [#485](https://github.com/twitter/typeahead.js/pull/485)
### 0.10.0 February 2, 2014
**Introducting Bloodhound**
This release was almost a complete rewrite of typeahead.js and will hopefully
lay the foundation for the 1.0.0 release. It's impossible to enumerate all of
the issues that were fixed. If you want to get an idea of what issues 0.10.0
resolved, take a look at the closed issues in the [0.10.0 milestone](https://github.com/twitter/typeahead.js/issues?milestone=8&page=1&state=closed).
The most important change in 0.10.0 is that typeahead.js was broken up into 2
individual components: Bloodhound and jQuery#typeahead. Bloodhound is an
feature-rich suggestion engine. jQuery#typeahead is a jQuery plugin that turns
input controls into typeaheads.
It's impossible to write a typeahead library that supports every use-case out
of the box  that was the main motivation behind decomposing typeahead.js.
Previously, some prospective typeahead.js users were unable to use the library
because either the suggestion engine or the typeahead UI did not meet their
requirements. In those cases, they were either forced to fork typeahead.js and
make the necessary modifications or they had to give up on using typeahead.js
entirely. Now they have the option of swapping out the component that doesn't
work for them with a custom implementation.
### 0.9.3 June 24, 2013
* Ensure cursor visibility in menus with overflow. [#209](https://github.com/twitter/typeahead.js/pull/209)
* Fixed bug that led to the menu staying open when it should have been closed. [#260](https://github.com/twitter/typeahead.js/pull/260)
* Private browsing in Safari no longer breaks prefetch. [#270](https://github.com/twitter/typeahead.js/pull/270)
* Pressing tab while a suggestion is highlighted now results in a selection. [#266](https://github.com/twitter/typeahead.js/pull/266)
* Dataset name is now passed as an argument for typeahead:selected event. [#207](https://github.com/twitter/typeahead.js/pull/207)
### 0.9.2 April 14, 2013
* Prefetch usage no longer breaks when cookies are disabled. [#190](https://github.com/twitter/typeahead.js/pull/190)
* Precompiled templates are now wrapped in the appropriate DOM element. [#172](https://github.com/twitter/typeahead.js/pull/172)
### 0.9.1 April 1, 2013
* Multiple requests no longer get sent for a query when datasets share a remote source. [#152](https://github.com/twitter/typeahead.js/pull/152)
* Datasets now support precompiled templates. [#137](https://github.com/twitter/typeahead.js/pull/137)
* Cached remote suggestions now get rendered immediately. [#156](https://github.com/twitter/typeahead.js/pull/156)
* Added typeahead:autocompleted event. [#132](https://github.com/twitter/typeahead.js/pull/132)
* Added a plugin method for programmatically setting the query. Experimental. [#159](https://github.com/twitter/typeahead.js/pull/159)
* Added minLength option for datasets. Experimental. [#131](https://github.com/twitter/typeahead.js/pull/131)
* Prefetch objects now support thumbprint option. Experimental. [#157](https://github.com/twitter/typeahead.js/pull/157)
### 0.9.0 March 24, 2013
**Custom events, no more typeahead.css, and an improved API**
* Implemented the triggering of custom events. [#106](https://github.com/twitter/typeahead.js/pull/106)
* Got rid of typeahead.css and now apply styling through JavaScript. [#15](https://github.com/twitter/typeahead.js/pull/15)
* Made the API more flexible and addressed a handful of remote issues by rewriting the transport component. [#25](https://github.com/twitter/typeahead.js/pull/81)
* Added support for dataset headers and footers. [#81](https://github.com/twitter/typeahead.js/pull/81)
* No longer cache unnamed datasets. [#116](https://github.com/twitter/typeahead.js/pull/116)
* Made the key name of the value property configurable. [#115](https://github.com/twitter/typeahead.js/pull/115)
* Input values set before initialization of typeaheads are now respected. [#109](https://github.com/twitter/typeahead.js/pull/109)
* Fixed an input value/hint casing bug. [#108](https://github.com/twitter/typeahead.js/pull/108)
### 0.8.2 March 04, 2013
* Fixed bug causing error to be thrown when initializing a typeahead on multiple elements. [#51](https://github.com/twitter/typeahead.js/pull/51)
* Tokens with falsy values are now filtered out was causing wonky behavior. [#75](https://github.com/twitter/typeahead.js/pull/75)
* No longer making remote requests for blank queries. [#74](https://github.com/twitter/typeahead.js/pull/74)
* Datums with regex characters in their value no longer cause errors. [#77](https://github.com/twitter/typeahead.js/pull/77)
* Now compatible with the Closure Compiler. [#48](https://github.com/twitter/typeahead.js/pull/48)
* Reference to jQuery is now obtained through window.jQuery, not window.$. [#47](https://github.com/twitter/typeahead.js/pull/47)
* Added a plugin method for destroying typeaheads. Won't be documented until v0.9 and might change before then. [#59](https://github.com/twitter/typeahead.js/pull/59)
### 0.8.1 February 25, 2013
* Fixed bug preventing local and prefetch from being used together. [#39](https://github.com/twitter/typeahead.js/pull/39)
* No longer prevent default browser behavior when up or down arrow is pressed with a modifier. [#6](https://github.com/twitter/typeahead.js/pull/6)
* Hint is hidden when user entered query is wider than the input. [#26](https://github.com/twitter/typeahead.js/pull/26)
* Data stored in localStorage now expires properly. [#34](https://github.com/twitter/typeahead.js/pull/34)
* Normalized search tokens and fixed query tokenization. [#38](https://github.com/twitter/typeahead.js/pull/38)
* Remote suggestions now are appended, not prepended to suggestions list. [#40](https://github.com/twitter/typeahead.js/pull/40)
* Fixed some typos through the codebase. [#3](https://github.com/twitter/typeahead.js/pull/3)
### 0.8.0 February 19, 2013
**Initial public release**
* Prefetch and search data locally insanely fast.
* Search hard-coded, prefetched, and/or remote data.
* Hinting.
* RTL/IME/international support.
* Search multiple datasets.
* Share datasets (and caching) between multiple inputs.
* And much, much more...

View File

@@ -6,7 +6,7 @@
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define("bloodhound", [ "jquery" ], function(a0) {
define([ "jquery" ], function(a0) {
return root["Bloodhound"] = factory(a0);
});
} else if (typeof exports === "object") {
@@ -423,6 +423,7 @@
this.identify = o.identify || _.stringify;
this.datumTokenizer = o.datumTokenizer;
this.queryTokenizer = o.queryTokenizer;
this.matchAnyQueryToken = o.matchAnyQueryToken;
this.reset();
}
_.mixin(SearchIndex.prototype, {
@@ -459,7 +460,7 @@
tokens = normalizeTokens(this.queryTokenizer(query));
_.each(tokens, function(token) {
var node, chars, ch, ids;
if (matches && matches.length === 0) {
if (matches && matches.length === 0 && !that.matchAnyQueryToken) {
return false;
}
node = that.trie;
@@ -471,8 +472,10 @@
ids = node[IDS].slice(0);
matches = matches ? getIntersection(matches, ids) : ids;
} else {
matches = [];
return false;
if (!that.matchAnyQueryToken) {
matches = [];
return false;
}
}
});
return matches ? _.map(unique(matches), function(id) {
@@ -614,6 +617,7 @@
this.url = o.url;
this.prepare = o.prepare;
this.transform = o.transform;
this.indexResponse = o.indexResponse;
this.transport = new Transport({
cache: o.cache,
limiter: o.limiter,
@@ -655,7 +659,9 @@
identify: _.stringify,
datumTokenizer: null,
queryTokenizer: null,
matchAnyQueryToken: false,
sufficient: 5,
indexRemote: false,
sorter: null,
local: [],
prefetch: null,
@@ -806,6 +812,7 @@
this.sorter = o.sorter;
this.identify = o.identify;
this.sufficient = o.sufficient;
this.indexRemote = o.indexRemote;
this.local = o.local;
this.remote = o.remote ? new Remote(o.remote) : null;
this.prefetch = o.prefetch ? new Prefetch(o.prefetch) : null;
@@ -875,6 +882,8 @@
},
search: function search(query, sync, async) {
var that = this, local;
sync = sync || _.noop;
async = async || _.noop;
local = this.sorter(this.index.search(query));
sync(this.remote ? local.slice() : local);
if (this.remote && local.length < this.sufficient) {
@@ -890,7 +899,8 @@
return that.identify(r) === that.identify(l);
}) && nonDuplicates.push(r);
});
async && async(nonDuplicates);
that.indexRemote && that.add(nonDuplicates);
async(nonDuplicates);
}
},
all: function all() {

View File

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define("bloodhound", [ "jquery" ], function(a0) {
define([ "jquery" ], function(a0) {
return root["Bloodhound"] = factory(a0);
});
} else if (typeof exports === "object") {
@@ -423,6 +423,7 @@
this.identify = o.identify || _.stringify;
this.datumTokenizer = o.datumTokenizer;
this.queryTokenizer = o.queryTokenizer;
this.matchAnyQueryToken = o.matchAnyQueryToken;
this.reset();
}
_.mixin(SearchIndex.prototype, {
@@ -459,7 +460,7 @@
tokens = normalizeTokens(this.queryTokenizer(query));
_.each(tokens, function(token) {
var node, chars, ch, ids;
if (matches && matches.length === 0) {
if (matches && matches.length === 0 && !that.matchAnyQueryToken) {
return false;
}
node = that.trie;
@@ -471,8 +472,10 @@
ids = node[IDS].slice(0);
matches = matches ? getIntersection(matches, ids) : ids;
} else {
matches = [];
return false;
if (!that.matchAnyQueryToken) {
matches = [];
return false;
}
}
});
return matches ? _.map(unique(matches), function(id) {
@@ -614,6 +617,7 @@
this.url = o.url;
this.prepare = o.prepare;
this.transform = o.transform;
this.indexResponse = o.indexResponse;
this.transport = new Transport({
cache: o.cache,
limiter: o.limiter,
@@ -655,7 +659,9 @@
identify: _.stringify,
datumTokenizer: null,
queryTokenizer: null,
matchAnyQueryToken: false,
sufficient: 5,
indexRemote: false,
sorter: null,
local: [],
prefetch: null,
@@ -806,6 +812,7 @@
this.sorter = o.sorter;
this.identify = o.identify;
this.sufficient = o.sufficient;
this.indexRemote = o.indexRemote;
this.local = o.local;
this.remote = o.remote ? new Remote(o.remote) : null;
this.prefetch = o.prefetch ? new Prefetch(o.prefetch) : null;
@@ -875,6 +882,8 @@
},
search: function search(query, sync, async) {
var that = this, local;
sync = sync || _.noop;
async = async || _.noop;
local = this.sorter(this.index.search(query));
sync(this.remote ? local.slice() : local);
if (this.remote && local.length < this.sufficient) {
@@ -890,7 +899,8 @@
return that.identify(r) === that.identify(l);
}) && nonDuplicates.push(r);
});
async && async(nonDuplicates);
that.indexRemote && that.add(nonDuplicates);
async(nonDuplicates);
}
},
all: function all() {
@@ -919,7 +929,7 @@
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define("typeahead.js", [ "jquery" ], function(a0) {
define([ "jquery" ], function(a0) {
return factory(a0);
});
} else if (typeof exports === "object") {
@@ -1720,8 +1730,8 @@
suggestions = suggestions || [];
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;
that.async && that.trigger("asyncReceived", query);
}
}
@@ -1825,6 +1835,9 @@
var that = this, onSelectableClick;
onSelectableClick = _.bind(this._onSelectableClick, this);
this.$node.on("click.tt", this.selectors.selectable, onSelectableClick);
this.$node.on("mouseover", this.selectors.selectable, function() {
that.setCursor($(this));
});
_.each(this.datasets, function(dataset) {
dataset.onSync("asyncRequested", that._propagate, that).onSync("asyncCanceled", that._propagate, that).onSync("asyncReceived", that._propagate, that).onSync("rendered", that._onRendered, that).onSync("cleared", that._onCleared, that);
});
@@ -1834,6 +1847,7 @@
return this.$node.hasClass(this.classes.open);
},
open: function open() {
this.$node.scrollTop(0);
this.$node.addClass(this.classes.open);
},
close: function close() {
@@ -2057,12 +2071,12 @@
},
_onLeftKeyed: function onLeftKeyed() {
if (this.dir === "rtl" && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onRightKeyed: function onRightKeyed() {
if (this.dir === "ltr" && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onQueryChanged: function onQueryChanged(e, query) {
@@ -2363,7 +2377,7 @@
return query;
} else {
ttEach(this, function(t) {
t.setVal(newVal);
t.setVal(_.toStr(newVal));
});
return this;
}

View File

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
(function(root, factory) {
if (typeof define === "function" && define.amd) {
define("typeahead.js", [ "jquery" ], function(a0) {
define([ "jquery" ], function(a0) {
return factory(a0);
});
} else if (typeof exports === "object") {
@@ -807,8 +807,8 @@
suggestions = suggestions || [];
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;
that.async && that.trigger("asyncReceived", query);
}
}
@@ -912,6 +912,9 @@
var that = this, onSelectableClick;
onSelectableClick = _.bind(this._onSelectableClick, this);
this.$node.on("click.tt", this.selectors.selectable, onSelectableClick);
this.$node.on("mouseover", this.selectors.selectable, function() {
that.setCursor($(this));
});
_.each(this.datasets, function(dataset) {
dataset.onSync("asyncRequested", that._propagate, that).onSync("asyncCanceled", that._propagate, that).onSync("asyncReceived", that._propagate, that).onSync("rendered", that._onRendered, that).onSync("cleared", that._onCleared, that);
});
@@ -921,6 +924,7 @@
return this.$node.hasClass(this.classes.open);
},
open: function open() {
this.$node.scrollTop(0);
this.$node.addClass(this.classes.open);
},
close: function close() {
@@ -1144,12 +1148,12 @@
},
_onLeftKeyed: function onLeftKeyed() {
if (this.dir === "rtl" && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onRightKeyed: function onRightKeyed() {
if (this.dir === "ltr" && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onQueryChanged: function onQueryChanged(e, query) {
@@ -1450,7 +1454,7 @@
return query;
} else {
ttEach(this, function(t) {
t.setVal(newVal);
t.setVal(_.toStr(newVal));
});
return this;
}

View File

File diff suppressed because one or more lines are too long

View File

@@ -136,7 +136,7 @@ contain at least `sufficient` number of datums, `remote` data will be requested
and then passed to the `async` callback.
```javascript
bloodhound.get(myQuery, sync, async);
bloodhound.search(myQuery, sync, async);
function sync(datums) {
console.log('datums from `local`, `prefetch`, and `#add`');
@@ -169,6 +169,10 @@ options you can configure.
* `queryTokenizer`  A function with the signature `(query)` that transforms a
query into an array of string tokens. **Required**.
* `matchAnyQueryToken` - By default a search result must match ALL query-tokens.
Instead, this option returns results that match ANY query-tokens. Defaults to
`false`.
* `initialize`  If set to `false`, the Bloodhound instance will not be
implicitly initialized by the constructor function. Defaults to `true`.
@@ -193,6 +197,9 @@ options you can configure.
the internal search index is insufficient or, if more configurability is
needed, a [remote options hash](#remote).
* `indexRemote` Adds the data loaded from `remote` to the search index (where
`local` and `prefetch` are stored for retrieval). Defaults to `false`.
<!-- section links -->
[compare function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
@@ -252,15 +259,15 @@ When configuring `remote`, the following options are available.
* `url` The URL remote data should be loaded from. **Required.**
* `prepare`  A function that provides a hook to allow you to prepare the
settings object passed to `transport` when a request is about to be made.
The function signature should be `prepare(query, settings)`, where `query` is
the query `#search` was called with and `settings` is the default settings
object created internally by the Bloodhound instance. The `prepare` function
should return a settings object. Defaults to the [identity function].
settings object passed to `transport` when a request is about to be made.
The function signature should be `prepare(query, settings)`, where `query` is
the query `#search` was called with and `settings` is the default settings
object created internally by the Bloodhound instance. The `prepare` function
should return a settings object. Defaults to the [identity function].
* `wildcard` A convenience option for `prepare`. If set, `prepare` will be a
function that replaces the value of this option in `url` with the URI encoded
query.
function that replaces the value of this option in `url` with the URI encoded
query.
* `rateLimitBy` The method used to rate-limit network requests. Can be either
`debounce` or `throttle`. Defaults to `debounce`.
@@ -269,8 +276,8 @@ When configuring `remote`, the following options are available.
`rateLimitBy`. Defaults to `300`.
* `transform`  A function with the signature `transform(response)` that allows
you to transform the remote response before the Bloodhound instance operates
on it. Defaults to the [identity function].
you to transform the remote response before the Bloodhound instance operates
on it. Defaults to the [identity function].
<!-- section links -->

View File

@@ -1,15 +1,15 @@
{
"name": "typeahead.js",
"name": "corejs-typeahead",
"description": "fast and fully-featured autocomplete library",
"keywords": [
"typeahead",
"autocomplete"
],
"homepage": "http://twitter.github.com/typeahead.js",
"bugs": "https://github.com/twitter/typeahead.js/issues",
"homepage": "http://corejavascript.github.io/typeahead.js/",
"bugs": "https://github.com/corejavascript/typeahead.js/issues",
"repository": {
"type": "git",
"url": "https://github.com/twitter/typeahead.js.git"
"url": "https://github.com/corejavascript/typeahead.js.git"
},
"author": {
"name": "Twitter, Inc.",
@@ -29,40 +29,43 @@
"url": "https://twitter.com/vskarich"
}
],
"license": "See license in LICENSE",
"dependencies": {
"jquery": ">=1.7"
},
"devDependencies": {
"chai": "^1.9.1",
"colors": "^0.6.2",
"chai": "^3.3.0",
"colors": "^1.1.2",
"grunt": "~0.4",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.1",
"grunt-contrib-connect": "~0.1",
"grunt-contrib-jshint": "~0.8",
"grunt-contrib-uglify": "~0.2.6",
"grunt-contrib-watch": "~0.2",
"grunt-concurrent": "^2.0.3",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-uglify": "^0.9.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-exec": "~0.4.5",
"grunt-sed": "~0.1",
"grunt-step": "~0.2.0",
"grunt-umd": "^2.3.3",
"karma": "^0.12.22",
"karma-chrome-launcher": "^0.1.4",
"karma-coverage": "^0.2.6",
"karma": "^0.13.14",
"karma-chrome-launcher": "^0.2.1",
"karma-coverage": "^0.5.2",
"karma-firefox-launcher": "^0.1.3",
"karma-jasmine": "^0.1.5",
"karma-opera-launcher": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",
"karma-jasmine": "^0.1.6",
"karma-opera-launcher": "^0.3.0",
"karma-phantomjs-launcher": "^0.2.1",
"karma-safari-launcher": "^0.1.1",
"mocha": "^1.20.1",
"semver": "~1.1.3",
"mocha": "^2.3.3",
"node-static": "^0.7.7",
"semver": "^5.0.3",
"underscore": "^1.6.0",
"yiewd": "^0.5.0"
"yiewd": "^0.6.0"
},
"scripts": {
"postinstall": "bower install",
"test": "./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
},
"version": "0.11.1",
"main": "dist/typeahead.bundle.js"
}
}

135
lib/typeahead/readme.md Normal file
View File

@@ -0,0 +1,135 @@
[![Build Status](https://travis-ci.org/corejavascript/typeahead.js.svg?branch=master)](https://travis-ci.org/corejavascript/typeahead.js)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/corejavascript/typeahead.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![bitHound Score](https://www.bithound.io/github/corejavascript/typeahead.js/badges/score.svg)](https://www.bithound.io/github/corejavascript/typeahead.js)
[![bitHound Dependencies](https://www.bithound.io/github/corejavascript/typeahead.js/badges/dependencies.svg)](https://www.bithound.io/github/corejavascript/typeahead.js/master/dependencies/npm)
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iron/iron/master/LICENSE)
# [corejs-typeahead](https://typeahead.js.org/)
This is a maintained fork of [twitter.com](https://twitter.com)'s autocomplete search library, [typeahead.js](https://github.com/twitter/typeahead.js).
The typeahead.js library consists of 2 components: the suggestion engine,
[Bloodhound](https://github.com/corejavascript/typeahead.js/blob/master/doc/bloodhound.md), and the UI view, [Typeahead](https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md).
The suggestion engine is responsible for computing suggestions for a given
query. The UI view is responsible for rendering suggestions and handling DOM
interactions. Both components can be used separately, but when used together,
they can provide a rich typeahead experience.
## Getting Started
How you acquire typeahead.js is up to you:
* Install with [Bower](https://bower.io/): `$ bower install corejs-typeahead`
* Install with [npm](https://www.npmjs.com): `$ npm install corejs-typeahead`
* [Download zipball of latest release](https://github.com/corejavascript/typeahead.js/archive/master.zip)
* Download the latest dist files individually:
* [bloodhound.js](https://github.com/corejavascript/typeahead.js/raw/master/dist/bloodhound.js) (standalone suggestion engine)
* [typeahead.jquery.js](https://github.com/corejavascript/typeahead.js/raw/master/dist/typeahead.jquery.js) (standalone UI view)
* [typeahead.bundle.js](https://github.com/corejavascript/typeahead.js/raw/master/dist/typeahead.bundle.js) (*bloodhound.js* + *typeahead.jquery.js*)
* [typeahead.bundle.min.js](https://github.com/corejavascript/typeahead.js/raw/master/dist/typeahead.bundle.min.js)
**Note:** both *bloodhound.js* and *typeahead.jquery.js* have a dependency on
[jQuery](http://jquery.com/) 1.9+.
## Documentation
* [Typeahead Docs](https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md)
* [Bloodhound Docs](https://github.com/corejavascript/typeahead.js/blob/master/doc/bloodhound.md)
## Examples
For some working examples of typeahead.js, visit the [examples page](https://typeahead.js.org/examples).
## Browser Support
* Chrome
* Firefox 3.5+
* Safari 4+
* Internet Explorer 8+
* Opera 11+
**NOTE:** typeahead.js is not tested on mobile browsers.
## Customer Support
For general questions about typeahead.js, tweet at [@typeahead](https://twitter.com/typeahead).
For technical questions, you should post a question on [Stack Overflow](http://stackoverflow.com/) and tag
it with [typeahead.js](http://stackoverflow.com/questions/tagged/typeahead.js).
## Issues
Discovered a bug? Please create an issue here on GitHub!
[github.com/corejavascript/typeahead.js/issues](https://github.com/corejavascript/typeahead.js/issues)
## Versioning
For transparency and insight into our release cycle, releases will be numbered
with the following format:
`<major>.<minor>.<patch>`
And constructed with the following guidelines:
* Breaking backwards compatibility bumps the major
* New additions without breaking backwards compatibility bumps the minor
* Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit [semver.org](http://semver.org/).
## Testing
Tests are written using [Jasmine](http://jasmine.github.io/) and ran with [Karma](http://karma-runner.github.io/). To run
the test suite with PhantomJS, run `$ npm test`.
## Developers
If you plan on contributing to typeahead.js, be sure to read the
[contributing guidelines](https://github.com/corejavascript/typeahead.js/blob/master/CONTRIBUTING.md). A good starting place for new contributors are issues
labeled with [entry-level](https://github.com/corejavascript/typeahead.js/issues?&labels=entry-level&state=open). Entry-level issues tend to require minor changes
and provide developers a chance to get more familiar with typeahead.js before
taking on more challenging work.
In order to build and test typeahead.js, you'll need to install its dev
dependencies (`$ npm install`) and have [grunt-cli](https://github.com/gruntjs/grunt-cli)
installed (`$ npm install -g grunt-cli`). Below is an overview of the available
Grunt tasks that'll be useful in development.
* `grunt build` Builds *typeahead.js* from source.
* `grunt lint` Runs source and test files through JSHint.
* `grunt watch` Rebuilds *typeahead.js* whenever a source file is modified.
* `grunt server` Serves files from the root of typeahead.js on localhost:8888.
Useful for using *test/playground.html* for debugging/testing.
* `grunt dev` Runs `grunt watch` and `grunt server` in parallel.
## Maintainers
* **Jake Harding**
* [@JakeHarding](https://twitter.com/JakeHarding)
* [GitHub](https://github.com/jharding)
* **You?**
## Authors
* **Jake Harding**
* [@JakeHarding](https://twitter.com/JakeHarding)
* [GitHub](https://github.com/jharding)
* **Veljko Skarich**
* [@vskarich](https://twitter.com/vskarich)
* [GitHub](https://github.com/vskarich)
* **Tim Trueman**
* [@timtrueman](https://twitter.com/timtrueman)
* [GitHub](https://github.com/timtrueman)
## License
Copyright 2013 Twitter, Inc.
Licensed under the MIT License

View File

@@ -20,6 +20,7 @@ var Bloodhound = (function() {
this.sorter = o.sorter;
this.identify = o.identify;
this.sufficient = o.sufficient;
this.indexRemote = o.indexRemote;
this.local = o.local;
this.remote = o.remote ? new Remote(o.remote) : null;
@@ -132,6 +133,9 @@ var Bloodhound = (function() {
search: function search(query, sync, async) {
var that = this, local;
sync = sync || _.noop;
async = async || _.noop;
local = this.sorter(this.index.search(query));
// return a copy to guarantee no changes within this scope
@@ -159,7 +163,10 @@ var Bloodhound = (function() {
}) && nonDuplicates.push(r);
});
async && async(nonDuplicates);
// #1148: Should Bloodhound index remote datums?
that.indexRemote && that.add(nonDuplicates);
async(nonDuplicates);
}
},

View File

@@ -15,7 +15,9 @@ var oParser = (function() {
identify: _.stringify,
datumTokenizer: null,
queryTokenizer: null,
matchAnyQueryToken: false,
sufficient: 5,
indexRemote: false,
sorter: null,
local: [],
prefetch: null,

View File

@@ -14,6 +14,7 @@ var Remote = (function() {
this.url = o.url;
this.prepare = o.prepare;
this.transform = o.transform;
this.indexResponse = o.indexResponse;
this.transport = new Transport({
cache: o.cache,

View File

@@ -22,6 +22,7 @@ var SearchIndex = window.SearchIndex = (function() {
this.identify = o.identify || _.stringify;
this.datumTokenizer = o.datumTokenizer;
this.queryTokenizer = o.queryTokenizer;
this.matchAnyQueryToken = o.matchAnyQueryToken;
this.reset();
}
@@ -78,7 +79,7 @@ var SearchIndex = window.SearchIndex = (function() {
var node, chars, ch, ids;
// previous tokens didn't share any matches
if (matches && matches.length === 0) {
if (matches && matches.length === 0 && !that.matchAnyQueryToken) {
return false;
}
@@ -96,8 +97,10 @@ var SearchIndex = window.SearchIndex = (function() {
// break early if we find out there are no possible matches
else {
matches = [];
return false;
if (!that.matchAnyQueryToken) {
matches = [];
return false;
}
}
});

View File

@@ -269,8 +269,8 @@ var Dataset = (function() {
// do not render the suggestions as they've become outdated
if (!canceled && rendered < that.limit) {
that.cancel = $.noop;
rendered += suggestions.length;
that._append(query, suggestions.slice(0, that.limit - rendered));
rendered += suggestions.length;
that.async && that.trigger('asyncReceived', query);
}

View File

@@ -103,6 +103,7 @@ var Menu = (function() {
onSelectableClick = _.bind(this._onSelectableClick, this);
this.$node.on('click.tt', this.selectors.selectable, onSelectableClick);
this.$node.on('mouseover', this.selectors.selectable, function(){ that.setCursor($(this)) });
_.each(this.datasets, function(dataset) {
dataset
@@ -121,6 +122,7 @@ var Menu = (function() {
},
open: function open() {
this.$node.scrollTop(0);
this.$node.addClass(this.classes.open);
},

View File

@@ -159,7 +159,7 @@
return success;
},
// mirror jQuery#val functionality: reads opearte on first match,
// mirror jQuery#val functionality: reads operate on first match,
// write operates on all matches
val: function val(newVal) {
var query;
@@ -170,7 +170,7 @@
}
else {
ttEach(this, function(t) { t.setVal(newVal); });
ttEach(this, function(t) { t.setVal(_.toStr(newVal)); });
return this;
}
},
@@ -186,7 +186,7 @@
};
$.fn.typeahead = function(method) {
// methods that should only act on intialized typeaheads
// methods that should only act on initialized typeaheads
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
}

View File

@@ -192,13 +192,13 @@ var Typeahead = (function() {
_onLeftKeyed: function onLeftKeyed() {
if (this.dir === 'rtl' && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},
_onRightKeyed: function onRightKeyed() {
if (this.dir === 'ltr' && this.input.isCursorAtEnd()) {
this.autocomplete(this.menu.getTopSelectable());
this.autocomplete(this.menu.getActiveSelectable() || this.menu.getTopSelectable());
}
},

View File

@@ -289,6 +289,57 @@ describe('Bloodhound', function() {
function fakeGet(o, cb) { cb(fixtures.data.animals); }
});
it('should not add remote data to index if indexRemote is false', function() {
this.bloodhound = build({
identify: function(d) { return d.value; },
remote: '/remote'
});
this.bloodhound.remote.get.andCallFake(fakeGet);
spyOn(this.bloodhound, 'add');
this.bloodhound.search('dog');
expect(this.bloodhound.add).not.toHaveBeenCalled();
function fakeGet(o, cb) { cb(fixtures.data.animals); }
});
it('should add remote data to index if indexRemote is true', function() {
this.bloodhound = build({
identify: function(d) { return d.value; },
indexRemote: true,
remote: '/remote'
});
this.bloodhound.remote.get.andCallFake(fakeGet);
spyOn(this.bloodhound, 'add');
this.bloodhound.search('dog');
expect(this.bloodhound.add).toHaveBeenCalledWith(fixtures.data.animals);
function fakeGet(o, cb) { cb(fixtures.data.animals); }
});
it('should not add duplicates from remote to index', function() {
this.bloodhound = build({
identify: function(d) { return d.value; },
indexRemote: true,
local: fixtures.data.animals,
remote: '/remote'
});
this.bloodhound.remote.get.andCallFake(fakeGet);
spyOn(this.bloodhound, 'add');
this.bloodhound.search('dog');
expect(this.bloodhound.add).toHaveBeenCalledWith([
{ value: 'cat' },
{ value: 'moose' }
]);
function fakeGet(o, cb) { cb(fixtures.data.animals); }
});
});
// helper functions

View File

@@ -54,11 +54,18 @@ describe('SearchIndex', function() {
expect(this.index.search('wtf')).toEqual([]);
});
it('#serach should handle multi-token queries', function() {
it('#search should handle multi-token queries', function() {
this.index.add({ value: 'foo bar' });
expect(this.index.search('foo b')).toEqual([{ value: 'foo bar' }]);
});
it('#search should return results that match ANY query-token when options.matchAnyQueryToken', function() {
this.index = build({matchAnyQueryToken:true});
this.index.add({ value: 'foo bar' });
expect(this.index.search('blah bar')).toEqual([{ value: 'foo bar' }]);
expect(this.index.search('food bark')).toEqual([]);
});
it('#all should return all datums', function() {
expect(this.index.all()).toEqual(fixtures.data.simple);
});

View File

@@ -3,7 +3,7 @@
if [ "$TEST_SUITE" == "unit" ]; then
./node_modules/karma/bin/karma start --single-run --browsers PhantomJS
elif [ "$TRAVIS_SECURE_ENV_VARS" == "true" -a "$TEST_SUITE" == "integration" ]; then
static -p 8888 &
./node_modules/.bin/static -p 8888 &
sleep 3
# integration tests are flaky, don't let them fail the build
./node_modules/mocha/bin/mocha --harmony -R spec ./test/integration/test.js || true

View File

@@ -366,6 +366,18 @@ describe('Dataset', function() {
});
});
it('should render all async suggestions if sync had no content', function() {
this.source.andCallFake(fakeGetWithEmptySyncAndAsyncSuggestions);
this.dataset.update('woah');
waits(100);
runs(function() {
var rendered = this.dataset.$el.find('.tt-suggestion');
expect(rendered).toHaveLength(5);
});
});
it('should trigger rendered after suggestions are rendered', function() {
var spy;
@@ -466,4 +478,19 @@ describe('Dataset', function() {
]);
}, 0);
}
function fakeGetWithEmptySyncAndAsyncSuggestions(query, sync, async) {
sync([]);
setTimeout(function() {
async([
{ value: 'four', raw: { value: 'four' } },
{ value: 'five', raw: { value: 'five' } },
{ value: 'six', raw: { value: 'six' } },
{ value: 'seven', raw: { value: 'seven' } },
{ value: 'eight', raw: { value: 'eight' } },
]);
}, 0);
}
});

View File

@@ -125,6 +125,13 @@ describe('Menu', function() {
});
describe('#open', function() {
it('should set scroll top of node to 0', function() {
spyOn(this.view.$node, 'scrollTop');
this.view.open();
expect(this.view.$node.scrollTop).toHaveBeenCalledWith(0);
});
it('should add open class to node', function() {
this.$node.removeClass(www.classes.open);
this.view.open();

View File

@@ -157,6 +157,14 @@ describe('$plugin', function() {
expect(this.$input.typeahead('val')).toBe('foo');
});
it('#val(q) should coerce null and undefined to empty string', function() {
this.$input.typeahead('val', null);
expect(this.$input.typeahead('val')).toBe('');
this.$input.typeahead('val', undefined);
expect(this.$input.typeahead('val')).toBe('');
});
it('#destroy should revert modified attributes', function() {
expect(this.$input).toHaveAttr('autocomplete', 'off');
expect(this.$input).toHaveAttr('dir');

View File

@@ -1,40 +0,0 @@
{
"licenses": [
{
"url": "https://github.com/twitter/typeahead.js/blob/master/LICENSE"
}
],
"dependencies": {
"jquery": ">=1.7"
},
"docs": "https://github.com/twitter/typeahead.js",
"demo": "http://twitter.github.com/typeahead.js/examples",
"name": "typeahead.js",
"title": "typeahead.js",
"author": {
"name": "Twitter, Inc.",
"url": "https://twitter.com/twitteross"
},
"description": "fast and fully-featured autocomplete library",
"keywords": [
"typeahead",
"autocomplete"
],
"homepage": "http://twitter.github.com/typeahead.js",
"bugs": "https://github.com/twitter/typeahead.js/issues",
"maintainers": [
{
"name": "Jake Harding",
"url": "https://twitter.com/JakeHarding"
},
{
"name": "Tim Trueman",
"url": "https://twitter.com/timtrueman"
},
{
"name": "Veljko Skarich",
"url": "https://twitter.com/vskarich"
}
],
"version": "0.11.1"
}