PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 4.8
Tagembed: Social Media Feeds and Customer Reviews Widget v4.8
7.8 7.5 7.6 7.7 7.4 trunk 3.10 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 All 43 releases
tagembed-widget / assets / js / toast.js

toast.js in Tagembed: Social Media Feeds and Customer Reviews Widget 4.8, at assets/js/toast.js

67 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*--Start--Manage Toast*/
2 class TagembedToast {
3 constructor() {
4 this.id = "Toast";
5 this.position = "__tagembed__is-top-center";
6 this.type = "";
7 this.icon = "";
8 this.className = "__tagembed__toast";
9 this.duration = 3000;
10 this.isFullScreen = false;
11 }
12 info(options) {
13 this.type = "__tagembed__bg-info";
14 this.icon = "fa-info";
15 this.show(options);
16 }
17 warning(options) {
18 this.type = "__tagembed__bg-warning";
19 this.icon = "fa-exclamatio";
20 this.show(options);
21 }
22 danger(options) {
23 this.type = "__tagembed__bg-danger";
24 this.icon = "fa-times";
25 this.show(options);
26 }
27 success(options) {
28 this.type = "__tagembed__bg-success";
29 this.icon = "fa-check";
30 this.show(options);
31 }
32 show(options) {
33 if (options.hasOwnProperty("position")) {
34 this.position = options.position;
35 }
36 if (options.hasOwnProperty("type")) {
37 this.type = options.type;
38 }
39 if (options.hasOwnProperty("message")) {
40 this.message = options.message;
41 }
42 if (options.hasOwnProperty("duration")) {
43 this.duration = options.duration;
44 }
45 /*create toast*/
46 let toastDiv = document.createElement("div");
47 let elemHTML = '<span class="__tagembed__faicon"><i class="fas ' + this.icon + '" aria-hidden="true"></i></span><span class="__tagembed__btnmsg">' + this.message + '</span>';
48 toastDiv.innerHTML = elemHTML;
49 toastDiv.className = this.type;
50 let toastParentDiv = document.createElement("div");
51 toastParentDiv.setAttribute('id', this.id);
52 toastParentDiv.className = this.className + " " + this.position;
53 if (options.hasOwnProperty("isFullScreen") && options.isFullScreen == true) {
54 toastParentDiv.className += " __tagembed__is-full-screen";
55 }
56 toastParentDiv.appendChild(toastDiv);
57 let bodyElement = document.body;
58 bodyElement.appendChild(toastParentDiv);
59 let self = this;
60 setTimeout(function () {
61 let element = document.getElementById(self.id);
62 element.className = "";
63 element.parentNode.removeChild(element);
64 }, this.duration);
65 }
66 }
67 /*--End--Manage Toast*/