forked from liulangnan/aui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchbar_frm.html
More file actions
78 lines (78 loc) · 2.94 KB
/
Copy pathsearchbar_frm.html
File metadata and controls
78 lines (78 loc) · 2.94 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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>AUI快速完成布局</title>
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<style type="text/css">
.aui-content-padded {
padding: 0.75rem;
background-color: #ffffff;
margin-top: 0.75rem;
}
</style>
</head>
<body>
<div class="aui-searchbar" id="search">
<div class="aui-searchbar-input aui-border-radius">
<i class="aui-iconfont aui-icon-search"></i>
<input type="search" placeholder="请输入搜索内容" id="search-input">
<div class="aui-searchbar-clear-btn">
<i class="aui-iconfont aui-icon-close"></i>
</div>
</div>
<div class="aui-searchbar-btn" tapmode>取消</div>
</div>
<section class="aui-content-padded">
更新说明:取消了搜索条的绝对定位。增加清除按钮
</section>
<section class="aui-content-padded">
要搜索的内容为:<span class="aui-text-info" id="search-keywords"></span>
</section>
</body>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
apiready = function(){
api.parseTapmode();
}
var searchBar = document.querySelector(".aui-searchbar");
var searchBarInput = document.querySelector(".aui-searchbar input");
var searchBarBtn = document.querySelector(".aui-searchbar .aui-searchbar-btn");
var searchBarClearBtn = document.querySelector(".aui-searchbar .aui-searchbar-clear-btn");
if(searchBar){
searchBarInput.onclick = function(){
searchBarBtn.style.marginRight = 0;
}
searchBarInput.oninput = function(){
if(this.value.length){
searchBarClearBtn.style.display = 'block';
searchBarBtn.classList.add("aui-text-info");
searchBarBtn.textContent = "搜索";
}else{
searchBarClearBtn.style.display = 'none';
searchBarBtn.classList.remove("aui-text-info");
searchBarBtn.textContent = "取消";
}
}
}
searchBarClearBtn.onclick = function(){
this.style.display = 'none';
searchBarInput.value = '';
searchBarBtn.classList.remove("aui-text-info");
searchBarBtn.textContent = "取消";
}
searchBarBtn.onclick = function(){
var keywords = searchBarInput.value;
if(keywords.length){
searchBarInput.blur();
document.getElementById("search-keywords").textContent = keywords;
}else{
this.style.marginRight = "-"+this.offsetWidth+"px";
searchBarInput.value = '';
searchBarInput.blur();
}
}
</script>
</html>