Grammalecte  Check-in [28cb4e344d]

Overview
Comment:[fx] WebExt: try to protect elements from CSS inheritance (text formatter)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 28cb4e344d67842ff0f10e8094e30a080e150183195bb12756089d8e7f62a2d4
User & Date: olr on 2017-09-02 18:09:16
Other Links: manifest | tags
Context
2017-09-02
18:52
[fx] WebExt: try to protect elements from CSS inheritance (lexicographer) check-in: ae3c05dd2b user: olr tags: trunk, fx
18:09
[fx] WebExt: try to protect elements from CSS inheritance (text formatter) check-in: 28cb4e344d user: olr tags: trunk, fx
11:58
[fx] WebExt: CSS: set panel properties to avoid overriding from the page check-in: 7674a70414 user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/webext/background.js from [d5244ca895] to [1909d2976b].

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
188
189
190
191
192
193
194

195
196
197
198
199
200
201







-







    contexts: ["all"]
});


browser.contextMenus.onClicked.addListener(function (xInfo, xTab) {
    // xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData
    // xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab
    
    // confusing: no way to get the node where we click?!
    switch (xInfo.menuItemId) {
        case "parseAndSpellcheck":
            parseAndSpellcheckSelectedText(xTab.id, xInfo.selectionText);
            break;
        case "getListOfTokens": 
            getListOfTokensFromSelectedText(xTab.id, xInfo.selectionText);

Modified gc_lang/fr/webext/content_scripts/panel_tf.css from [d4ccdba870] to [50d005a5ba].

1
2
3
4
5
6
7
8
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
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
77
78
79
80
81
1
2
3
4
5
6
7
8
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
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
77
78
79
80
81











+







+
+






-
+




-
+




+
+


-
+



-
+



-
+




-
+


-
+



-
-
-
-






-






-
+







/*
    CSS for the Text Formatter
*/


/*
    Options
*/
#grammalecte_tf_options {
    display: flex;
    padding: 10px;
    color: hsl(0, 0%, 0%);
}
.grammalecte_tf_column {
    flex-grow: 1;
    width: 360px;
    padding: 0 5px;
}
#grammalecte_tf_options legend label {
    margin: 0;
    padding: 0;
    font-size: 20px;
    color: hsla(210, 20%, 50%, .8);
    font-weight: bold;
}
#grammalecte_tf_options fieldset {
    padding: 2px 10px 10px 13px;
    margin-bottom: 5px;
    margin: 0 0 5px 0;
    background-color: hsl(210, 10%, 96%);
    border-color: hsl(210, 20%, 80%);
    border-radius: 3px;
}
#grammalecte_tf_options legend .option {
#grammalecte_tf_options legend .grammalecte_tf_option {
    margin: 7px 5px 0 4px;
    float: left;
}
#grammalecte_tf_options label {
    margin: 0;
    padding: 0;
    font-size: 13px;
}
#grammalecte_tf_options .underline:hover {
.grammalecte_tf_underline:hover {
    background-color: hsl(210, 10%, 86%);
    border-radius: 2px;
}
#grammalecte_tf_options .blockopt .option {
.grammalecte_tf_blockopt .grammalecte_tf_option {
    margin: 4px 5px 0 6px;
    float: left;
}
#grammalecte_tf_options .grammalecte_tf_result {
.grammalecte_tf_result {
    float: right;
    margin: 2px 3px 0 0;
    font-size: 13px;
}
#grammalecte_tf_options .indent {
.grammalecte_tf_indent {
    padding-left: 20px;
}
#grammalecte_tf_options .inlineblock {
.grammalecte_tf_inlineblock {
    display: inline-block;
    margin-right: 10px;
}
#grammalecte_tf_options .rmg10 {
    margin-right: 10px;
}



/*
    Actions
*/
#grammalecte_tf_actions {
    /*background-color: hsl(120, 10%, 92%);*/
    display: flex;
    justify-content: space-between;
    padding: 15px 15px 10px 15px;
    border-top: 1px solid hsl(210, 10%, 90%);
}

.grammalecte_button {
.grammalecte_tf_button {
    display: inline-block;
    padding: 5px 10px;
    width: 100px;
    border-radius: 3px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
99
100
101
102
103
104
105
106
107
108
109
110
99
100
101
102
103
104
105












-
-
-
-
-
#grammalecte_tf_apply {
    background-color: hsl(120, 50%, 50%);
    color: hsl(150, 0%, 100%);
}
#grammalecte_tf_apply:hover {
    background-color: hsl(120, 50%, 40%);
}

#grammalecte_progressbarbox {
    display: inline-block;
    padding: 10px 20px;
}

Modified gc_lang/fr/webext/content_scripts/panel_tf.js from [8051a1ef4c] to [e714ba0d98].

67
68
69
70
71
72
73
74

75
76

77
78
79
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
67
68
69
70
71
72
73

74
75

76
77
78
79
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







-
+

-
+




















-
+








-
-
+
+







-
+







-
+








-
+












-
+







-
+









-
-
+
+





-
-
+
+







            xColumn2.appendChild(xTypo);
            xColumn2.appendChild(xMisc);
            xColumn2.appendChild(xStruct);
            xOptions.appendChild(xColumn1);
            xOptions.appendChild(xColumn2);
            // Actions
            let xActions = createNode("div", {id: "grammalecte_tf_actions"});
            let xDefaultButton = createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_button"});
            let xDefaultButton = createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_tf_button"});
            xDefaultButton.addEventListener("click", () => { this.reset(); });
            let xApplyButton = createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_button"});
            let xApplyButton = createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_tf_button"});
            xApplyButton.addEventListener("click", () => { this.saveOptions(); this.apply(); });
            xActions.appendChild(xDefaultButton);
            xActions.appendChild(createNode("progress", {id: "grammalecte_tf_progressbar"}));
            xActions.appendChild(createNode("span", {id: "grammalecte_tf_time_res", textContent: "…"}));
            xActions.appendChild(xApplyButton);
            //xActions.appendChild(createNode("div", {id: "grammalecte_infomsg", textContent: "blabla"}));
            // create result
            xTFNode.appendChild(xOptions);
            xTFNode.appendChild(xActions);
        }
        catch (e) {
            showError(e);
        }
        return xTFNode;
    }

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

    _createSimpleOption (sId, bDefault, sLabel) {
        let xLine = createNode("div", {className: "blockopt underline"});
        xLine.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault}));
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"});
        xLine.appendChild(createNode("input", {type: "checkbox", id: sId, className: "grammalecte_tf_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: "·"}));
        return xLine;
    }

    // Hyphens
    _createRadioBoxHyphens (sName, sIdEmDash, sIdEnDash, bDefaultEmDash) {
        let xLine = createNode("div", {className: "blockopt indent"});
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"});
        xLine.appendChild(this._createInlineRadioOption(sName, sIdEmDash, "cadratin (—)", bDefaultEmDash));
        xLine.appendChild(this._createInlineRadioOption(sName, sIdEnDash, "demi-cadratin (—)", !bDefaultEmDash));
        return xLine;
    }

    // Ligatures
    _createRadioBoxLigatures () {
        let xLine = createNode("div", {className: "blockopt underline"});
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"});
        xLine.appendChild(createNode("div", {id: "res_"+"o_ts_ligature", className: "grammalecte_tf_result", textContent: "·"}));
        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 indent"});
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_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"});
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_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;
    }

    // Ordinals
    _createOrdinalOptions () {
        let xLine = createNode("div", {className: "blockopt underline"});
        let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"});
        xLine.appendChild(createNode("div", {id: "res_"+"o_ordinals_no_exponant", className: "grammalecte_tf_result", textContent: "·"}));
        xLine.appendChild(this._createInlineCheckboxOption("o_ordinals_no_exponant", "Ordinaux (15e, XXIe…)", true));
        xLine.appendChild(this._createInlineCheckboxOption("o_ordinals_exponant", "e → ᵉ", true));
        return xLine;
    }
    

    // Inline option block
    _createInlineCheckboxOption (sId, sLabel, bDefault) {
        let xInlineBlock = createNode("div", {className: "inlineblock"});
        xInlineBlock.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault}));
        let xInlineBlock = createNode("div", {className: "grammalecte_tf_inlineblock"});
        xInlineBlock.appendChild(createNode("input", {type: "checkbox", id: sId, className: "grammalecte_tf_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}));
        let xInlineBlock = createNode("div", {className: "grammalecte_tf_inlineblock"});
        xInlineBlock.appendChild(createNode("input", {type: "radio", id: sId, name: sName, className:"grammalecte_tf_option"}, {default: bDefault}));
        xInlineBlock.appendChild(createNode("label", {htmlFor: sId, className: "opt_lbl", textContent: sLabel}));
        return xInlineBlock;
    }


    /*
        Actions
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
231
232
233
234
235
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
231
232
233
234
235







-
+
















-
+













-
+







            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;
        }
        this.resetProgressBar();
    }

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

    resetProgressBar () {
        document.getElementById('grammalecte_tf_progressbar').value = 0;
        document.getElementById('grammalecte_tf_time_res').textContent = "";
    }

    setOptions (oOptions) {
        if (oOptions.hasOwnProperty("tf_options")) {
            oOptions = oOptions.tf_options;
        }
        for (let xNode of document.getElementsByClassName("option")) {
        for (let xNode of document.getElementsByClassName("grammalecte_tf_option")) {
            //console.log(xNode.id + " > " + oOptions.hasOwnProperty(xNode.id) + ": " + oOptions[xNode.id] + " [" + xNode.dataset.default + "]");
            xNode.checked = (oOptions.hasOwnProperty(xNode.id)) ? oOptions[xNode.id] : (xNode.dataset.default === "true");
            if (document.getElementById("res_"+xNode.id) !== null) {
                document.getElementById("res_"+xNode.id).textContent = "";
            }
            if (xNode.id.startsWith("o_group_")) {
                this.switchGroup(xNode.id);
            }
        }
    }

    saveOptions () {
        let oOptions = {};
        for (let xNode of document.getElementsByClassName("option")) {
        for (let xNode of document.getElementsByClassName("grammalecte_tf_option")) {
            oOptions[xNode.id] = xNode.checked;
            //console.log(xNode.id + ": " + xNode.checked);
        }
        browser.storage.local.set({"tf_options": oOptions});
    }

    apply () {