-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
103 lines (89 loc) · 3.08 KB
/
example.html
File metadata and controls
103 lines (89 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example Search</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="dst/avSearch.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
html, body {
padding: 0px;
margin: 0px;
font-family: 'Open Sans', sans-serif;
}
.example-topbar {
box-sizing: border-box;
height: 40px;
background-color: #d42f63;
}
.example-topbar .title {
display: inline-block;
padding: 8px 10px;
color: #fff;
font-size: 18px;
}
</style>
<script>
$(document).ready(function() {
let search = new AvSearchBar(
$("#avSearchBar"),
{
instantSearch: {
enabled: true,
searchType: AvSearchBar.TYPE.RESULTS
},
request: {
url: "exampleResponse.json",
method: "GET",
},
resultMapper: function(data) {
return {
'name': data.name,
'email': data.email,
'link': data.link
};
},
searchDataExtractor: function($elem) {
return [
$elem.find(".name").html()
];
}
}
);
fetch("exampleResponse.json")
.then(res => res.json())
.then(json => {
search.addResults(json, true);
});
});
</script>
</head>
<body>
<header>
<div class="example-topbar">
<span class="title">Search Bar Example -></span>
<span id="avSearchBar" class="av-search-bar">
<span class="search-button"></span>
<form class="search-box">
<input class="search-input" value="Search" />
<div class="search-results">
<div class="loading">loading...</div>
<div class="no-results">No Results</div>
<div class="results"></div>
<div class="result-template">
<a class="result" href="$link">
<div class="name">$name</div>
<div class="email">$email</div>
</a>
</div>
</div>
</form>
</span>
</div>
</header>
</body>
</html>