Grammalecte  Check-in [91852523ef]

Overview
Comment:[fx] Use Shadow DOM in messagebox when avaible
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | shadowdom
Files: files | file ages | folders
SHA3-256: 91852523ef185c28bb5d067c6eb94f59a599078ae66b385fe82e96adb3b4dbf9
User & Date: IllusionPerdu on 2018-10-19 14:45:12
Other Links: branch diff | manifest | tags
Context
2018-10-19
14:57
[fx] Oups it's not necessary to have sUrl in panel or msgbox check-in: f8cceefa3c user: IllusionPerdu tags: fx, shadowdom
14:45
[fx] Use Shadow DOM in messagebox when avaible check-in: 91852523ef user: IllusionPerdu tags: fx, shadowdom
14:33
[fx] Use Shadow DOM in panel when avaible check-in: 41527933de user: IllusionPerdu tags: fx, shadowdom
Changes

Modified gc_lang/fr/webext/content_scripts/message_box.js from [4f0ad33a4a] to [1ad982bafb].

1
2
3




4
5
6
7
8
9
10











11
12
13
14
15
16
17
// JavaScript
// Panel creator





"use strict";


class GrammalecteMessageBox {

    constructor (sId, sTitle) {
        this.sId = sId;











        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);
    }

    _createPanel (sTitle) {
        try {



>
>
>
>





|

>
>
>
>
>
>
>
>
>
>
>







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
// 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 {
            this.oParent = 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);
    }

    _createPanel (sTitle) {
        try {
46
47
48
49
50
51
52










53

54
55
56
57
58
59
60
    _createCloseButton () {
        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 () {










        document.body.appendChild(this.xMessageBox);

    }

    show () {
        this.xMessageBox.style.display = "block";
    }

    hide () {







>
>
>
>
>
>
>
>
>
>
|
>







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
    _createCloseButton () {
        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){
            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);
        }
    }

    show () {
        this.xMessageBox.style.display = "block";
    }

    hide () {