Index: gc_lang/fr/webext/content_scripts/panel_creator.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_creator.js +++ gc_lang/fr/webext/content_scripts/panel_creator.js @@ -115,37 +115,24 @@ /* Common functions */ -function createNode (sType, oAttr) { +function createNode (sType, oAttr, oDataset=null) { try { let xNode = document.createElement(sType); Object.assign(xNode, oAttr); + if (oDataset) { + Object.assign(xNode.dataset, oDataset); + } return xNode; } catch (e) { showError(e); } } -function createCheckbox (sId, bDefault, sClass="") { - let xInput = document.createElement("input"); - xInput.type = "checkbox"; - xInput.id = sId; - xInput.className = sClass; - xInput.dataset.default = bDefault; - return xInput; -} - -function createLabel (sForId, sLabel, sClass="") { - let xLabel = document.createElement("label"); - xLabel.setAttribute("for", sForId); - xLabel.textContent = sLabel; - return xLabel; -} - function createLogo () { let xImg = document.createElement("img"); xImg.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAC8UlEQVQ4jX3TbUgTcRwH8P89ddu5u9tt082aZmpFEU4tFz0QGTUwCi0heniR9MSUIKRaD0RvIlKigsooo+iNFa0XJYuwIjEK19OcDtPElsG0ktyp591t7u7+vUh7MPX3+vf5/n8/+P0BmKJIPUUVlh2rdVVeesWlzEybqg+bFOsoylnqPmNavGFfknV2Omu2Lvja3vxAURKJib3opHizu8riLK6gjRyuKgmoSoMRFENRUqfXTzvBGK62LC2uoFkOl4RhjQ8+qWt7dPNE3sbdp+2LXbsGe9qb4rIo/BfwFy6nWQ4ThWGNDzbcfu29dMDh2nHU7CypYNLmzTda0/L5cNuzmDQi/A4Y27k6eQxLI79wS/11D0AAMNvs6XT6ojVJjJEgTbMy2BT77xBMp09KcpaWV1uc41jQoi0NdUHfjeOO9WWn7AVF7s7n986SithPJGeupBh2PCSP/xxqxAp3eq6wuUV7Wc6MSZIEhA8vHjbfOe/OcW3zmAuKy+nUzAyD2bow8ODaEROFq8AyZ5WBYdEZXGqGxZ61HJV+9HYCJRbTNA0QBA40HWunaKN5dKg/DBKxeCIe09Th/m4MJwiMSZmLEzMQAABQRuNqgu8NYX3doTcMpvCkLbtQZ2AJkrPOZG1zlnY13T+Hy9EehY90h57eqcorcZ/lctZuMzAsOjLEqwNv66/6vZcPYRBC+C3cGaBxhSet2av1BpYgTTY7k5y2JPT41slIR6Axv8R9nnOs+4Pf+2r992uOxGVJwgAAAEINfgt3BGgsESWtWas1iGDyl+CT/u7WpvxNFRc4x7qtBoZFhSFejb7z1fq9NYfjsiT+cwcQavBruCOgU4SIGo18amuoq3Js3FNlynVtH385+s53ze+t8cRkURx3yMTTRBAEQVAUXbFlf3XystJKA2NExeFBdWASDAAA+MQACCEEmqbJ0b6PMC7JwhDU8YFHV5u9NZ64LErT/oW/63tPV6uJwmKoOND78u7Fg5NhAAD4CVbzY9cwrWQrAAAAAElFTkSuQmCC"; return xImg; } Index: gc_lang/fr/webext/content_scripts/text_formatter.js ================================================================== --- gc_lang/fr/webext/content_scripts/text_formatter.js +++ gc_lang/fr/webext/content_scripts/text_formatter.js @@ -31,15 +31,18 @@ let xColumn2 = createNode("div", {className: "grammalecte_tf_column"}); let xTypo = createFieldset("group_typo", true, "Signes typographiques"); xTypo.appendChild(createOptionInputAndLabel("o_ts_apostrophe", true, "Apostrophe (’)")); xTypo.appendChild(createOptionInputAndLabel("o_ts_ellipsis", true, "Points de suspension (…)")); xTypo.appendChild(createOptionInputAndLabel("o_ts_dash_middle", true, "Tirets d’incise :")); + xTypo.appendChild(createRadioBoxHyphens("hyphen1", "o_ts_m_dash_middle", "o_ts_n_dash_middle", false)); xTypo.appendChild(createOptionInputAndLabel("o_ts_dash_start", true, "Tirets en début de paragraphe :")); + xTypo.appendChild(createRadioBoxHyphens("hyphen2", "o_ts_m_dash_start", "o_ts_n_dash_start", true)); xTypo.appendChild(createOptionInputAndLabel("o_ts_quotation_marks", true, "Modifier les guillemets droits (\" et ')")); xTypo.appendChild(createOptionInputAndLabel("o_ts_units", true, "Points médians des unités (N·m, Ω·m…)")); xTypo.appendChild(createOptionInputAndLabel("o_ts_spell", true, "Ligatures (cœur…) et diacritiques (ça, État…)")); - xTypo.appendChild(createOptionInputAndLabel("o_ts_ligature", true, "Ligatures")); + xTypo.appendChild(createRadioBoxLigatures()); + xTypo.appendChild(createLigaturesSelection()); let xMisc = createFieldset("group_misc", true, "Divers"); xMisc.appendChild(createOptionInputAndLabel("o_ordinals_no_exponant", true, "Ordinaux (15e, XXIe…)")); xMisc.appendChild(createOptionInputAndLabel("o_etc", true, "Et cætera, etc.")); xMisc.appendChild(createOptionInputAndLabel("o_missing_hyphens", true, "Traits d’union manquants")); xMisc.appendChild(createOptionInputAndLabel("o_ma_word", true, "Apostrophes manquantes")); @@ -71,252 +74,88 @@ showError(e); } return xTFNode; } + +/* + Common options +*/ function createFieldset (sId, bDefault, sLabel) { let xFieldset = createNode("fieldset", {id: sId, className: "groupblock"}); let xLegend = document.createElement("legend"); - let xInput = createCheckbox("o_"+sId, bDefault, "option"); - let xLabel = createLabel(xInput.id, sLabel); - // create result - xLegend.appendChild(xInput); - xLegend.appendChild(xLabel); + 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; } function createOptionInputAndLabel (sId, bDefault, sLabel) { let xOption = createNode("div", {className: "blockopt underline"}); - let xInput = createCheckbox(sId, bDefault, "option"); - let xLabel = createLabel(sId, sLabel, "opt_lbl largew"); - let xResult = createNode("div", {id: "res_"+sId, className: "grammalecte_tf_result", textContent: "9999"}); - // create result - xOption.appendChild(xResult); - xOption.appendChild(xInput); - xOption.appendChild(xLabel); + 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; } + +/* + Hyphens +*/ +function createRadioBoxHyphens (sName, sIdEmDash, sIdEnDash, bDefaultEmDash) { + let xLine = createNode("div", {className: "blockopt"}); + 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(createNode("input", {type: "radio", id: sIdEnDash, name: sName, className:"option"}, {default: !bDefaultEmDash})); + xLine.appendChild(createNode("label", {htmlFor: sIdEnDash, className: "opt_lbl", textContent: "demi-cadratin (–)"})); + return xLine; +} + + +/* + Ligatures +*/ +function createRadioBoxLigatures () { + let xLine = createNode("div", {className: "blockopt underline"}); + xLine.appendChild(createOptionInputAndLabel("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"})); + return xLine; +} + +function createLigaturesSelection () { + let xLine = createNode("div", {className: "blockopt"}); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_ff", "ff", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_fi", "fi", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_ffi", "ffi", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_fl", "fl", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_ffl", "ffl", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_ft", "ft", true)); + xLine.appendChild(createLigatureCheckboxAndLabel("o_ts_ligature_st", "st", false)); + return xLine; +} + +function createLigatureCheckboxAndLabel (sId, sLabel, bDefault) { + let xInlineBlock = createNode("div", {style: "display: inline-block;"}); + xInlineBlock.appendChild(createNode("input", {type: "checkbox", id: sId, className: "option"}, {default: bDefault})); + xInlineBlock.appendChild(createNode("label", {htmlFor: sId, className: "opt_lbl", textContent: sLabel})); + return xInlineBlock; +} + let sTFinnerHTML = ' \ -

FORMATEUR DE TEXTE

\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ -
\ -
\ -  
\ -  
\ -  
\ -  
\ -  
\ -  
\ -
\ -
\ -
\ - \ \ -
\ - \ -
\
\
\ \ \
\ \ \
\
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\
\
\ \ \
\ @@ -323,34 +162,6 @@
\ \ \
\
\ -
\ -
\ - \ - \ -
\ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - \ -
\ -
Par défaut
\ -
Appliquer
\ -
\ - \ -
\ ';