Grammalecte  Check-in [e70da9d241]

Overview
Comment:[fx] MutationObserver in main object oGrammalecte
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | FixWebext
Files: files | file ages | folders
SHA3-256: e70da9d241cbbfadb57bd841b17b94c4f28419d5871645e32208014553d8e22c
User & Date: olr on 2017-10-28 07:28:49
Other Links: branch diff | manifest | tags
Context
2017-10-28
07:29
[fx] fix menu button size check-in: 93122299cc user: olr tags: FixWebext, fx
07:28
[fx] MutationObserver in main object oGrammalecte check-in: e70da9d241 user: olr tags: FixWebext, fx
07:11
[fx] menu close button: size doesn’t look good on Firefox check-in: 1617b4806b user: olr tags: FixWebext, fx
Changes

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

47
48
49
50
51
52
53


54
55
56
57
58
59
60
..
87
88
89
90
91
92
93



























94
95
96
97
98
99
100
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
    oTFPanel: null,
    oLxgPanel: null,
    oGCPanel: null,

    oMessageBox: null,

    xRightClickedNode: null,



    listenRightClick: function () {
        // Node where a right click is done
        // Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
        document.addEventListener('contextmenu', function (xEvent) {
            this.xRightClickedNode = xEvent.target;
        }.bind(this), true);
................................................................................
                for (let xNode of document.querySelectorAll("[contenteditable]")) {
                    this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
                    this.nMenu += 1;
                }
            }
        }
    },




























    rescanPage: function () {
        if (this.oTFPanel !== null) { this.oTFPanel.hide(); }
        if (this.oLxgPanel !== null) { this.oLxgPanel.hide(); }
        if (this.oGCPanel !== null) { this.oGCPanel.hide(); }
        for (let oMenu of this.lMenu) {
            oMenu.deleteNodes();
................................................................................


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

/*
    When a textarea is added via jascript we add the menu :)
*/
let observer = 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 {
                    for (let xNode of mutation.addedNodes[i].getElementsByTagName("textarea")) {
                        oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, xNode));
                        oGrammalecte.nMenu += 1;
                    }
                }
            }
        }
    });
});
observer.observe(document.body, {
    childList: true,
    subtree: true
});







>
>







 







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







 







<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
323
324
325
326
327
328
329










330














    oTFPanel: null,
    oLxgPanel: null,
    oGCPanel: null,

    oMessageBox: null,

    xRightClickedNode: null,

    xObserver: null,

    listenRightClick: function () {
        // Node where a right click is done
        // Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
        document.addEventListener('contextmenu', function (xEvent) {
            this.xRightClickedNode = xEvent.target;
        }.bind(this), true);
................................................................................
                for (let xNode of document.querySelectorAll("[contenteditable]")) {
                    this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
                    this.nMenu += 1;
                }
            }
        }
    },

    observePage: function () {
        /*
            When a textarea is added via jascript we add the menu :)
        */
        let 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 {
                            for (let xNode of mutation.addedNodes[i].getElementsByTagName("textarea")) {
                                oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, xNode));
                                oGrammalecte.nMenu += 1;
                            }
                        }
                    }
                }
            });
        });
        this.xObserver.observe(document.body, {
            childList: true,
            subtree: true
        });
    },

    rescanPage: function () {
        if (this.oTFPanel !== null) { this.oTFPanel.hide(); }
        if (this.oLxgPanel !== null) { this.oLxgPanel.hide(); }
        if (this.oGCPanel !== null) { this.oGCPanel.hide(); }
        for (let oMenu of this.lMenu) {
            oMenu.deleteNodes();
................................................................................


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










oGrammalecte.observePage();