-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
178 lines (165 loc) · 4.35 KB
/
index.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>a-box</title>
<link rel="stylesheet" href="./lib/common.css">
<style>
* {
box-sizing: border-box;
}
body {
font-size: 16px;
padding: 10px;
margin: 0;
width: 100%;
}
.item {
margin-bottom: 20px;
}
button {
font-size: 16px;
margin: 5px;
border-radius: 2px;
border: 1px solid #000;
background: #fff;
padding: 6px 12px;
cursor: pointer;
outline: none;
}
button:active {
background: #f7f7f7;
}
@media (max-width: 750px) {
button {
margin: 10px 0;
width: 100%;
padding: 8px 12px;
}
}
.demo-1 {
position: relative;
border: 1px solid #333;
padding: 10px;
max-width: 750px;
height: 150px;
margin-top: 10px;
}
</style>
</head>
<body>
<h3 class="title">提示操作框</h3>
<div class="item">
<button id="openAlert">打开alert</button>
<button id="openConfirm">打开confirm</button>
<button id="openPrompt">打开prompt</button>
</div>
<h3 class="title">Message</h3>
<div class="item">
<button class="openMessage" data-type="info">打开message | info</button>
<button class="openMessage" data-type="success">打开message | success</button>
<button class="openMessage" data-type="error">打开message | error</button>
<button class="openMessage" data-type="warning">打开message | warning</button>
<button class="openMessage" data-type="none">打开message | 无图标</button>
</div>
<h3 class="title">Loading</h3>
<div class="item">
<button class="openLoading" data-type="loading">打开loading</button>
<button class="openLoading-local" data-type="loading">局部loading</button>
<div class="demo-1" id="Demo1">局部内容</div>
</div>
<h3 class="title">Notice通知</h3>
<div class="item">
<button class="openNotice" data-type="info">打开notice | info</button>
<button class="openNotice" data-type="success">打开notice | success</button>
<button class="openNotice" data-type="error">打开notice | error</button>
<button class="openNotice" data-type="warning">打开notice | warning</button>
</div>
</body>
<script src="./lib/a-box.js"></script>
<script>
const box = new ABox()
document.querySelector('#openAlert').addEventListener('click', function () {
const a = box.alert({
title: '提示',
content: '这是一个 alert 弹出层',
confirm: () => {
console.log('确定')
}
})
})
document.querySelector('#openConfirm').addEventListener('click', function () {
const a = box.confirm({
title: '提示',
content: '这是一个 confirm 弹出层',
confirm: () => {
console.log('确定')
},
cancel: () => {
console.log('取消')
}
})
})
document.querySelector('#openPrompt').addEventListener('click', function () {
const a = box.prompt({
title: '提示',
type: '',
confirm: (content) => {
console.log(content)
console.log('确定')
},
cancel: () => {
console.log('取消')
}
})
})
document.querySelectorAll('.openMessage').forEach(item => {
item.addEventListener('click', function () {
console.dir(item)
const type = item.dataset.type
box.message({
content: '一个消息',
type,
close: () => {
console.log('close')
}
})
})
})
document.querySelector('.openLoading').addEventListener('click', function () {
const loading = box.loading({content: '这是一个loading', mask: false})
setTimeout(() => {
loading.setContent('变换内容 2s 后关闭')
setTimeout(() => {
loading.hide()
}, 2000)
}, 2000)
})
document.querySelector('.openLoading-local').addEventListener('click', function () {
const loading = box.loading({selector: '#Demo1', content: '这是一个局部loading', mask: false})
setTimeout(() => {
loading.hide()
}, 2000)
})
document.querySelectorAll('.openNotice').forEach(item => {
item.addEventListener('click', function () {
console.dir(item)
const type = item.dataset.type
const a = box.notice({
title: '这是一个标题',
content: '这是内容,这是内容,这是内容这是内容这是内容',
type,
close: () => {
console.log('close')
}
})
// setTimeout(() => {
// a.hide()
// }, 3000)
})
})
</script>
</html>