Grammalecte  Check-in [35b97b66b5]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[fx] observePage update: don’t add menu if option.textarea doesn’t require it
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256:35b97b66b5e07d80fb59027c6853cef67048f4f24f8eb43b36054d3214fca3b0
User & Date: olr 2019-02-13 20:03:29
Context
2019-02-14
07:18
[fr] faux positif check-in: 2f8140be90 user: olr tags: fr, trunk
2019-02-13
21:37
merge trunk check-in: 12dd6264d6 user: olr tags: comdic
20:03
[fx] observePage update: don’t add menu if option.textarea doesn’t require it check-in: 35b97b66b5 user: olr tags: fx, trunk
11:22
[fr] faux positif check-in: 4cae5ae88c user: olr tags: fr, trunk
Changes

Changes to gc_lang/fr/webext/content_scripts/init.js.

    55     55       oMessageBox: null,
    56     56   
    57     57       xRightClickedNode: null,
    58     58   
    59     59       xObserver: null,
    60     60   
    61     61       sExtensionUrl: null,
           62  +
           63  +    oOptions: null,
    62     64   
    63     65       listenRightClick: function () {
    64     66           // Node where a right click is done
    65     67           // Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1325814
    66     68           document.addEventListener('contextmenu', function (xEvent) {
    67     69               this.xRightClickedNode = xEvent.target;
    68     70           }.bind(this), true);
................................................................................
    76     78           if (bChrome) {
    77     79               browser.storage.local.get("ui_options", this._createMenus.bind(this));
    78     80               return;
    79     81           }
    80     82           browser.storage.local.get("ui_options").then(this._createMenus.bind(this), showError);
    81     83       },
    82     84   
    83         -    _createMenus: function (dOptions) {
    84         -        if (dOptions.hasOwnProperty("ui_options")) {
    85         -            dOptions = dOptions.ui_options;
    86         -            if (dOptions.textarea) {
           85  +    _createMenus: function (oOptions) {
           86  +        if (oOptions.hasOwnProperty("ui_options")) {
           87  +            this.oOptions = oOptions.ui_options;
           88  +            if (this.oOptions.textarea) {
    87     89                   for (let xNode of document.getElementsByTagName("textarea")) {
    88     90                       if (xNode.style.display !== "none" && xNode.style.visibility !== "hidden" && xNode.getAttribute("spellcheck") !== "false") {
    89     91                           this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
    90     92                           this.nMenu += 1;
    91     93                       }
    92     94                   }
    93     95               }
    94         -            if (dOptions.editablenode) {
           96  +            if (this.oOptions.editablenode) {
    95     97                   for (let xNode of document.querySelectorAll("[contenteditable]")) {
    96     98                       this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode));
    97     99                       this.nMenu += 1;
    98    100                   }
    99    101               }
   100    102           }
   101    103       },
................................................................................
   104    106           /*
   105    107               When a textarea is added via jascript we add the menu :)
   106    108           */
   107    109           this.xObserver = new MutationObserver(function (mutations) {
   108    110               mutations.forEach(function (mutation) {
   109    111                   for (let i = 0;  i < mutation.addedNodes.length;  i++){
   110    112                       if (mutation.addedNodes[i].tagName == "TEXTAREA") {
   111         -                        oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, mutation.addedNodes[i]));
   112         -                        oGrammalecte.nMenu += 1;
          113  +                        if (this.oOptions === null || this.oOptions.textarea) {
          114  +                            oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, mutation.addedNodes[i]));
          115  +                            oGrammalecte.nMenu += 1;
          116  +                        }
   113    117                       } else if (mutation.addedNodes[i].getElementsByTagName) {
   114         -                        for (let xNode of mutation.addedNodes[i].getElementsByTagName("textarea")) {
   115         -                            oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, xNode));
   116         -                            oGrammalecte.nMenu += 1;
          118  +                        if (this.oOptions === null || this.oOptions.textarea) {
          119  +                            for (let xNode of mutation.addedNodes[i].getElementsByTagName("textarea")) {
          120  +                                oGrammalecte.lMenu.push(new GrammalecteMenu(oGrammalecte.nMenu, xNode));
          121  +                                oGrammalecte.nMenu += 1;
          122  +                            }
   117    123                           }
   118    124                       }
   119    125                   }
   120    126               });
   121    127           });
   122    128           this.xObserver.observe(document.body, {
   123    129               childList: true,