10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
-
-
-
+
+
+
+
-
+
|
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;
if (this.bShadow) {
this.xShadowPanel = oGrammalecte.createNode("div", {id: this.sId+"_shadow", style: "width:0;height:0;"});
this.xShadow = this.xShadowPanel.attachShadow({mode: "open"});
this.xParent = this.xShadow;
} else {
this.oParent = document;
this.xParent = document;
}
this.xMessageBoxBar = oGrammalecte.createNode("div", {className: "grammalecte_message_box_bar"});
this.xMessageBoxContent = oGrammalecte.createNode("div", {className: "grammalecte_message_box_content"});
this.xMessageBox = this._createPanel(sTitle);
}
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
-
-
-
+
+
+
+
|
let xButton = oGrammalecte.createNode("div", {className: "grammalecte_close_button", textContent: "×", title: "Fermer la fenêtre"});
xButton.onclick = function () { this.hide(); }.bind(this); // better than writing “let that = this;” before the function?
return xButton;
}
insertIntoPage () {
if (this.bShadow){
oGrammalecte.createStyle("content_scripts/panel.css", null, this.oShadow);
oGrammalecte.createStyle("content_scripts/message_box.css", null, this.oShadow);
this.oShadow.appendChild(this.xMessageBox);
document.body.appendChild(this.oShadowPanel);
oGrammalecte.createStyle("content_scripts/panel.css", null, this.xShadow);
oGrammalecte.createStyle("content_scripts/message_box.css", null, this.xShadow);
this.xShadow.appendChild(this.xMessageBox);
document.body.appendChild(this.xShadowPanel);
} else {
if (!document.getElementById("grammalecte_cssmsg")){
oGrammalecte.createStyle("content_scripts/panel.css", null, document.head);
oGrammalecte.createStyle("content_scripts/message_box.css", "grammalecte_cssmsg", document.head);
}
document.body.appendChild(this.xMessageBox);
}
|