Browse Source

Upgrade typeahead to 0.10.2

master
Sébastien Lucas 10 years ago
parent
commit
a2a6652487
5 changed files with 38 additions and 1159 deletions
  1. +7
    -0
      resources/typeahead/typeahead.bundle.min.js
  2. +0
    -1140
      resources/typeahead/typeahead.js
  3. +1
    -1
      templates/default/file.html
  4. +2
    -1
      templates/default/styles/style-base.css
  5. +28
    -17
      util.js

+ 7
- 0
resources/typeahead/typeahead.bundle.min.js
File diff suppressed because it is too large
View File


+ 0
- 1140
resources/typeahead/typeahead.js
File diff suppressed because it is too large
View File


+ 1
- 1
templates/default/file.html View File

@@ -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}}" />


+ 2
- 1
templates/default/styles/style-base.css View File

@@ -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;
}


+ 28
- 17
util.js View File

@@ -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) {


Loading…
Cancel
Save