This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Search.html
78 lines (59 loc) · 1.83 KB
/
Search.html
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
<style disabled>
.Box {
position: relative;
}
.Box > ul {
position: absolute;
left: 0;
top: 100%;
right: 0;
z-index: 1;
margin: 0;
padding: 0;
list-style: none;
border: 1px solid rgb(204, 204, 204);
background: white;
display: none;
}
.Box > ul > li {
padding: 6px 12px;
cursor: pointer;
}
.Box > ul > li:hover {
background: rgb(230, 230, 230);
}
</style>
<script>
require(['jquery', 'EasyWebApp'], function ($, EWA) {
var iWebApp = new EWA();
EWA.component(function (data) {
data.getURL = function () {
var data = this.valueOf();
return data.api + data[ data.key ];
};
var $_Tips = this.$_View.find('.Box > ul'), VM = this;
data.search = function (event) {
var input = event.target;
this.render(input.name, input.value);
iWebApp.load( $_Tips.show() );
event.stopPropagation();
};
data.select = function (event) {
$_Tips.hide().prevAll('[type="search"]')[0].value =
event.target.textContent.trim().split("\n")[0].trim();
VM.emit('check', this.valueOf());
};
});
});
</script>
<div class="Box">
<input type="search" class="form-control"
name="${view.key}" value="${scope[ view.key ]}"
autocomplete="off" placeholder="${view.placeHolder}"
onchange="${view.search}" />
<ul data-href="?data=${view.getURL()}">
<li onclick="${scope.select}">
<slot name="item"></slot>
</li>
</ul>
</div>