1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// JavaScript
// Panel creator
/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global oGrammalecte, xGrammalectePort, showError, window, document, console */
"use strict";
class GrammalecteMessageBox {
constructor (sUrl, sId, sTitle) {
this.sId = sId;
this.sUrl = sUrl;
this.bShadow = document.body.createShadowRoot || document.body.attachShadow;
if (this.bShadow){
this.oShadowPanel = oGrammalecte.createNode("div", {id: this.sId+"_shadow", style: "width:0;height:0;"});
this.oShadow = this.oShadowPanel.attachShadow({mode: "open"});
this.oParent = this.oShadow;
} else {
|
|
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// JavaScript
// Panel creator
/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global oGrammalecte, xGrammalectePort, showError, window, document, console */
"use strict";
class GrammalecteMessageBox {
constructor (sId, sTitle) {
this.sId = sId;
this.bShadow = document.body.createShadowRoot || document.body.attachShadow;
if (this.bShadow){
this.oShadowPanel = oGrammalecte.createNode("div", {id: this.sId+"_shadow", style: "width:0;height:0;"});
this.oShadow = this.oShadowPanel.attachShadow({mode: "open"});
this.oParent = this.oShadow;
} else {
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
xButton.onclick = function () { this.hide(); }.bind(this); // better than writing “let that = this;” before the function?
return xButton;
}
insertIntoPage () {
if (this.bShadow){
this.oShadow.appendChild(
oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: this.sUrl+"content_scripts/panel.css"})
);
this.oShadow.appendChild(
oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: this.sUrl+"content_scripts/message_box.css"})
);
this.oShadow.appendChild(this.xMessageBox);
document.body.appendChild(this.oShadowPanel);
} else {
document.body.appendChild(this.xMessageBox);
}
}
|
|
|
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
xButton.onclick = function () { this.hide(); }.bind(this); // better than writing “let that = this;” before the function?
return xButton;
}
insertIntoPage () {
if (this.bShadow){
this.oShadow.appendChild(
oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel.css"})
);
this.oShadow.appendChild(
oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/message_box.css"})
);
this.oShadow.appendChild(this.xMessageBox);
document.body.appendChild(this.oShadowPanel);
} else {
document.body.appendChild(this.xMessageBox);
}
}
|