added typeahead library to re-implement search suggestions for bootstrap

framework.
pull/1/head
Michael Peter Christen 11 years ago
parent b9056ef2db
commit d873304381

@ -90,4 +90,34 @@ label {
ul.nav li.dropdown:hover ul.dropdown-menu{
display: block;
margin-top:0px
}
}
/*
* typeahead
* sets the following classes:
* twitter-typeahead, tt-dropdown-menu, tt-dataset-%CLASS%, tt-suggestions, tt-suggestion
* tt-hint, tt-input, tt-cursor
*/
.tt-dropdown-menu {
width: 396px;
margin-top: 4px;
padding: 4px 0;
background-color: #f8f8f8;
border: 1px solid #ccc;
}
.tt-suggestion {
padding: 3px 10px;
font-size: 16px;
}
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #428bca;
}
.tt-suggestion p {
margin: 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -5,19 +5,16 @@
<title>YaCy '#[clientname]#': Search Page</title>
#%env/templates/metas.template%#
<link rel="alternate" type="application/rss+xml" title="Search for #[former]#" href="yacysearch.rss?query=#[former]#" />
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="opensearchdescription.xml" />
<script type="text/javascript" src="yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="yacy/ui/js/jquery.autocomplete.yacy.js"></script>
<link media="screen" type="text/css" href="yacy/ui/css/autocomplete.css" rel="stylesheet" />
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="opensearchdescription.xml" />
<script type="text/javascript" src="/env/bootstrap/js/typeahead.jquery.min.js"></script>
<script type="text/javascript" src="js/html.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#search').autocomplete('suggest.json', {parse: opensearch, delay: 0, selectFirst: false, scroll: false, max: 30});
function opensearch(data) {
var parsed = [];
data = eval('({"suggest":' + data + '})');
for (var i = 0; i < data.suggest[1].length; i++) {
var row = data.suggest[1][i];
var suggestMatcher = function() {
return function opensearch(q, cb) {
$.getJSON("suggest.json?q=" + q, function(data) {
var parsed = [];
for (var i = 0; i < data[1].length; i++) {
var row = data[1][i];
if (row) {
parsed[parsed.length] = {
data: [row],
@ -26,10 +23,19 @@
};
};
};
return parsed;
cb(parsed);
});
};
};
$(document).ready(function() {
$('#search').typeahead({hint:false,highlight:true,minLength:1}, {
name: 'states',
displayKey: 'value',
source: suggestMatcher()
});
});
</script>
<style type="text/css">.twitter-typeahead {margin: 0px;padding: 0px;top:-8px;}</style> <!-- fix for input window -->
</head>
<body id="index" onload="#(focus)#::document.getElementById('search').focus()#(/focus)#">
#(topmenu)#

@ -62,7 +62,7 @@ public class suggest {
// get query
final String originalquerystring = (post == null) ? "" : post.get("query", post.get("q", ""));
final String querystring = originalquerystring.replace('+', ' ');
final String querystring = originalquerystring.replace('+', ' ').replaceAll("%20", " ");
final int timeout = (post == null) ? 300 : post.getInt("timeout", 300);
final int count = (post == null) ? 10 : Math.min(20, post.getInt("count", 10));

@ -4,10 +4,7 @@
<title>#[former]# - YaCy '#[clientname]#': Search Page</title>
#%env/templates/metas.template%#
<link rel="alternate" type="application/rss+xml" title="Search for #[former]#" href="yacysearch.rss?query=#[former]#" />
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="http://#[thisaddress]#/opensearchdescription.xml" />
<script type="text/javascript" src="yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="yacy/ui/js/jquery.autocomplete.yacy.js"></script>
<link media="screen" type="text/css" href="yacy/ui/css/autocomplete.css" rel="stylesheet" />
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="http://#[thisaddress]#/opensearchdescription.xml" />
<link rel="stylesheet" type="text/css" media="screen" href="env/highslide.css" />
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/xml.js"></script>
@ -16,7 +13,6 @@
<script type="text/javascript">hs.outlineType = 'rounded-white';</script>
<script type="text/javascript">
//<![CDATA[
function handleArrowKeys(evt) {
evt = (evt) ? evt : ((window.event) ? event : null);
if (evt) {
@ -33,19 +29,15 @@
}
}
document.onkeydown = handleArrowKeys;
//]]>
</script>
</head>
<body id="yacysearch">
<script type="text/javascript" src="yacy/ui/js/jquery.autocomplete.yacy.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#search').autocomplete('suggest.json', {parse: opensearch, delay: 0, selectFirst: false, scroll: false, max: 30});
function opensearch(data) {
var parsed = [];
data = eval('({"suggest":' + data + '})');
for (var i = 0; i < data.suggest[1].length; i++) {
var row = data.suggest[1][i];
<script type="text/javascript" src="/env/bootstrap/js/typeahead.jquery.min.js"></script>
<script type="text/javascript">
var suggestMatcher = function() {
return function opensearch(q, cb) {
$.getJSON("suggest.json?q=" + q, function(data) {
var parsed = [];
for (var i = 0; i < data[1].length; i++) {
var row = data[1][i];
if (row) {
parsed[parsed.length] = {
data: [row],
@ -54,10 +46,22 @@
};
};
};
return parsed;
cb(parsed);
});
};
};
$(document).ready(function() {
$('#search').typeahead({hint:false,highlight:true,minLength:1}, {
name: 'states',
displayKey: 'value',
source: suggestMatcher()
});
</script>
});
</script>
<style type="text/css">.twitter-typeahead {margin: 0px;padding: 0px;top:2px;}</style> <!-- fix for input window -->
</head>
<body id="yacysearch">
#(topmenu)#
#%env/templates/embeddedheader.template%#
::

Loading…
Cancel
Save