addsearch-search-ui
Version:
JavaScript library to develop Search UIs for the web
82 lines (73 loc) • 2.13 kB
HTML
<html lang="en">
<head>
<title>AddSearch Search UI: Basic example</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/addsearch-js-client@0.3/dist/addsearch-js-client.min.js"></script>
<script src="../../dist/addsearch-search-ui.min.js"></script>
<link rel="stylesheet" href="../../dist/addsearch-search-ui.min.css" />
<style type="text/css">
body {
font-family: 'Lato', sans-serif;
min-width: 320px;
}
</style>
</head>
<body>
<!-- Containers. Search UI components will be added inside these divs -->
<div id="searchfields"></div>
<section>
<form>
<input class="addsearch"/>
<div id="autocomplete-container" class="addsRp-autocomplete-container-class"></div>
<input class="addsearch-button" type="button" value="search.." />
</form>
</section>
<div id="results"></div>
<div id="pagination"></div>
<style>
.addsearch {
display: flex;
height: 44px;
background: #fff;
border: 1px solid #dfe1e5;
border-radius: 24px;
width: 500px ;
padding-left: 25px;
font-size: 18px;
}
</style>
<script>
// AddSearch JS client with an example index. Get your own SITEKEY by signing up at www.addsearch.com
var client = new AddSearchClient('2c32bf3eb06b30af5f8208481aea3e8b');
// Search UI instance
var searchui = new AddSearchUI(client, {matchAllQuery: true});
// Add components
searchui.searchField({
selectorToBind: '.addsearch',
buttonSelector:'.addsearch-button',
autofocus: true,
searchAsYouType: false
});
searchui.autocomplete({
containerId: 'autocomplete-container',
hideAutomatically: false,
sources: [
{
type: AddSearchUI.AUTOCOMPLETE_TYPE.SUGGESTIONS
}
]
});
searchui.searchResults({
containerId: 'results'
});
searchui.pagination({
containerId: 'pagination'
});
// All components added. Start
searchui.start();
</script>
</body>
</html>