Grammalecte  Check-in [a7d3941648]

Overview
Comment:[fx] gc panel: autorefresh as option
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: a7d3941648b08a726a9048f2e20ac80be7e0a78c7a007d17e55b53744db09553
User & Date: olr on 2019-05-20 14:10:52
Other Links: manifest | tags
Context
2019-05-20
14:53
[fx] gc panel: prevent autorefresh after opening the tooltip check-in: 364440f87f user: olr tags: fx, trunk
14:10
[fx] gc panel: autorefresh as option check-in: a7d3941648 user: olr tags: fx, trunk
13:22
[fx] gc panel: refresh with blur event (not a so good idea?) check-in: e1f9580c26 user: olr tags: fx, trunk
Changes

Modified gc_lang/fr/webext/content_scripts/panel.css from [e93a7554f8] to [6a801a72c8].

   142    142       font-variant: small-caps;
   143    143       cursor: pointer;
   144    144       border-radius: 3px;
   145    145   }
   146    146   div.grammalecte_menu_button:hover {
   147    147       background-color: hsl(210, 80%, 40%);
   148    148   }
   149         -
          149  +div.grammalecte_autorefresh_button {
          150  +    display: inline-block;
          151  +    padding: 1px 5px;
          152  +    margin-left: 5px;
          153  +    border-radius: 3px;
          154  +    background-color: hsl(0, 50%, 50%);
          155  +    color: hsl(0, 50%, 96%);
          156  +    opacity: .7;
          157  +}
          158  +div.grammalecte_autorefresh_button:hover {
          159  +    opacity: 1;
          160  +}
   150    161   
   151    162   div.grammalecte_panel_content {
   152    163       /* https://stackoverflow.com/questions/7676022/html5-flexible-box-model-height-calculation/15388247#15388247 */
   153    164       position: relative;
   154    165       flex-grow: 1;
   155    166       overflow: auto;
   156    167   }

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [0205c3f57a] to [5417ae779f].

    57     57           this.xParagraphList = oGrammalecte.createNode("div", {id: "grammalecte_paragraph_list"});
    58     58           this.xGCPanelContent.appendChild(this.xParagraphList);
    59     59           this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false);
    60     60           this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent);
    61     61           this.xPanelContent.appendChild(this.xGCPanelContent);
    62     62           this.xNode = null;
    63     63           this.oTextControl = new GrammalecteTextControl();
           64  +        this.bAutoRefresh = false;
    64     65           // Lexicographer
    65     66           this.nLxgCount = 0;
    66     67           this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
    67     68           this.xPanelContent.appendChild(this.xLxgPanelContent);
    68     69           // Conjugueur
    69     70           this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"});
    70     71           this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML;  // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js>
................................................................................
    76     77       createMenu () {
    77     78           this.xMenu = oGrammalecte.createNode("div", {className: "grammalecte_panel_menu"});
    78     79           this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"});
    79     80           this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"});
    80     81           this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"});
    81     82           this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"});
    82     83           this.xLEButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "•Éditeur lexical•"});
           84  +        this.xAutoRefresh = oGrammalecte.createNode("div", {className: "grammalecte_autorefresh_button", textContent: "AR", title: "Auto-rafraîchissement de la correction grammaticale"})
           85  +        this.xEditorButton.appendChild(this.xAutoRefresh);
    83     86           this.xTFButton.onclick = () => {
    84     87               if (!this.bWorking) {
    85     88                   oGrammalecte.createTFPanel();
    86     89                   oGrammalecte.oTFPanel.start();
    87     90                   oGrammalecte.oTFPanel.show();
    88     91               }
    89     92           };
    90     93           this.xEditorButton.onclick = () => {
    91     94               if (!this.bWorking) {
    92     95                   this.showEditor();
    93     96               }
    94     97           };
           98  +        this.xAutoRefresh.onclick = () => {
           99  +            console.log("autor");
          100  +            this.bAutoRefresh = !this.bAutoRefresh;
          101  +            this.xAutoRefresh.style.backgroundColor = (this.bAutoRefresh) ? "hsl(150, 50%, 50%)" : "";
          102  +            this.xAutoRefresh.style.color = (this.bAutoRefresh) ? "hsl(150, 50%, 96%)" : "";
          103  +            this.xAutoRefresh.style.opacity = (this.bAutoRefresh) ? "1" : "";
          104  +            console.log("on");
          105  +        }
    95    106           this.xLxgButton.onclick = () => {
    96    107               if (!this.bWorking) {
    97    108                   this.showLexicographer();
    98    109                   this.clearLexicographer();
    99    110                   this.startWaitIcon();
   100    111                   xGrammalectePort.postMessage({
   101    112                       sCommand: "getListOfTokens",
................................................................................
   213    224                   xActionsBar.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_check" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_green", textContent: "↻", title: "Réanalyser…"}, {para_num: oResult.iParaNum}));
   214    225                   xActionsBar.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_hide" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_red", textContent: "×", title: "Cacher", style: "font-weight: bold;"}));
   215    226                   // paragraph
   216    227                   let xParagraph = oGrammalecte.createNode("p", {id: "grammalecte_paragraph"+oResult.iParaNum, className: "grammalecte_paragraph", lang: "fr", contentEditable: "true"}, {para_num: oResult.iParaNum});
   217    228                   xParagraph.setAttribute("spellcheck", "false"); // doesn’t seem possible to use “spellcheck” as a common attribute.
   218    229                   xParagraph.dataset.timer_id = "0";
   219    230                   xParagraph.addEventListener("input", function (xEvent) {
   220         -                    // timer for refreshing analysis
   221         -                    window.clearTimeout(parseInt(xParagraph.dataset.timer_id));
   222         -                    xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum);
   223         -                    // save caret position
   224         -                    let [nStart, nEnd] = oGrammalecte.getCaretPosition(xParagraph);
   225         -                    xParagraph.dataset.caret_position_start = nStart;
   226         -                    xParagraph.dataset.caret_position_end = nEnd;
          231  +                    if (this.bAutoRefresh) {
          232  +                        // timer for refreshing analysis
          233  +                        window.clearTimeout(parseInt(xParagraph.dataset.timer_id));
          234  +                        xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum);
          235  +                        // save caret position
          236  +                        let [nStart, nEnd] = oGrammalecte.getCaretPosition(xParagraph);
          237  +                        xParagraph.dataset.caret_position_start = nStart;
          238  +                        xParagraph.dataset.caret_position_end = nEnd;
          239  +                    }
   227    240                       // write text
   228    241                       this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num), this.purgeText(xEvent.target.textContent));
   229    242                       this.oTextControl.write();
   230    243                   }.bind(this)
   231    244                   , true);
   232    245                   /*xParagraph.addEventListener("blur", function (xEvent) {
   233    246                       // remove timer for refreshing analysis