///
///
//
// Examples from http://twitter.github.com/typeahead.js/examples
//
declare var Hogan: string;
// Countries
// Prefetches data, stores it in localStorage, and searches it on the client
$('.example-countries .typeahead').typeahead({
name: 'countries',
prefetch: '../data/countries.json',
limit: 10
});
// Open Source Projects by Twitter
// Defines a custom template and template engine for rendering suggestions
$('.example-twitter-oss .typeahead').typeahead({
name: 'twitter-oss',
prefetch: '../data/repos.json',
template: [
'
{{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: 'NBA Teams
'
},
{
name: 'nhl-teams',
prefetch: '../data/nhl.json',
header: 'NHL Teams
'
}
]);
// Best Picture Winners
// Prefetches some data then relies on remote requests for suggestions when prefetched data is insufficient
$('.example-films .typeahead').typeahead([
{
name: 'best-picture-winners',
remote: '../data/films/queries/%QUERY.json',
prefetch: '../data/films/post_1960.json',
template: '{{value}} – {{year}}
',
engine: Hogan
}
]);