-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
179 lines (157 loc) · 7.72 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
<!DOCTYPE html>
<html style="width: 100%; height: 100%; margin: 0;">
<head>
<script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script type="text/javascript" src="./dist/vendor.bundle.js"></script>
<script type="text/javascript" src="./dist/super-toastr.bundle.js"></script>
<link rel="stylesheet" type="text/css" href="demo.css">
</head>
<body class="container">
<h1>Super toastr Demo</h1>
<section id="demo" class="well">
<div class="row">
<div class="col-12 col-lg-3">
<div class="form-group">
<label for="st-content">Content</label>
<textarea type="text" id="st-content" name="st-content" rows="8" placeholder="Enter a content..." style="width: 100%;"><div style="color: darkblue; font-weight: bold; padding-bottom: 5px;">Toast Title</div><div style="color: darkblue;">One toastr to rule them all</div></textarea>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="form-group">
<input type="checkbox" id="st-close-btn" name="st-close-btn" checked /> Close button
</div>
<div class="form-group">
<input type="text" id="st-time-out" name="st-time-out" checked placeholder="Time out (ms)"/>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="form-group st-types">
<label for="st-type">Toast type</label>
<input type="radio" name="st-type" value="SUC" checked> success <br>
<input type="radio" name="st-type" value="ERR"> error <br>
<input type="radio" name="st-type" value="WAR"> warning <br>
<input type="radio" name="st-type" value="INF"> info <br>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="st-positions form-group">
<label for="st-type">Position</label>
<input type="radio" name="st-position" value="top_right" checked> Top Right <br>
<input type="radio" name="st-position" value="bottom_right"> Bottom Right <br>
<input type="radio" name="st-position" value="bottom_left"> Bottom Left <br>
<input type="radio" name="st-position" value="top_left"> Top Left <br>
<!--
<input type="radio" name="st-position" value="top_full_width "> Top Full Width <br>
<input type="radio" name="st-position" value="bottom_full_width"> Bottom Full Width <br>
-->
<input type="radio" name="st-position" value="top_center"> Top Center <br>
<input type="radio" name="st-position" value="bottom_center"> Bottom Center <br>
</div>
</div>
</div>
<br />
</section>
<br />
<section id="demo" class="col-12 well">
<div class="row">
<!--
<h3>All toast IDs</h3>
<div id="all-taost-ids">
</div>
-->
<div class="col-12 col-lg-3 pb-3">
<button class="btn" onClick="addToast()">
add toast
</button>
</div>
<div class="col-12 col-lg-3 pb-3">
<div class="flex-container">
<input type="text" name='st-to-remove-toast-id' class="input-remove input-field" placeholder="Enter toast id">
<button type="submit" class="btn remove-btn" onClick="removeToastById()">remove</button>
</div>
</div>
<div class="col-12 col-lg-3 pb-3">
<div class="flex-container">
<input type="text" name='st-to-remove-toast-type' class="input-remove input-field" placeholder="Enter toast type">
<button type="submit" class="btn remove-btn" onClick="removeToastByType()">remove</button>
</div>
</div>
<div class="col-12 col-lg-3 pb-3">
<div class="flex-container">
<button type="submit" class="btn remove-all-btn" onClick="removeAllToasts()">Remove All Toasts</button>
</div>
</div>
</div>
<div class="row">
<div class="col p-3" style="border: 1px solid #d1d1d1">
<pre id="st-current-toast-id" style="padding: 5px 10px; font-size: 18px; font-weight: bold;">
</pre>
<pre id="st-json-config" style="padding: 5px 10px;">
</pre>
</div>
</div>
</section>
<div id="toasts-container-1" style="z-index: 999999; pointer-events: none; display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%;">
</div>
</body>
<script>
var instanceA = SuperToastrLib.createToaster('toasts-container-1');
function getBackgroundForType(type) {
if (type === 'WAR') {
return 'yellow';
}
if (type === 'ERR') {
return '#F44336';
}
if (type === 'SUC') {
return '#26a69a';
}
if (type === 'INF') {
return '#dbdbdb';
}
return '';
}
function prettyDate2(date){
var localeSpecificTime = date.toLocaleTimeString();
return localeSpecificTime;
}
function addToast() {
const toastContentElement = document.querySelector('textarea[name="st-content"]');
const toastType = document.querySelector('input[name="st-type"]:checked').value;
const toastPosition = document.querySelector('input[name="st-position"]:checked').value;
const toastCloseBtnElement = document.querySelector('input[name="st-close-btn"]:checked');
const toastTimeout = document.querySelector('input[name="st-time-out"]');
var toastConfig = {
type: toastType,
position: toastPosition,
background: getBackgroundForType(toastType),
content: toastContentElement.value,
closeBtn: toastCloseBtnElement ? true : false,
timeout: toastTimeout.value || null
};
const addedToastID = instanceA.addToast(toastConfig);
document.getElementById('st-current-toast-id').innerHTML = 'Current added toast id: ' + addedToastID;
document.getElementById('st-json-config').innerHTML = 'toastr.config = ' + JSON.stringify(Object.assign(toastConfig, {content: toastContentElement.innerHTML}), undefined, 4);
}
function removeToastById() {
const toRemoveToastId = document.querySelector('input[name="st-to-remove-toast-id"]').value;
if (toRemoveToastId) {
const currentToastId = instanceA.removeToastById(toRemoveToastId);
document.getElementById('st-current-toast-id').innerHTML = '';
document.getElementById('st-json-config').innerHTML = '';
}
}
function removeToastByType() {
const toRemoveToastType = document.querySelector('input[name="st-to-remove-toast-type"]').value;
if (toRemoveToastType) {
const currentToastId = instanceA.removeAllToastTypes([toRemoveToastType]);
document.getElementById('st-current-toast-type').innerHTML = '';
document.getElementById('st-json-config').innerHTML = '';
}
}
function removeAllToasts() {
instanceA.removeAllToasts();
}
</script>
</html>