-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
905 lines (818 loc) · 42 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script src="https://www.sowecms.com/demos/statics/prism.js"></script>
<link rel="stylesheet" type="text/css" href="https://www.sowecms.com/demos/statics/prism.css">
<style>
.bg-primary-2 {
background-color: #3779B3;
}
.bg-secondary-2 {
background: #cbdbe8;
}
.text-underline {
text-decoration: underline;
}
.text-bold {
font-weight: 700;
}
.text-italic {
font-style: italic;
}
.text-small {
font-size: 0.8em;
}
.flex-grow-1 {
flex-grow: 1;
}
.nav-tabs {
border: 0;
}
.nav-tabs li {
margin: 0 0.25em;
}
.nav-tabs li .nav-link {
margin: 0 0.25em;
background: rgba(255, 255, 255, 0.5);
}
.nav-tabs li .nav-link.active {
background: #FFF;
}
#btn-top {
position: fixed;
z-index: 50;
bottom: 1em;
top: auto;
left: auto;
right: 1em;
margin-left: -1.9rem;
opacity: .66;
display: none;
}
.table-striped tbody tr:nth-of-type(odd) td pre {
background: #FFF;
}
.btn-github {
color: #24292e;
background-color: #fafbfc;
border: 1px #c4c8cc solid;
margin: 0 0.25em;
}
.btn-github:hover {
background-color: #e6ebf1;
background-image: linear-gradient(-180deg, #f0f3f6, #e6ebf1 90%);
background-position: -.5em;
border-color: rgba(27, 31, 35, .35);
}
.btn-github svg {
vertical-align: middle;
width: 14px;
height: 14px;
margin-bottom: 2px;
fill: #24292e;
}
/* Example 4*/
.notifyjs-container .notifyjs-notification.alert-dark {
color: #24292e;
background-color: #fafbfc;
border-color: #c4c8cc;
}
.notifyjs-container .notifyjs-notification.alert-dark p.progress {
background: #24292e;
}
.notifyjs-container .notifyjs-notification.alert-dark .notifyjs-icon svg {
fill: #24292e;
}
</style>
</head>
<body>
<header id="header" class="bg-primary-2">
<div class="container py-4">
<div class="row">
<div class="col-xs-12 col-md-8">
<h1 class="text-white m-0">Notifier.js </h1>
<p class="text-white m-0">Vanilla Javascript html notifications manager
</p>
<ul class="list-inline menu-navigation pt-3">
<li class="list-inline-item"><a class="text-white text-underline" href="#docs">Documentation</a>
</li>
<li class="list-inline-item"><a class="text-white text-underline" href="#examples">Examples</a>
</li>
</ul>
</div>
<div class="col-xs-12 col-md-4">
<ul class="list-unstyled text-md-right">
<li>
<a class="text-white text-underline d-flex align-items-center" target="_blank"
rel="noopener" href="https://github.com/jsanahuja/Notifierjs">
<span class="mr-2 flex-grow-1">Visit our repository</span>
<svg class="octicon octicon-mark-github v-align-middle" fill="white" height="32"
viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true">
<path fill-rule="evenodd"
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.26 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z">
</path>
</svg>
</a>
</li>
<li class="pt-2">
<a class="text-white text-underline d-flex align-items-center" target="_blank"
rel="noopener" href="https://www.paypal.me/JavierSL">
<span class="mr-2 flex-grow-1">Support us</span>
<svg class="octicon v-align-middle" fill="white" height="32" width="32"
viewBox="0 0 32 32">
<path
d="M29.41 11.535c.215 1 .192 2.215-.07 3.645-1.035 5.285-4.399 7.925-10.09 7.925h-.785a1.17 1.17 0 0 0-.785.297 1.29 1.29 0 0 0-.43.758l-.07.34-.985 6.18-.035.265a1.27 1.27 0 0 1-.437.762c-.23.195-.496.293-.793.293h-4.485a.715.715 0 0 1-.59-.27.806.806 0 0 1-.16-.64c.11-.668.266-1.668.473-3 .21-1.332.367-2.332.477-3 .105-.668.265-1.664.48-2.992.215-1.328.375-2.325.48-2.993.063-.437.317-.66.77-.66h2.34c1.582.024 2.988-.101 4.215-.375 2.082-.465 3.789-1.32 5.125-2.57 1.215-1.133 2.136-2.594 2.765-4.395.285-.832.496-1.625.625-2.375.012-.07.028-.113.047-.132a.06.06 0 0 1 .063-.016.263.263 0 0 1 .105.063c.942.699 1.524 1.664 1.75 2.89zM26.34 6.5c0 1.273-.274 2.68-.82 4.215-.954 2.773-2.75 4.648-5.395 5.625-1.344.476-2.844.726-4.5.75 0 .012-.535.015-1.605.015l-1.61-.015c-1.191 0-1.89.57-2.105 1.715-.024.093-.532 3.25-1.52 9.465-.012.117-.082.175-.215.175H3.305a.833.833 0 0 1-.653-.293.831.831 0 0 1-.207-.687L6.59 1.195c.058-.343.223-.629.492-.855C7.348.113 7.656 0 8 0h10.68c.402 0 .984.078 1.738.23.758.157 1.422.348 1.992.575 1.274.488 2.246 1.218 2.922 2.195.672.977 1.008 2.145 1.008 3.5zm0 0" />
</svg>
</a>
</li>
</ul>
</div>
</div>
</div>
</header>
<section id="docs">
<div class="bg-secondary-2 py-3">
<div class="container">
<h2>Documentation</h2>
</div>
</div>
<div class="container py-3">
<h3 id="notifier" class="mt-3"><a class="text-underline" href="#notifier">Notifier</a></h3>
<table class="table table-striped">
<thead class="thead-light">
<tr>
<th>Method</th>
<th>Type</th>
<th style="width: 40%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="d-flex flex-wrap">
<code
class="text-bold flex-grow-1"><em>constructor(<a class="text-underline" href="#options">options</a>)</em></code>
</td>
<td></td>
<td>Instances the notifications manager with the given <em>options</em>.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">notify(type, msg, time, callback)</code>
</td>
<td><em><a class="text-underline" href="#notification">Notification</a></em></td>
<td>
Creates a new <em>Notification</em> object of the type <code><em>type</em></code> with the
message <code><em>msg</em></code>. The notification will be shown (on <a
class="text-underline" href="#notification.push">push</a>)
for <code><em>time</em></code> miliseconds or
<code><em>default_time</em></code> if not specified. The <code><em>callback</em></code> will
be called right before the gracefully vanish (on <a class="text-underline"
href="#notification.clear">clear</a>).
</td>
</tr>
</tbody>
</table>
<h4 id="options" class="mt-4"><a class="text-underline" href="#options">Notifier Options</a></h4>
<table class="table table-striped">
<thead class="thead-light">
<tr>
<th>Attribute</th>
<th>Type</th>
<th>Default</th>
<th style="width: 40%">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">autopush</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>Boolean<em></td>
<td><code>true</code></td>
<td>Whether the notifier has to automatically push notifications (on creation) or not.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">position</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>string<em></td>
<td><code>bottom-right</code></td>
<td>Screen position of the notification. Allows <code>top-left</code>, <code>top-right</code>, <code>bottom-left</code> and <code>bottom-right</code></em>.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">direction</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>string</em></td>
<td><code>bottom</code></td>
<td>The direction the notifications will be stacked:
<p class="mb-0"><code>top</code>: The latest notification will show on top.</p>
<p><code>bottom</code>: The latest notification will show at bottom.</p>
</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">zindex</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>int</em></td>
<td><code>9999</code></td>
<td>The CSS z-index the notifications container should have</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">default_time</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>number [Int]</em></td>
<td><code>4500</code></td>
<td>Number of miliseconds the notification will be visible if not specified.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">vanish_time</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>number [Int]</em></td>
<td><code>300</code></td>
<td>Miliseconds the notification vanish animation will take.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1">fps</code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em>number [Int]</em></td>
<td><code>30</code></td>
<td>Frames per second of progress and vanish animations.</td>
</tr>
<tr>
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em><type></em></code>
<span class="text-danger text-small text-italic">Optional</span>
</td>
<td><em><a class="text-underline" href="#notification-type">Notification Type</a></em></td>
<td>
<span class="text-danger text-small text-italic">success</span>,
<span class="text-danger text-small text-italic">error</span>,
<span class="text-danger text-small text-italic">warning</span>,
<span class="text-danger text-small text-italic">info</span>
</td>
<td>
You can define your own notification types or override existing ones. See <a class="text-underline" href="#notification-type">Notification Type</a> or the Example 4.</pre>
</td>
</tr>
</tbody>
</table>
<h3 id="notification" class="mt-4"><a class="text-underline" href="#notification">Notification</a></h3>
<table class="table table-striped">
<thead class="thead-light">
<tr>
<th>Method</th>
<th colspan="2">Type</th>
<th style="width: 40%">Description</th>
</tr>
</thead>
<tbody>
<tr id="notification.push">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>push()</em></code>
</td>
<td colspan="2">void</td>
<td>Displays the notification.</td>
</tr>
<tr id="notification.clear">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>clear()</em></code>
</td>
<td colspan="2">void</td>
<td>Vanishes the notification gracefully.</td>
</tr>
<tr id="notification.destroy">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>destroy()</em></code>
</td>
<td colspan="2">void</td>
<td>Destroys the notification. Note it <strong>will not</strong> trigger the
<code><em>callback</em></code>.</td>
</tr>
</tbody>
</table>
<h3 id="notification-type" class="mt-4"><a class="text-underline" href="#notification-type">Notification Type</a></h3>
<table class="table table-striped">
<thead class="thead-light">
<tr>
<th>Attribute</th>
<th colspan="2">Type</th>
<th style="width: 40%">Description</th>
</tr>
</thead>
<tbody>
<tr id="notification.type.classes">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>classes</em></code>
</td>
<td colspan="2">string</td>
<td>CSS classes that will be added to the notification.</td>
</tr>
<tr id="notification.type.icon">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>icon</em></code>
</td>
<td colspan="2">string</td>
<td>
<p class="mb-0">HTML containing the icon. Something like:</p>
<p class="mb-0"><code><svg ...></svg></code></p>
<p class="mb-0"><code><img ... /></code></p>
<p class="mb-0"><code><i ...></i></code></p>
</td>
</tr>
<tr id="notification.type.textColor">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>textColor</em></code>
</td>
<td colspan="2">string</td>
<td>Text color of the notification.</td>
</tr>
<tr id="notification.type.borderColor">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>borderColor</em></code>
</td>
<td colspan="2">string</td>
<td>Border color of the notification.</td>
</tr>
<tr id="notification.type.backgroundColor">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>backgroundColor</em></code>
</td>
<td colspan="2">string</td>
<td>Background color of the notification.</td>
</tr>
<tr id="notification.type.progressColor">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>progressColor</em></code>
</td>
<td colspan="2">string</td>
<td>Progress bar color.</td>
</tr>
<tr id="notification.type.iconColor">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>iconColor</em></code>
</td>
<td colspan="2">string</td>
<td>Icon color. This only applies for inline <svg> tags in <code>icon</code>.</td>
</tr>
<tr id="notification.type.iconClasses">
<td class="d-flex flex-wrap">
<code class="text-bold flex-grow-1"><em>iconClasses</em></code>
</td>
<td colspan="2">string</td>
<td>CSS classes that will be added to the icon.</td>
</tr>
</tbody>
</table>
</div>
</section>
<section id="examples">
<div class="bg-secondary-2 pt-3">
<div class="container">
<h2>Examples</h2>
<ul class="pt-3 nav nav-tabs" id="tabExamples" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="example1-tab" href="#example1" role="tab"
aria-controls="Example 1" aria-selected="true" data-toggle="tab">Example 1</a>
</li>
<li class="nav-item">
<a class="nav-link" id="example2-tab" href="#example2" role="tab" aria-controls="Example 2"
aria-selected="true" data-toggle="tab">Example 2</a>
</li>
<li class="nav-item">
<a class="nav-link" id="example3-tab" href="#example3" role="tab" aria-controls="Example 3"
aria-selected="true" data-toggle="tab">Example 3</a>
</li>
<li class="nav-item">
<a class="nav-link" id="example4-tab" href="#example4" role="tab" aria-controls="Example 4"
aria-selected="true" data-toggle="tab">Example 4</a>
</li>
<li class="nav-item">
<a class="nav-link" id="example4-tab" href="#example5" role="tab" aria-controls="Example 5"
aria-selected="true" data-toggle="tab">Example 5</a>
</li>
</ul>
</div>
</div>
<div class="container pt-3">
<div class="tab-content" id="tabContentExamples">
<div class="tab-pane fade show active" id="example1" role="tabpanel" aria-labelledby="example1-tab">
<h3>Example 1: Push notifications</h3>
<p><code><em>push</em></code> your notification using the <code><em>type</em></code> according to
the message.</p>
<button class="btn btn-success" id="ex1notify1">Success Notification</button>
<button class="btn btn-info" id="ex1notify2">Info Notification</button>
<button class="btn btn-warning" id="ex1notify3">Warning Notification</button>
<button class="btn btn-danger" id="ex1notify4">Error Notification</button>
<div class="section_code py-3">
<div>Code:</div>
<pre><code class="language-html"><script src="dist/Notifier.min.js"></script>
<script>
(function () {
var notifier = new Notifier();
// Success
document.getElementById("ex1notify1").onclick = function () {
notifier.notify("success", "Successfully logged in!");
};
// Info
document.getElementById("ex1notify2").onclick = function () {
notifier.notify("info", "New message from <a href=\"https://github.com/jsanahuja/\" target=\"_new\">jsanahuja</a> received!");
};
// Warning
document.getElementById("ex1notify3").onclick = function () {
notifier.notify("warning", "Flood is not permitted, your chat will be temporary disabled");
};
// Error
document.getElementById("ex1notify4").onclick = function () {
notification = notifier.notify("error", "Invalid username or password");
};
})();
</script>
</code></pre>
</div>
</div>
<div class="tab-pane fade show" id="example2" role="tabpanel" aria-labelledby="example2-tab">
<h3>Example 2: Push, Clear and Destroy notifications</h3>
<p>Set the <code><em>autopush</em></code> to <em>false</em> and <code><em>push</em></code> your notification and <code><em>clear</em></code> or
<code><em>destroy</em></code> them prematurely.</p>
<button class="btn btn-primary" id="ex2notify1">Push 10 Notifications</button>
<button class="btn btn-secondary" id="ex2notify2">Clear all notifications</button>
<button class="btn btn-danger" id="ex2notify3">Destroy all notifications</button>
<div class="section_code py-3">
<div>Code:</div>
<pre><code class="language-html"><script src="dist/Notifier.min.js"></script>
<script>
(function(){
var notifier = new Notifier({
autopush: false
});
var notifications = [];
// Push 10 notifications
document.getElementById("ex2notify1").onclick = function () {
for(var i = 0; i < 10; i++){
var notification = notifier.notify("info", "Notification "+ i);
notification.push();
notifications.push(notification);
}
};
// Clear all notifications
document.getElementById("ex2notify2").onclick = function () {
for(var i = 0; i < notifications.length; i++){
notifications[i].clear();
}
notifications = [];
};
// Destroy all notifications
document.getElementById("ex2notify3").onclick = function () {
for(var i = 0; i < notifications.length; i++){
notifications[i].destroy();
}
notifications = [];
};
})();
</script>
</code></pre>
</div>
</div>
<div class="tab-pane fade show" id="example3" role="tabpanel" aria-labelledby="example3-tab">
<h3>Example 3: Using the callback</h3>
<p>Set a <code><em>callback</em></code> to trigger actions after the notification.</p>
<button class="btn btn-primary" id="ex3notify1">Start loop</button>
<button class="btn btn-secondary" id="ex3notify2">Stop loop</button>
<div class="section_code py-3">
<div>Code:</div>
<pre><code class="language-html"><script src="dist/Notifier.min.js"></script>
<script>
(function(){
var notifier = new Notifier();
var notification = null,
counter = 0;
// Start loop
document.getElementById("ex3notify1").onclick = function () {
if (notification !== null) {
return;
}
var callback = function () {
counter++;
notification = notifier.notify("info", "This is the notification #" + counter, 3500, callback);
}
callback();
};
// Destroy notification. Clearing it would call the callback!
document.getElementById("ex3notify2").onclick = function () {
if (notification === null) {
return;
}
notification.destroy();
notification = null;
};
})();
</script>
</code></pre>
</div>
</div>
<div class="tab-pane fade show" id="example4" role="tabpanel" aria-labelledby="example4-tab">
<h3>Example 4: Define your own styles</h3>
<p>Use the <code><em><type></em></code> option to define your own styles</p>
<button class="btn btn-github" id="ex4notify1">
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path
d="M4.03 0c-2.53 0-4.03 3-4.03 3s1.5 3 4.03 3c2.47 0 3.97-3 3.97-3s-1.5-3-3.97-3zm-.03 1c1.11 0 2 .9 2 2 0 1.11-.89 2-2 2-1.1 0-2-.89-2-2 0-1.1.9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.04-.19-.06-.28-.08.16-.24.28-.44.28-.28 0-.5-.22-.5-.5 0-.2.12-.36.28-.44-.09-.03-.18-.06-.28-.06z"
transform="translate(0 1)" /></svg>
Watch
</button>
<button class="btn btn-github" id="ex4notify2">
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path d="M4 0l-1 3h-3l2.5 2-1 3 2.5-2 2.5 2-1-3 2.5-2h-3l-1-3z" /></svg>
Star
</button>
<button class="btn btn-github" id="ex4notify3">
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path
d="M4.03 0c-2.53 0-4.03 3-4.03 3s1.5 3 4.03 3c2.47 0 3.97-3 3.97-3s-1.5-3-3.97-3zm-.03 1c1.11 0 2 .9 2 2 0 1.11-.89 2-2 2-1.1 0-2-.89-2-2 0-1.1.9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.04-.19-.06-.28-.08.16-.24.28-.44.28-.28 0-.5-.22-.5-.5 0-.2.12-.36.28-.44-.09-.03-.18-.06-.28-.06z"
transform="translate(0 1)" /></svg>
Fork
</button>
<p class="mt-3">All the icons, including the ones of this example, used by <a
href="https://github.com/jsanahuja/Notifierjs" target="_new">Notifier.js</a> were taken
from <a href="https://github.com/iconic/open-iconic">open-iconic</a></p>
<div class="section_code py-3">
<div>Code:</div>
<pre><code class="language-html"><script src="dist/Notifier.min.js"></script>
<script>
(function(){
var notifier = new Notifier({
watch: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M4.03 0c-2.53 0-4.03 3-4.03 3s1.5 3 4.03 3c2.47 0 3.97-3 3.97-3s-1.5-3-3.97-3zm-.03 1c1.11 0 2 .9 2 2 0 1.11-.89 2-2 2-1.1 0-2-.89-2-2 0-1.1.9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.04-.19-.06-.28-.08.16-.24.28-.44.28-.28 0-.5-.22-.5-.5 0-.2.12-.36.28-.44-.09-.03-.18-.06-.28-.06z\" transform=\"translate(0 1)\" /></svg>"
},
star: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M4 0l-1 3h-3l2.5 2-1 3 2.5-2 2.5 2-1-3 2.5-2h-3l-1-3z\" /></svg>"
},
fork: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M1.5 0c-.83 0-1.5.67-1.5 1.5 0 .66.41 1.2 1 1.41v2.19c-.59.2-1 .75-1 1.41 0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5c0-.6-.34-1.1-.84-1.34.09-.09.21-.16.34-.16h2c.82 0 1.5-.68 1.5-1.5v-.59c.59-.2 1-.75 1-1.41 0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5c0 .66.41 1.2 1 1.41v.59c0 .28-.22.5-.5.5h-2c-.17 0-.35.04-.5.09v-1.19c.59-.2 1-.75 1-1.41 0-.83-.67-1.5-1.5-1.5z\" /></svg>"
}
});
document.getElementById("ex4notify1").onclick = function () {
notifier.notify("watch", "Watched!");
};
document.getElementById("ex4notify2").onclick = function () {
notifier.notify("star", "Starred!");
};
document.getElementById("ex4notify3").onclick = function () {
notifier.notify("fork", "Forked!");
};
})();
</script>
</code></pre>
</div>
</div>
<div class="tab-pane fade show" id="example5" role="tabpanel" aria-labelledby="example4-tab">
<h3>Example 5: Position the notifications and set the stack direction</h3>
<p>Use the <code><em>position</em></code> and <code><em>direction</em></code> options to change it.</p>
<button class="btn btn-github" id="ex5notify1">Top Left</button>
<button class="btn btn-github" id="ex5notify2">Top Right</button>
<button class="btn btn-github" id="ex5notify3">Bottom Left</button>
<button class="btn btn-github" id="ex5notify4">Bottom Right</button>
<div class="section_code py-3">
<div>Code:</div>
<pre><code class="language-html"><script src="dist/Notifier.min.js"></script>
<script>
(function(){
var notifierTR = new Notifier({
position: 'top-right',
direction: 'top'
});
var notifierTL = new Notifier({
position: 'top-left',
direction: 'top'
});
var notifierBL = new Notifier({
position: 'bottom-left',
direction: 'bottom'
});
var notifierBR = new Notifier({
position: 'bottom-right',
direction: 'bottom'
});
document.getElementById("ex5notify1").onclick = function () {
notifierTL.notify("info", "I am on TOP LEFT!");
};
document.getElementById("ex5notify2").onclick = function () {
notifierTR.notify("info", "I am on TOP RIGHT!");
};
document.getElementById("ex5notify3").onclick = function () {
notifier.notify("info", "I am on BOTTOM LEFT!");
};
document.getElementById("ex5notify4").onclick = function () {
notifier.notify("info", "I am on BOTTOM RIGHT!");
};
})();
</script>
</code></pre>
</div>
</div>
</div>
</div>
</section>
<footer id="footer" class="bg-dark">
<div class="container text-center py-4">
<h3 class="text-white">Still not enough?</h3>
<a class="h3 mb-3 text-primary text-underline" target="_blank" rel="noopener"
href="https://github.com/jsanahuja/Notifierjs">
Open an issue or send a pull request!
</a>
</div>
<a href="#header" id="btn-top" class="bg-primary px-2 py-1" title="Go top">
<span class="text-white" aria-hidden="true">^</span>
</a>
</footer>
<script src="dist/Notifier.min.js"></script>
<script>
// Example 1
(function () {
var notifier = new Notifier();
document.getElementById("ex1notify1").onclick = function () {
notifier.notify("success", "Successfully logged in!");
};
document.getElementById("ex1notify2").onclick = function () {
notifier.notify("info", "New message from <a href=\"https://github.com/jsanahuja/\" target=\"_new\">jsanahuja</a> received!");
};
document.getElementById("ex1notify3").onclick = function () {
notifier.notify("warning", "Flood is not permitted, your chat will be temporary disabled");
};
document.getElementById("ex1notify4").onclick = function () {
notifier.notify("error", "Invalid username or password");
};
})();
// Example 2
(function () {
var notifier = new Notifier({
autopush: false
});
var notifications = [];
document.getElementById("ex2notify1").onclick = function () {
for (var i = 0; i < 10; i++) {
var notification = notifier.notify("info", "Notification " + i);
notification.push();
notifications.push(notification);
}
};
document.getElementById("ex2notify2").onclick = function () {
for (var i = 0; i < notifications.length; i++) {
notifications[i].clear();
}
notifications = [];
};
document.getElementById("ex2notify3").onclick = function () {
for (var i = 0; i < notifications.length; i++) {
notifications[i].destroy();
}
notifications = [];
};
})();
//Example 3
(function () {
var notifier = new Notifier();
var notification = null,
counter = 0;
document.getElementById("ex3notify1").onclick = function () {
if (notification !== null) {
return;
}
var callback = function () {
counter++;
notification = notifier.notify("info", "This is the notification #" + counter, 3500, callback);
}
callback();
};
document.getElementById("ex3notify2").onclick = function () {
if (notification === null) {
return;
}
notification.destroy();
notification = null;
};
})();
// Example 4
(function () {
var notifier = new Notifier({
watch: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M4.03 0c-2.53 0-4.03 3-4.03 3s1.5 3 4.03 3c2.47 0 3.97-3 3.97-3s-1.5-3-3.97-3zm-.03 1c1.11 0 2 .9 2 2 0 1.11-.89 2-2 2-1.1 0-2-.89-2-2 0-1.1.9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.04-.19-.06-.28-.08.16-.24.28-.44.28-.28 0-.5-.22-.5-.5 0-.2.12-.36.28-.44-.09-.03-.18-.06-.28-.06z\" transform=\"translate(0 1)\" /></svg>"
},
star: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M4 0l-1 3h-3l2.5 2-1 3 2.5-2 2.5 2-1-3 2.5-2h-3l-1-3z\" /></svg>"
},
fork: {
textColor: "#24292e",
borderColor: "#c4c8cc",
backgroundColor: "#fafbfc",
progressColor: "#24292e",
iconColor: "#24292e",
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\"><path d=\"M1.5 0c-.83 0-1.5.67-1.5 1.5 0 .66.41 1.2 1 1.41v2.19c-.59.2-1 .75-1 1.41 0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5c0-.6-.34-1.1-.84-1.34.09-.09.21-.16.34-.16h2c.82 0 1.5-.68 1.5-1.5v-.59c.59-.2 1-.75 1-1.41 0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5c0 .66.41 1.2 1 1.41v.59c0 .28-.22.5-.5.5h-2c-.17 0-.35.04-.5.09v-1.19c.59-.2 1-.75 1-1.41 0-.83-.67-1.5-1.5-1.5z\" /></svg>"
}
});
document.getElementById("ex4notify1").onclick = function () {
notification = notifier.notify("watch", "Watched!");
notification.push();
};
document.getElementById("ex4notify2").onclick = function () {
notification = notifier.notify("star", "Starred!");
notification.push();
};
document.getElementById("ex4notify3").onclick = function () {
notification = notifier.notify("fork", "Forked!");
notification.push();
};
})();
// Example 5
(function () {
var notifierTR = new Notifier({
position: 'top-right',
direction: 'top'
});
var notifierTL = new Notifier({
position: 'top-left',
direction: 'top'
});
var notifierBL = new Notifier({
position: 'bottom-left',
direction: 'bottom'
});
var notifierBR = new Notifier({
position: 'bottom-right',
direction: 'bottom'
});
document.getElementById("ex5notify1").onclick = function () {
notifierTL.notify("info", "I am on TOP LEFT!");
};
document.getElementById("ex5notify2").onclick = function () {
notifierTR.notify("info", "I am on TOP RIGHT!");
};
document.getElementById("ex5notify3").onclick = function () {
notifierBL.notify("info", "I am on BOTTOM LEFT!");
};
document.getElementById("ex5notify4").onclick = function () {
notifierBR.notify("info", "I am on BOTTOM RIGHT!");
};
})();
(function ($) {
$(window).scroll(function () {
var viewportTop = $(window).scrollTop() + $(window).height();
if ($(window).scrollTop() > 10) {
$('#btn-top').addClass('d-block');
$('#btn-top').removeClass('d-none');
} else {
$('#btn-top').addClass('d-none');
$('#btn-top').removeClass('d-block');
}
});
})(jQuery);
</script>
</body>
</html>