PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 7.9
Tagembed: Social Media Feeds and Customer Reviews Widget v7.9
7.9 8.0 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 All 45 releases
tagembed-widget / assets / js / toast.js
assets/js
account 4 days ago customize 4 days ago display 4 days ago editor 4 days ago feed 4 days ago filter 4 days ago network 4 days ago support 4 days ago theme 4 days ago upgrade 4 days ago vendor 4 days ago widget 4 days ago confirm_dialog.js 4.5 KB 4 days ago dialog.form.js 10.6 KB 4 days ago lazyload.js 4.9 KB 4 days ago loader.js 1.3 KB 4 days ago tagembed.common.js 25.0 KB 4 days ago tagembed.deactive.js 9.2 KB 4 days ago toast.js 3.0 KB 4 days ago

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

78 lines 3.0 KB 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 /* The message is rendered as text only. No markup is built from it, so there is
47 nothing for an attacker to break out of. */
48 let toastDiv = document.createElement("div");
49 let toastIconSpan = document.createElement("span");
50 toastIconSpan.className = "__tagembed__faicon";
51 let toastIcon = document.createElement("i");
52 toastIcon.className = "fas " + this.icon;
53 toastIcon.setAttribute("aria-hidden", "true");
54 toastIconSpan.appendChild(toastIcon);
55 let toastMessageSpan = document.createElement("span");
56 toastMessageSpan.className = "__tagembed__btnmsg";
57 toastMessageSpan.textContent = (this.message === undefined || this.message === null) ? "" : String(this.message);
58 toastDiv.appendChild(toastIconSpan);
59 toastDiv.appendChild(toastMessageSpan);
60 toastDiv.className = this.type;
61 let toastParentDiv = document.createElement("div");
62 toastParentDiv.setAttribute('id', this.id);
63 toastParentDiv.className = this.className + " " + this.position;
64 if (options.hasOwnProperty("isFullScreen") && options.isFullScreen == true) {
65 toastParentDiv.className += " __tagembed__is-full-screen";
66 }
67 toastParentDiv.appendChild(toastDiv);
68 let bodyElement = document.body;
69 bodyElement.appendChild(toastParentDiv);
70 let self = this;
71 setTimeout(function () {
72 let element = document.getElementById(self.id);
73 element.className = "";
74 element.parentNode.removeChild(element);
75 }, this.duration);
76 }
77 }
78 /*--End--Manage Toast*/