Initial version

Work is still in progress!
This commit is contained in:
Ivaylo Gochkov
2013-12-18 00:03:12 +01:00
parent 718eff7763
commit 46a54d3216
3 changed files with 203 additions and 1 deletions
+72
View File
@@ -0,0 +1,72 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="typeahead.d.ts"/>
//
// Examples from http://twitter.github.com/typeahead.js/examples
//
// 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: [
// '<p class="repo-language">{{language}}</p>',
// '<p class="repo-name">{{name}}</p>',
// '<p class="repo-description">{{description}}</p>'
// ].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: '<h3 class="league-name">NBA Teams</h3>'
},
{
name: 'nhl-teams',
prefetch: '../data/nhl.json',
header: '<h3 class="league-name">NHL Teams</h3>'
}
]);
// 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: '<p><strong>{{value}}</strong> {{year}}</p>',
// engine: Hogan
// }
//]);