Upgrade typeahead to 0.10.2

This commit is contained in:
Sébastien Lucas 2014-04-06 21:20:49 +02:00
vecāks d2e39e5eed
revīzija a2a6652487
5 mainīti faili ar 38 papildinājumiem un 1159 dzēšanām

Faila izmaiņas netiek rādītas, jo viena vai vairākas līnijas ir pārāk garas

Failā izmaiņas netiks attēlotas, jo tās ir par lielu Ielādēt izmaiņas

Parādīt failu

@ -22,7 +22,7 @@
<link rel="stylesheet" type="text/css" href="resources/Magnific-Popup/magnific-popup.css?v={{=it.version}}" media="screen" />
<script type="text/javascript" src="resources/doT/doT.min.js?v={{=it.version}}"></script>
<script type="text/javascript" src="resources/lru/lru.js?v={{=it.version}}"></script>
<script type="text/javascript" src="resources/typeahead/typeahead.js?v={{=it.version}}"></script>
<script type="text/javascript" src="resources/typeahead/typeahead.bundle.min.js?v={{=it.version}}"></script>
{{?}}
<script type="text/javascript" src="util.js"></script>
<link rel="related" href="{{=it.opds_url}}" type="application/atom+xml;profile=opds-catalog" title="{{=it.title}}" />

Parādīt failu

@ -337,6 +337,7 @@ width:100%;
{
vertical-align: middle;
width: 100%;
color: black;
}
.tt-hint, .tt-query {
@ -386,7 +387,7 @@ width: 100%;
line-height: 14px;
}
.tt-suggestion.tt-is-under-cursor {
.tt-suggestion.tt-cursor {
color: #1c1c1c;
background-color: #778899;
}

45
util.js
Parādīt failu

@ -15,6 +15,23 @@ $.ajaxSetup({
cache: false
});
var copsTypeahead = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 30,
remote: {
url: 'getJSON.php?page=9&search=1&db=%DB&query=%QUERY',
replace: function (url, query) {
if (currentData.multipleDatabase === 1 && currentData.databaseId === "") {
return url.replace('%QUERY', query).replace('&db=%DB', "");
}
return url.replace('%QUERY', query).replace('%DB', currentData.databaseId);
}
}
});
copsTypeahead.initialize();
var DEBUG = false;
var isPushStateEnabled = window.history && window.history.pushState && window.history.replaceState &&
// pushState isn't reliable on iOS until 5.
@ -288,25 +305,19 @@ updatePage = function (data) {
$("#sortForm").hide ();
}
$('input[name=query]').typeahead([
$('input[name=query]').typeahead(
{
hint: true,
minLength : 3
},
{
name: 'search',
allowDuplicates: true,
minLength : 3,
valueKey: 'title',
limit: 24,
template: templateSuggestion,
remote: {
url: 'getJSON.php?page=9&search=1&db=%DB&query=%QUERY',
replace: function (url, query) {
if (currentData.multipleDatabase === 1 && currentData.databaseId === "") {
return url.replace('%QUERY', query).replace('&db=%DB', "");
}
return url.replace('%QUERY', query).replace('%DB', currentData.databaseId);
}
}
}
]);
displayKey: 'title',
templates: {
suggestion: templateSuggestion
},
source: copsTypeahead.ttAdapter()
});
$('input[name=query]').bind('typeahead:selected', function(obj, datum) {
if (isPushStateEnabled) {