-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
207 lines (186 loc) · 6.63 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Toaster-JS Demo</title>
<meta name="author" content="zitros.tk"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<meta name="keywords" content="toasts, toast, js, notification, message, javascript, css, toaster, toaster-js, pop-up, hint, alert, minimalistic, vanilla, es6"/>
<script src="umd.js"></script>
<link rel="stylesheet" href="default.css"/>
<style>
html, body {
background: #f5f8fa;
margin: 0;
padding: 0;
}
.central {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: table;
pointer-events: none;
}
.central > div {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.central > div > div {
display: inline-block;
pointer-events: all;
}
label {
display: block;
margin: 10px 0;
}
input, select, textarea, button {
padding: 4px;
border-radius: 4px;
border: 1px solid gray;
}
button {
background: white;
box-shadow: inset -1px -2px 2px rgba(0, 0, 0, .2);
cursor: pointer;
}
h1 {
margin: 0;
}
.sub {
font-size: 75%;
color: gray;
margin-bottom: 5px;
}
#messageInput {
width: 100%;
box-sizing: border-box;
}
.footer {
position: absolute;
bottom: 0;
color: black;
width: 100%;
text-align: center;
font-size: 10pt;
opacity: .5;
}
.little-cross {
position: absolute;
right: 0;
top: -5px;
display: inline-block;
float: right;
font-family: monospace;
font-size: 15px;
cursor: pointer;
color: gray;
text-shadow: none;
}
.table {
display: table;
width: 100%;
}
.row {
display: table-row;
}
.column {
display: table-cell;
text-align: left;
border-bottom: 14px solid transparent;
}
.column input:not([type=checkbox]), .column select {
width: 100px;
box-sizing: border-box;
}
.little-cross:after {
content: "x";
}
</style>
<script type="text/javascript">
function init () {
document.getElementById("showButton").addEventListener("click", function () {
let element = document.createElement("div"),
text = document.createElement("span"),
littleCross = document.createElement("span");
text.textContent = document.getElementById("messageInput").value;
littleCross.className = "little-cross";
if (document.getElementById("canBeClosedInput") && document.getElementById("canBeClosedInput").checked) {
element.appendChild(littleCross);
}
element.appendChild(text);
let toast = new Toast(
element,
document.getElementById("typeSelect").value,
document.getElementById("timeoutInput").value
);
littleCross.addEventListener("click", function () { toast.delete() });
});
document.getElementById("deleteAllButton").addEventListener("click", function () {
deleteAllToasts();
});
}
</script>
</head>
<body onload="init()">
<div class="central">
<div>
<div>
<h1>Toaster-JS Demo</h1>
<div class="sub">Simple and fully-CSS-customizable toast notifications</div>
<div class="sub">Find more on <a href="https://www.npmjs.com/package/toaster-js" target="_blank">npm</a> | See the <a href="https://github.com/ZitRos/toaster-js/blob/master/index.html" target="_blank">source</a> of this page</div>
<a href="https://github.com/ZitRos/toaster-js" target="_blank">
<img src="https://img.shields.io/github/stars/zitros/toaster-js.svg?style=social&label=Star" alt="npm"/>
</a>
<label>
<textarea id="messageInput">This is my awesome message!</textarea>
</label>
<div class="table">
<div class="row">
<div class="column">Message type</div>
<div class="column">
<select id="typeSelect">
<option value="info">Info</option>
<option value="message">Message</option>
<option value="warning">Warning</option>
<option value="error">Error</option>
<option value="done">Done</option>
</select>
</div>
</div>
<div class="row">
<div class="column">Timeout</div>
<div class="column">
<input id="timeoutInput" type="number" value="8000"/>
</div>
</div>
<div class="row">
<div class="column">Can be closed?</div>
<div class="column">
<input id="canBeClosedInput" type="checkbox"/>
</div>
</div>
</div>
<button id="showButton">Show Toast!</button>
<button id="deleteAllButton">Delete All</button>
</div>
</div>
</div>
<div class="footer">
<div style="display: inline-block; max-width: 700px;">
<div>
toasts, toast, js, notification, message, javascript, css, toaster, toaster-js,
pop-up, hint, alert, minimalistic, vanilla, es6
</div>
<div>
by <a target="_blank" href="https://nikita.tk">Nikita Savchenko</a>
</div>
<div>
<a target="_blank" href="https://github.com/ZitRos/toaster-js/blob/master/LICENSE">License: MIT</a>
</div>
</div>
</div>
</body>
</html>