Grammalecte  Check-in [b652ab4e9d]

Overview
Comment:[fx] Don't auto load CSS - Ajuste time for autoheigth
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | shadowdom
Files: files | file ages | folders
SHA3-256: b652ab4e9d3c02d80f825100f169ef23092453f907c4dd7a13feb059d37078bd
User & Date: IllusionPerdu on 2018-10-19 23:18:44
Other Links: branch diff | manifest | tags
Context
2018-10-20
10:42
[fx] More elegant solution for adding styles check-in: 933990893e user: IllusionPerdu tags: fx, shadowdom
2018-10-19
23:18
[fx] Don't auto load CSS - Ajuste time for autoheigth check-in: b652ab4e9d user: IllusionPerdu tags: fx, shadowdom
16:36
[fx] Fix auto-ajust height of TextFormateur check-in: cea1ffe126 user: IllusionPerdu tags: fx, shadowdom
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [677d02ceb6] to [f45d12f413].

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
        this.lMenu.length = 0; // to clear an array
        this.listenRightClick();
        this.createMenus();
    },

    createTFPanel: function () {
        if (this.oTFPanel === null) {
            this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 600, false);
            //this.oTFPanel.logInnerHTML();
            this.oTFPanel.insertIntoPage();
            window.setTimeout(function(self){
                self.oTFPanel.adjustHeight();
            }, 1, this);
        }
    },

    createLxgPanel: function () {
        if (this.oLxgPanel === null) {
            this.oLxgPanel = new GrammalecteLexicographer("grammalecte_lxg_panel", "Lexicographe", 500, 700);
            this.oLxgPanel.insertIntoPage();







|




|







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
        this.lMenu.length = 0; // to clear an array
        this.listenRightClick();
        this.createMenus();
    },

    createTFPanel: function () {
        if (this.oTFPanel === null) {
            this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 760, 615, false);
            //this.oTFPanel.logInnerHTML();
            this.oTFPanel.insertIntoPage();
            window.setTimeout(function(self){
                self.oTFPanel.adjustHeight();
            }, 50, this);
        }
    },

    createLxgPanel: function () {
        if (this.oLxgPanel === null) {
            this.oLxgPanel = new GrammalecteLexicographer("grammalecte_lxg_panel", "Lexicographe", 500, 700);
            this.oLxgPanel.insertIntoPage();
228
229
230
231
232
233
234




235
236
237
238
239
240
241

xGrammalectePort.onMessage.addListener(function (oMessage) {
    let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
    let sText = "";
    switch (sActionDone) {
        case "init":
            oGrammalecte.sExtensionUrl = oMessage.sUrl;




            break;
        case "parseAndSpellcheck":
            if (!bEnd) {
                oGrammalecte.oGCPanel.addParagraphResult(result);
            } else {
                oGrammalecte.oGCPanel.stopWaitIcon();
            }







>
>
>
>







228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

xGrammalectePort.onMessage.addListener(function (oMessage) {
    let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
    let sText = "";
    switch (sActionDone) {
        case "init":
            oGrammalecte.sExtensionUrl = oMessage.sUrl;
            // Start
            oGrammalecte.listenRightClick();
            oGrammalecte.createMenus();
            oGrammalecte.observePage();
            break;
        case "parseAndSpellcheck":
            if (!bEnd) {
                oGrammalecte.oGCPanel.addParagraphResult(result);
            } else {
                oGrammalecte.oGCPanel.stopWaitIcon();
            }
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
        case "rescanPage":
            oGrammalecte.rescanPage();
            break;
        default:
            console.log("[Content script] Unknown command: " + sActionDone);
    }
});


/*
    Start
*/
oGrammalecte.listenRightClick();
oGrammalecte.createMenus();
oGrammalecte.observePage();







<
<
<
<
<
<
<
<
329
330
331
332
333
334
335








        case "rescanPage":
            oGrammalecte.rescanPage();
            break;
        default:
            console.log("[Content script] Unknown command: " + sActionDone);
    }
});








Modified gc_lang/fr/webext/content_scripts/menu.css from [b015cf663a] to [0e552e9d81].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    }
}


/*
    Menu
*/
div.grammalecte_abs {
    display: none;
    position: absolute;
}

div.grammalecte_menu {
    all: initial;
    display: none;
    position: absolute;
    margin-left: -10px;
    border-radius: 5px;
    border: 3px solid hsl(210, 50%, 30%);







<
<
<
<
<







44
45
46
47
48
49
50





51
52
53
54
55
56
57
    }
}


/*
    Menu
*/





div.grammalecte_menu {
    all: initial;
    display: none;
    position: absolute;
    margin-left: -10px;
    border-radius: 5px;
    border: 3px solid hsl(210, 50%, 30%);

Modified gc_lang/fr/webext/content_scripts/menu.js from [0e7a0e2ea5] to [c804b43d48].

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
33
34
35
36
37
38
39
40
41
42
43
44
45






46
47
48
49
50
51
52


class GrammalecteMenu {

    constructor (nMenu, xNode) {
        this.xNode = xNode;
        this.sMenuId = "grammalecte_menu" + nMenu;
        this.bShadow = document.body.createShadowRoot || document.body.attachShadow;
        this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "});
        this.xButton.onclick = () => { this.switchMenu(); };
        this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex;
        this.xMenu = this._createMenu();

        let xStyle = window.getComputedStyle(this.xNode);
        let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10));

        let xNodeInsertAfter = this.xNode;
        if (document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')) {
            xNodeInsertAfter = this.xNode.parentNode;
        }


        if (this.bShadow){

            this.oShadowBtn = oGrammalecte.createNode("div", {className: "grammalecte_abs", style: "width:16px;height:16px;"});
            this.oShadowBtnNode = this.oShadowBtn.attachShadow({mode: "open"});
            this.oShadowBtnNode.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"})
            );
            this.oShadowBtnNode.appendChild(this.xButton);
            this._insertAfter(this.oShadowBtn, xNodeInsertAfter, nMarginTop);

            this.oShadowMenu = oGrammalecte.createNode("div", {id: this.sMenuId+"_shadow", className: "grammalecte_abs", style: "width:0;height:0;"});
            this.oShadowMenuNode = this.oShadowMenu.attachShadow({mode: "open"});
            this.oShadowMenuNode.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"})
            );
            this.oShadowMenuNode.appendChild(this.xMenu);
            this._insertAfter(this.oShadowMenu, xNodeInsertAfter, nMarginTop + 8);
        } else {






            this._insertAfter(this.xButton, xNodeInsertAfter, nMarginTop);
            this._insertAfter(this.xMenu, xNodeInsertAfter, nMarginTop + 8);
        }
        this._createListeners();
    }

    _insertAfter (xNewNode, xReferenceNode, nMarginTop) {







<






<






>

>
|







|







>
>
>
>
>
>







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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


class GrammalecteMenu {

    constructor (nMenu, xNode) {
        this.xNode = xNode;
        this.sMenuId = "grammalecte_menu" + nMenu;

        this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "});
        this.xButton.onclick = () => { this.switchMenu(); };
        this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex;
        this.xMenu = this._createMenu();

        let xStyle = window.getComputedStyle(this.xNode);


        let xNodeInsertAfter = this.xNode;
        if (document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')) {
            xNodeInsertAfter = this.xNode.parentNode;
        }

        this.bShadow = document.body.createShadowRoot || document.body.attachShadow;
        if (this.bShadow){
            let nMarginTop = -1 * (parseInt(xStyle.marginBottom.replace('px', ''), 10));
            this.oShadowBtn = oGrammalecte.createNode("div", {style: "display:none;position:absolute;width:0;height:0;"});
            this.oShadowBtnNode = this.oShadowBtn.attachShadow({mode: "open"});
            this.oShadowBtnNode.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"})
            );
            this.oShadowBtnNode.appendChild(this.xButton);
            this._insertAfter(this.oShadowBtn, xNodeInsertAfter, nMarginTop);

            this.oShadowMenu = oGrammalecte.createNode("div", {id: this.sMenuId+"_shadow", style: "display:none;position:absolute;width:0;height:0;"});
            this.oShadowMenuNode = this.oShadowMenu.attachShadow({mode: "open"});
            this.oShadowMenuNode.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"})
            );
            this.oShadowMenuNode.appendChild(this.xMenu);
            this._insertAfter(this.oShadowMenu, xNodeInsertAfter, nMarginTop + 8);
        } else {
            let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10));
            if (!document.getElementById("grammalecte_cssmenu")){
                document.head.appendChild(
                    oGrammalecte.createNode("link", {id: "grammalecte_cssmenu", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/menu.css"})
                );
            }
            this._insertAfter(this.xButton, xNodeInsertAfter, nMarginTop);
            this._insertAfter(this.xMenu, xNodeInsertAfter, nMarginTop + 8);
        }
        this._createListeners();
    }

    _insertAfter (xNewNode, xReferenceNode, nMarginTop) {

Modified gc_lang/fr/webext/content_scripts/message_box.js from [570e256791] to [85fc74a091].

70
71
72
73
74
75
76








77
78
79
80
81
82
83
            );
            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);
        }
    }

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







>
>
>
>
>
>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
            );
            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 {
            if (!document.getElementById("grammalecte_cssmsg")){
                document.head.appendChild(
                    oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel.css"})
                );
                document.head.appendChild(
                    oGrammalecte.createNode("link", {id: "grammalecte_cssmsg", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/message_box.css"})
                );
            }
            document.body.appendChild(this.xMessageBox);
        }
    }

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

Modified gc_lang/fr/webext/content_scripts/panel.js from [c76d6fb8d0] to [d7c31535a7].

109
110
111
112
113
114
115














116
117
118
119
120
121
122
            );
            this.oShadow.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_tf.css"})
            );
            this.oShadow.appendChild(this.xPanel);
            document.body.appendChild(this.oShadowPanel);
        } else {














            document.body.appendChild(this.xPanel);
        }
    }

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







>
>
>
>
>
>
>
>
>
>
>
>
>
>







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
            );
            this.oShadow.appendChild(
                oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_tf.css"})
            );
            this.oShadow.appendChild(this.xPanel);
            document.body.appendChild(this.oShadowPanel);
        } else {
            if (!document.getElementById("grammalecte_csspanel")){
                document.head.appendChild(
                    oGrammalecte.createNode("link", {id: "grammalecte_csspanel", rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel.css"})
                );
                document.head.appendChild(
                    oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_gc.css"})
                );
                document.head.appendChild(
                    oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_lxg.css"})
                );
                document.head.appendChild(
                    oGrammalecte.createNode("link", {rel: "stylesheet", type: "text/css", media: "all", href: oGrammalecte.sExtensionUrl + "content_scripts/panel_tf.css"})
                );
            }
            document.body.appendChild(this.xPanel);
        }
    }

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

Modified gc_lang/fr/webext/content_scripts/panel_tf.css from [4f1042a727] to [be63cf139a].

109
110
111
112
113
114
115

116
117
118
119
120
121
122
123
124
125
126
127
    color: hsl(210, 0%, 100%);
}
div#grammalecte_tf_reset:hover {
    background-color: hsl(210, 50%, 40%);
}
progress#grammalecte_tf_progressbar {
    width: 360px;

}
span#grammalecte_tf_time_res {
    width: 60px;
    padding: 5px 10px;
}
div#grammalecte_tf_apply {
    background-color: hsl(120, 50%, 50%);
    color: hsl(150, 0%, 100%);
}
div#grammalecte_tf_apply:hover {
    background-color: hsl(120, 50%, 40%);
}







>












109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    color: hsl(210, 0%, 100%);
}
div#grammalecte_tf_reset:hover {
    background-color: hsl(210, 50%, 40%);
}
progress#grammalecte_tf_progressbar {
    width: 360px;
    height: 29px;
}
span#grammalecte_tf_time_res {
    width: 60px;
    padding: 5px 10px;
}
div#grammalecte_tf_apply {
    background-color: hsl(120, 50%, 50%);
    color: hsl(150, 0%, 100%);
}
div#grammalecte_tf_apply:hover {
    background-color: hsl(120, 50%, 40%);
}

Modified gc_lang/fr/webext/manifest.json from [e5bad7cd5c] to [1e877b8ece].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
87
88
89
90
    {
      "matches": ["<all_urls>"],
      "exclude_matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "css": [
        "content_scripts/panel.css",
        "content_scripts/panel_tf.css",
        "content_scripts/panel_gc.css",
        "content_scripts/panel_lxg.css",
        "content_scripts/message_box.css",
        "content_scripts/menu.css"
      ],
      "js": [
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/panel_lxg.js",
        "content_scripts/message_box.js",
        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_end"
    },
    {
      "matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "css": [
        "content_scripts/panel.css",
        "content_scripts/panel_tf.css",
        "content_scripts/panel_gc.css",
        "content_scripts/panel_lxg.css",
        "content_scripts/menu.css"
      ],
      "js": [
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/panel_lxg.js",
        "content_scripts/menu.js",







<
<
<
<
<
<
<
<


















<
<
<
<
<
<
<







44
45
46
47
48
49
50








51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68







69
70
71
72
73
74
75
    {
      "matches": ["<all_urls>"],
      "exclude_matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],








      "js": [
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/panel_lxg.js",
        "content_scripts/message_box.js",
        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_end"
    },
    {
      "matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],







      "js": [
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/panel_lxg.js",
        "content_scripts/menu.js",