Grammalecte  Check-in [e605c5e3ec]

Overview
Comment:[fx] code cleaning
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | FixWebext
Files: files | file ages | folders
SHA3-256: e605c5e3ecb62bf55e5d2b775bd95a25265c669b2759b0b67a9b2c2e36cdd1cc
User & Date: olr on 2017-10-28 07:52:17
Other Links: branch diff | manifest | tags
Context
2017-10-28
07:54
[fx] CSS: line-height doesn’t look OK on Firefox check-in: e20095be97 user: olr tags: fx, FixWebext
07:52
[fx] code cleaning check-in: e605c5e3ec user: olr tags: fx, FixWebext
07:29
[fx] fix menu button size check-in: 93122299cc user: olr tags: fx, FixWebext
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [184607ced6] to [669d7f6b5e].

94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108







-
+







        }
    },

    observePage: function () {
        /*
            When a textarea is added via jascript we add the menu :)
        */
        let this.xObserver = new MutationObserver(function (mutations) {
        this.xObserver = new MutationObserver(function (mutations) {
            mutations.forEach(function (mutation) {
                for (let i = 0;  i < mutation.addedNodes.length;  i++){
                    if (mutation.addedNodes[i].getElementsByTagName) {
                        if (mutation.addedNodes[i].tagName == "TEXTAREA") {
                            oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, mutation.addedNodes[i]));
                            oGrammalecte.nMenu += 1;
                        } else {

Modified gc_lang/fr/webext/content_scripts/menu.js from [0a15c1c9ea] to [6f7cefd29a].

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
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







-
-
+
+

-
-
-
+
+
+


-
+
-
-
-
+
-
-
-
+


-
+

+


-
+







        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 style = window.getComputedStyle(this.xNode);
        let topMargin = -1 * (8 + parseInt(style.marginBottom.replace('px', ''), 10));
        let xStyle = window.getComputedStyle(this.xNode);
        let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10));

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

        this._insertAfter(this.xButton, insAfterThis);
        this._insertAfter(this.xButton, xNodeInsertAfter, nMarginTop);
        this.xButton.style.marginTop = topMargin + 'px';

        this._insertAfter(this.xMenu, insAfterThis);
        this._insertAfter(this.xMenu, xNodeInsertAfter, nMarginTop + 8);
        this.xMenu.style.marginTop = (topMargin + 8) + 'px';

        this._createListenersOnReferenceNode();
        this._createListeners();
    }

    _insertAfter (xNewNode, xReferenceNode) {
    _insertAfter (xNewNode, xReferenceNode, nMarginTop) {
        xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling);
        xNewNode.style.marginTop = nMarginTop + "px";
    }

    _createListenersOnReferenceNode () {
    _createListeners () {
        this.xNode.addEventListener('focus', (e) => {
            this.xButton.style.display = "block";
        });
        this.xNode.addEventListener('blur', (e) => {
            window.setTimeout(() => {this.xButton.style.display = "none";}, 300);
        });
    }