Merge pull request #1905 from maanasa/master

Update typeahead.d.ts
This commit is contained in:
Bart van der Schoor
2014-03-26 14:09:03 +01:00
2 changed files with 46 additions and 0 deletions
+14
View File
@@ -71,3 +71,17 @@ $('.example-films .typeahead').typeahead([
engine: Hogan
}
]);
// Countries - Modified the first test here to add options
// Specifies options to display hint with a highlight and adds a minimum length restriction for search
// Prefetches data, stores it in localStorage, and searches it on the client
$('.example-countries .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 2
},
{
name: 'countries',
prefetch: '../data/countries.json',
limit: 10
});
+32
View File
@@ -50,6 +50,16 @@ interface JQuery {
* @param query The query to be set in case method 'setQuery' is used.
*/
typeahead(methodName: string, query: string): JQuery;
/**
* Accomodates specifying options such as hint and highlight.
* This is in correspondence to the examples mentioned in http://twitter.github.io/typeahead.js/examples/
*
* @constructor
* @param options ('hint' or 'highlight' or 'minLength' all of which are optional)
* @param dataset Array of datasets
*/
typeahead(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset): JQuery;
}
declare module Twitter.Typeahead {
@@ -243,4 +253,26 @@ declare module Twitter.Typeahead {
*/
tokens: string[];
}
/**
* When initializing a typeahead, there are a number of options you can configure.
*/
interface Options {
/**
* highlight: If true, when suggestions are rendered,
* pattern matches for the current query in text nodes will be wrapped in a strong element.
* Defaults to false.
*/
highlight?: boolean;
/**
* If false, the typeahead will not show a hint. Defaults to true.
*/
hint?: boolean;
/**
* The minimum character length needed before suggestions start getting rendered. Defaults to 1.
*/
minLength?: number;
}
}