diff --git a/README.md b/README.md
index 7e305efe3..6f72a9e36 100755
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-DefinitelyTyped [](https://travis-ci.org/borisyankov/DefinitelyTyped)
+DefinitelyTyped [](https://travis-ci.org/borisyankov/DefinitelyTyped)
===============
The repository for *high quality* TypeScript type definitions.
@@ -231,6 +231,7 @@ List of Definitions
* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
* [tween.js](https://github.com/sole/tween.js/) (by [Adam R. Smith](https://github.com/sunetos))
* [twitter-bootstrap-wizard](https://github.com/VinceG/twitter-bootstrap-wizard) (by [Blake Niemyjski](https://github.com/niemyjski))
+* [Typeahead.js](http://twitter.github.io/typeahead.js) (by [Ivaylo Gochkov](https://github.com/igochkov))
* [Ubuntu Unity Web API](https://launchpad.net/libunity-webapps) (by [John Vrbanac](https://github.com/jmvrbanac))
* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/))
diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts
new file mode 100644
index 000000000..ee41ea3f5
--- /dev/null
+++ b/typeahead/typeahead-tests.ts
@@ -0,0 +1,72 @@
+///
{{language}}
', +// '{{name}}
', +// '{{description}}
' +// ].join(''), +// engine: Hogan +//}); + +// Arabic Phrases +// Hardcoded list showing Right - To - Left(RTL) support +$('.example-arabic .typeahead').typeahead({ + name: 'arabic', + local: [ + "الإنجليزية", + "نعم", + "لا", + "مرحبا", + "کيف الحال؟", + "أهلا", + "مع السلامة", + "لا أتكلم العربية", + "لا أفهم", + "أنا جائع" + ] +}); + +// NBA and NHL Teams +// Two datasets that are prefetched, stored, and searched on the client +$('.example-sports .typeahead').typeahead([ + { + name: 'nba-teams', + prefetch: '../data/nba.json', + header: '{{value}} – {{year}}
', +// engine: Hogan +// } +//]); \ No newline at end of file diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts new file mode 100644 index 000000000..f4baec0e6 --- /dev/null +++ b/typeahead/typeahead.d.ts @@ -0,0 +1,129 @@ +// Type definitions for Twitter's typeahead.js 0.9.3 +// Project: http://twitter.github.io/typeahead.js/ +// Definitions by: Ivaylo Gochkovelement (i.e.
value
). + */ + template?: any; + /** + * The template engine used to compile/render template if it is a + * string. Any engine can use used as long as it adheres to the + * expected API. Required if template is a string. + */ + engine?: string; + /** + * The header rendered before suggestions in the dropdown menu. + * Can be either a DOM element or HTML. + */ + header?: any; + /** + * The footer rendered after suggestions in the dropdown menu. + * Can be either a DOM element or HTML. + */ + footer?: any; + /** + * An array of {Twitter.Typeahead.Datum}. + */ + local?: any[]; + /** + * Can be a URL to a JSON file containing an array of datums or, + * if more configurability is needed, a prefetch options object + * {Twitter.Typeahead.PrefetchOptions}. + */ + prefetch?: any; + /** + * Can be a URL to fetch suggestions from when the data provided by + * local and prefetch is insufficient or, if more configurability is + * needed, a remote options object {Twitter.Typeahead.RemoteOptions}. + */ + remote?: any; + } + + interface PrefetchOptions { + url: string; + ttl?: number; + filter?: (parsedResponse: any) => Datum[]; + } + + interface RemoteOptions { + url: string; + dataType?: string; + cache?: boolean; + timeout?: number; + wildcard?: string; + replace?: (url: string, uriEncodedQuery: string) => string; + rateLimitFn?: any; // debounce or trottle + rateLimitWait?: number; + maxParallelRequests?: number; + beforeSend?: (jqXhr: JQueryXHR, settings: JQueryAjaxSettings) => void; + filter?: (parsedResponse: any) => Datum[]; + } + + interface Datum { + value: string; + tokens: string[]; + } + + interface TypeaheadStatic { + VERSION: string; + utils: TypeaheadUtils; + } + + interface TypeaheadUtils { + debounce: (func: any, wait: number, immediate: boolean) => any; + throttle: (func: any, wait: number) => any; + } +} + +interface JQuery { + /** + * Turns an input[type="text"] element into a typeahead. + * + * @constructor + * @param dataset Single dataset + */ + typeahead(dataset: Twitter.Typeahead.Dataset): JQuery; + + /** + * Turns an input[type="text"] element into a typeahead. + * + * @constructor + * @param dataset Array of datasets + */ + typeahead(datasets: Twitter.Typeahead.Dataset[]): JQuery; + + typeahead(methodName: string): JQuery; + typeahead(methodName: 'destroy'): JQuery; + typeahead(methodName: 'setQuery'): JQuery; +} + +declare var typeahead: Twitter.Typeahead.TypeaheadStatic; \ No newline at end of file