Grammalecte  Check-in [b300065d85]

Overview
Comment:[fx] text formatter update
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext2
Files: files | file ages | folders
SHA3-256: b300065d8526f5ec6d0e7de61be7e2621eb7aef377e905d1b2025c941311f9f9
User & Date: olr on 2017-08-23 16:43:07
Other Links: branch diff | manifest | tags
Context
2017-08-24
11:28
[fx] text formatter update check-in: ab1793ecaf user: olr tags: fx, webext2
2017-08-23
16:43
[fx] text formatter update check-in: b300065d85 user: olr tags: fx, webext2
12:22
[fx] panels size adjustments check-in: 905fe07ad2 user: olr tags: fx, webext2
Changes

Modified gc_lang/fr/webext/content_scripts/content_modifier.js from [7906b3873c] to [8ce1a9bdc9].

111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125







-
+







function createTFPanel (xTextArea) {
    console.log("Formateur de texte");
    if (oTFPanel !== null) {
        oTFPanel.setTextArea(xTextArea);
        oTFPanel.show();
    } else {
        // create the panel
        oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 800, 600, false);
        oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 800, 620, false);
        oTFPanel.logInnerHTML();
        oTFPanel.setTextArea(xTextArea);
        oTFPanel.insertIntoPage();
    }
}

function createLxgPanel () {

Modified gc_lang/fr/webext/content_scripts/panels_content.js from [0c67b192c0] to [df3e50c05e].

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
65
66
67
68
69
70
71




72
73
74
75
76
77
78







-
-
-
-








    _createCloseButton () {
        let xButton = createNode("div", {className: "grammalecte_close_button", textContent: "×", title: "Fermer la fenêtre"});
        xButton.onclick = function () { this.hide(); }.bind(this);  // better than writing “let that = this;” before the function?
        return xButton;
    }

    setContentNode (xNode) {
        this.xPanelContent.appendChild(xNode);
    }

    insertIntoPage () {
        document.body.appendChild(this.xPanelNode);
    }

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

Modified gc_lang/fr/webext/content_scripts/tf_content.css from [c791976474] to [bf8f75e407].

1
2






3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1

2
3
4
5
6
7
8
9
10
11
12




13
14
15
16
17
18
19

-
+
+
+
+
+
+





-
-
-
-







/*
    Text Formatter
    CSS for the Text Formatter
*/


/*
    Options
*/
#grammalecte_tf_options {
    display: flex;
    padding: 10px;
}
#grammalecte_tf_options .underline:hover {
    background-color: hsl(210, 10%, 86%);
    border-radius: 2px;
}
.grammalecte_tf_column {
    flex-grow: 1;
    width: 360px;
    padding: 0 5px;
}
#grammalecte_tf_options legend label {
    font-size: 20px;
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
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
59
60
61
62
63
64
65
66



67
68
69
70
71
72
73
74
75
76







+
+
+
+
+
+
+
+



-
+


+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
+
+
+







}
#grammalecte_tf_options legend .option {
    margin: 7px 5px 0 4px;
    float: left;
}
#grammalecte_tf_options label {
    font-size: 13px;
}
#grammalecte_tf_options .underline:hover {
    background-color: hsl(210, 10%, 86%);
    border-radius: 2px;
}
#grammalecte_tf_options .blockopt .option {
    margin: 4px 5px 0 6px;
    float: left;
}
#grammalecte_tf_options .grammalecte_tf_result {
    float: right;
    margin-right: 3px;
    margin: 2px 3px 0 0;
    font-size: 13px;
}
#grammalecte_tf_options .indent {
    padding-left: 20px;

}
#grammalecte_tf_options .inlineblock {
    display: inline-block;
    margin-right: 10px;
}
#grammalecte_tf_options .rmg10 {
    margin-right: 10px;
}



/*
    Actions
*/
#grammalecte_tf_actions {
    background-color: hsl(120, 10%, 92%);
    padding: 15px;
    border-top: 1px solid hsl(120, 20%, 86%);
    /*background-color: hsl(120, 10%, 92%);*/
    padding: 15px 15px 10px 15px;
    border-top: 1px solid hsl(210, 10%, 90%);
}

.grammalecte_button {
    display: inline-block;
    padding: 5px 10px;
    width: 100px;
    border-radius: 3px;

Modified gc_lang/fr/webext/content_scripts/tf_content.js from [8d3cbce0ee] to [91cc95e53d].

56
57
58
59
60
61
62

63
64
65
66
67
68
69
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70







+







            xTypo.appendChild(this._createRadioBoxLigatures());
            xTypo.appendChild(this._createLigaturesSelection());
            let xMisc = this._createFieldset("group_misc", true, "Divers");
            xMisc.appendChild(this._createSimpleOption("o_ordinals_no_exponant", true, "Ordinaux (15e, XXIe…)"));
            xMisc.appendChild(this._createSimpleOption("o_etc", true, "Et cætera, etc."));
            xMisc.appendChild(this._createSimpleOption("o_missing_hyphens", true, "Traits d’union manquants"));
            xMisc.appendChild(this._createSimpleOption("o_ma_word", true, "Apostrophes manquantes"));
            xMisc.appendChild(this._createSingleLetterOptions());
            let xStruct = this._createFieldset("group_struct", false, "Restructuration [!]");
            xStruct.appendChild(this._createSimpleOption("o_remove_hyphens_at_end_of_paragraphs", false, "Enlever césures en fin de ligne/paragraphe [!]"));
            xStruct.appendChild(this._createSimpleOption("o_merge_contiguous_paragraphs", false, "Fusionner les paragraphes contigus [!]"));
            xColumn1.appendChild(xSSP);
            xColumn1.appendChild(xSpace);
            xColumn1.appendChild(xNBSP);
            xColumn1.appendChild(xDelete);
80
81
82
83
84
85
86
87
88
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
130
131
132
133
134
135
136




137
138
139
140
141
142
143
144
145
146
147
148








149
150
151









152
153


154







155
156
157
158

159








160
161


162









































163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
81
82
83
84
85
86
87

88
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








130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149


150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171
172


173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229










230







-





-
-
+
-










-
-
-
-
-
+
+
+
+
+


-
-
-
+
-

-
+
-
-
+
-
-
+



-
-
-
+
-


-
-
-
-
-
+
+
+
+




-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+



+
+
+
+
+
+
+
+
+
-
-
+
+

+
+
+
+
+
+
+



-
+

+
+
+
+
+
+
+
+
-
-
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+













-
-
-
-
-
-
-
-
-
-

            xActions.appendChild(createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_button", style: "background-color: hsl(180, 50%, 50%)"}));
            //xActions.appendChild(createNode("div", {id: "grammalecte_infomsg", textContent: "blabla"}));
            // create result
            xTFNode.appendChild(xOptions);
            xTFNode.appendChild(xActions);
        }
        catch (e) {
            //console.error(e);
            showError(e);
        }
        return xTFNode;
    }

    /*
        Common options
    // Common options
    */
    _createFieldset (sId, bDefault, sLabel) {
        let xFieldset = createNode("fieldset", {id: sId, className: "groupblock"});
        let xLegend = document.createElement("legend");
        xLegend.appendChild(createNode("input", {type: "checkbox", id: "o_"+sId, className: "option"}, {default: bDefault}));
        xLegend.appendChild(createNode("label", {htmlFor: "o_"+sId, textContent: sLabel}));
        xFieldset.appendChild(xLegend);
        return xFieldset;
    }

    _createSimpleOption (sId, bDefault, sLabel) {
        let xOption = createNode("div", {className: "blockopt underline"});
        xOption.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault}));
        xOption.appendChild(createNode("label", {htmlFor: sId, textContent: sLabel, className: "opt_lbl largew"}));
        xOption.appendChild(createNode("div", {id: "res_"+sId, className: "grammalecte_tf_result", textContent: "9999"}));
        return xOption;
        let xLine = createNode("div", {className: "blockopt underline"});
        xLine.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault}));
        xLine.appendChild(createNode("label", {htmlFor: sId, textContent: sLabel, className: "opt_lbl largew"}));
        xLine.appendChild(createNode("div", {id: "res_"+sId, className: "grammalecte_tf_result", textContent: "9999"}));
        return xLine;
    }


    /*
        Hyphens
    // Hyphens
    */
    _createRadioBoxHyphens (sName, sIdEmDash, sIdEnDash, bDefaultEmDash) {
        let xLine = createNode("div", {className: "blockopt"});
        let xLine = createNode("div", {className: "blockopt indent"});
        xLine.appendChild(createNode("input", {type: "radio", id: sIdEmDash, name: sName, className:"option"}, {default: bDefaultEmDash}));
        xLine.appendChild(createNode("label", {htmlFor: sIdEmDash, className: "opt_lbl", textContent: "cadratin (—)"}));
        xLine.appendChild(this._createInlineRadioOption(sName, sIdEmDash, "cadratin (—)", bDefaultEmDash));
        xLine.appendChild(createNode("input", {type: "radio", id: sIdEnDash, name: sName, className:"option"}, {default: !bDefaultEmDash}));
        xLine.appendChild(createNode("label", {htmlFor: sIdEnDash, className: "opt_lbl", textContent: "demi-cadratin ()"}));
        xLine.appendChild(this._createInlineRadioOption(sName, sIdEnDash, "demi-cadratin ()", !bDefaultEmDash));
        return xLine;
    }


    /*
        Ligatures
    // Ligatures
    */
    _createRadioBoxLigatures () {
        let xLine = createNode("div", {className: "blockopt underline"});
        xLine.appendChild(this._createSimpleOption("o_ts_ligature", true, "Ligatures"));
        xLine.appendChild(createNode("input", {type: "radio", id: "o_ts_ligature_do", name: "liga", className:"option"}, {default: false}));
        xLine.appendChild(createNode("label", {htmlFor: "o_ts_ligature_do", className: "opt_lbl", textContent: "faire"}));
        xLine.appendChild(createNode("input", {type: "radio", id: "o_ts_ligature_undo", name: "liga", className:"option"}, {default: true}));
        xLine.appendChild(createNode("label", {htmlFor: "o_ts_ligature_undo", className: "opt_lbl", textContent: "défaire"}));
        xLine.appendChild(createNode("div", {id: "res_"+"o_ts_ligature", className: "grammalecte_tf_result", textContent: "9999"}));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature", "Ligatures", true));
        xLine.appendChild(this._createInlineRadioOption("liga", "o_ts_ligature_do", "faire", false));
        xLine.appendChild(this._createInlineRadioOption("liga", "o_ts_ligature_undo", "défaire", true));
        return xLine;
    }

    _createLigaturesSelection () {
        let xLine = createNode("div", {className: "blockopt"});
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_ff", "ff", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_fi", "fi", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_ffi", "ffi", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_fl", "fl", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_ffl", "ffl", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_ft", "ft", true));
        xLine.appendChild(this._createLigatureCheckboxAndLabel("o_ts_ligature_st", "st", false));
        let xLine = createNode("div", {className: "blockopt indent"});
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_ff", "ff", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_fi", "fi", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_ffi", "ffi", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_fl", "fl", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_ffl", "ffl", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_ft", "ft", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ts_ligature_st", "st", false));
        return xLine;
    }

    // Apostrophes
    _createSingleLetterOptions () {
        let xLine = createNode("div", {className: "blockopt indent"});
        xLine.appendChild(this._createInlineCheckboxOption("o_ma_1letter_lowercase", "lettres isolées (j’ n’ m’ t’ s’ c’ d’ l’)", false));
        xLine.appendChild(this._createInlineCheckboxOption("o_ma_1letter_uppercase", "Maj.", false));
        return xLine;
    }

    // Inline option block
    _createLigatureCheckboxAndLabel (sId, sLabel, bDefault) {
        let xInlineBlock = createNode("div", {style: "display: inline-block;"});
    _createInlineCheckboxOption (sId, sLabel, bDefault) {
        let xInlineBlock = createNode("div", {className: "inlineblock"});
        xInlineBlock.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault}));
        xInlineBlock.appendChild(createNode("label", {htmlFor: sId, textContent: sLabel, className: "opt_lbl"}));
        return xInlineBlock;
    }

    _createInlineRadioOption (sName, sId, sLabel, bDefault) {
        let xInlineBlock = createNode("div", {className: "inlineblock"});
        xInlineBlock.appendChild(createNode("input", {type: "radio", id: sId, name: sName, className:"option"}, {default: bDefault}));
        xInlineBlock.appendChild(createNode("label", {htmlFor: sId, className: "opt_lbl", textContent: sLabel}));
        return xInlineBlock;
    }
}


    /*
        Actions
    */
    switchGroup (sOptName) {
        if (document.getElementById(sOptName).checked) {
            document.getElementById(sOptName.slice(2)).style.opacity = 1;
        } else {
            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;
    

        }
    }


    reset () {
        this.resetProgressBar();
        for (let xNode of document.getElementsByClassName("option")) {
            xNode.checked = (xNode.dataset.default === "true");
            if (xNode.id.startsWith("o_group_")) {
                switchGroup(xNode.id);
            }
        }
    }

    resetProgressBar () {
        document.getElementById('progressbar').value = 0;
        document.getElementById('time_res').textContent = "";
    }

    setOptions (oOptions) {
        for (let sOptName in oOptions) {
            //console.log(sOptName + ":" + oOptions[sOptName]);
            if (document.getElementById(sOptName) !== null) {
                document.getElementById(sOptName).checked = oOptions[sOptName];
                if (sOptName.startsWith("o_group_")) {
                    switchGroup(sOptName);
                } 
                if (document.getElementById("res_"+sOptName) !== null) {
                    document.getElementById("res_"+sOptName).textContent = "";
                }
            }
        }
    }

    saveOptions () {
        let oOptions = {};
        for (let xNode of document.getElementsByClassName("option")) {
            oOptions[xNode.id] = xNode.checked;
        }
        self.port.emit("saveOptions", JSON.stringify(oOptions));
    }


}


let sTFinnerHTML = ' \
<!-- Misc --> \
    <div class="blockopt underline"> \
      <div id="res_o_ordinals_no_exponant" class="result fright"></div> \
      <input type="checkbox" id="o_ordinals_no_exponant" class="option" data-default="true" /> \
      <label for="o_ordinals_no_exponant" class="opt_lbl reducedw" data-l10n-en="tf_ordinals_no_exponant">${tf_ordinals_no_exponant}</label> \
      <div class="secondoption"> \
        <input type="checkbox" id="o_ordinals_exponant" class="option" data-default="true" /> \
        <label for="o_ordinals_exponant" class="opt_lbl smallw" data-l10n-en="tf_ordinals_exponant">${tf_ordinals_exponant}</label> \
      </div> \
    </div> \
    <div class="blockopt"> \
      <div class="inlineblock indent"> \
        <input type="checkbox" id="o_ma_1letter_lowercase" class="option" /> \
        <label for="o_ma_1letter_lowercase" class="opt_lbl" data-l10n-en="tf_ma_1letter_lowercase">${tf_ma_1letter_lowercase}</label> \
      </div> \
      <div class="inlineblock indent"> \
        <input type="checkbox" id="o_ma_1letter_uppercase" class="option" /> \
        <label for="o_ma_1letter_uppercase" class="opt_lbl" data-l10n-en="tf_ma_1letter_uppercase">${tf_ma_1letter_uppercase}</label> \
      </div> \
    </div> \
';