Overview
Comment: | [fx] we can inject CSS in content-scripts -> drop inline style |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fx | webext2 |
Files: | files | file ages | folders |
SHA3-256: |
94fe28531548350636e026da53be0a90 |
User & Date: | olr on 2017-08-12 14:53:52 |
Other Links: | branch diff | manifest | tags |
Context
2017-08-12
| ||
14:55 | [fx] forgot to add the CSS file with the previous commit check-in: 9e033cb647 user: olr tags: fx, webext2 | |
14:53 | [fx] we can inject CSS in content-scripts -> drop inline style check-in: 94fe285315 user: olr tags: fx, webext2 | |
12:04 | [fx] panels ui improvement + image inline check-in: a974df14bb user: olr tags: fx, webext2 | |
Changes
Modified gc_lang/fr/webext/content_scripts/modify_page.js from [4865d913a8] to [7d090ec36f].
︙ | ︙ | |||
39 40 41 42 43 44 45 | xWrapper.style = "padding: 5px; color: hsl(210, 10%, 90%); background-color: hsl(210, 50%, 50%); border-radius: 3px;"; xWrapper.id = nWrapper + 1; nWrapper += 1; xParentElement.insertBefore(xWrapper, xTextArea); xWrapper.appendChild(xTextArea); // move textarea in wrapper let xToolbar = createWrapperToolbar(xTextArea); xWrapper.appendChild(xToolbar); | < | < < < < | 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 | xWrapper.style = "padding: 5px; color: hsl(210, 10%, 90%); background-color: hsl(210, 50%, 50%); border-radius: 3px;"; xWrapper.id = nWrapper + 1; nWrapper += 1; xParentElement.insertBefore(xWrapper, xTextArea); xWrapper.appendChild(xTextArea); // move textarea in wrapper let xToolbar = createWrapperToolbar(xTextArea); xWrapper.appendChild(xToolbar); } catch (e) { showError(e); } } let sButtonStyle = "display: inline-block; padding: 0 5px; margin-left: 5px; background-color: hsl(210, 50%, 60%); border-radius: 2px; cursor: pointer;"; function createWrapperToolbar (xTextArea) { try { let xToolbar = document.createElement("div"); xToolbar.style = "display: flex; justify-content: flex-end; margin-top: 5px; padding: 5px 10px;"; /*let xLogo = document.createElement("img"); xLogo.src = browser.extension.getURL("img/logo-16.png"); // can’t work, due to content-script policy: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027 xTitle.appendChild(xLogo);*/ xToolbar.appendChild(document.createTextNode("Grammalecte")); let xConjButton = document.createElement("div"); xConjButton.textContent = "Conjuguer"; xConjButton.style = sButtonStyle; xConjButton.onclick = function() { createConjPanel(); }; |
︙ | ︙ | |||
102 103 104 105 106 107 108 | function createConjPanel () { console.log("Conjugueur"); if (xConjPanel !== null) { xConjPanel.style.display = "block"; } else { // create the panel | | | | | | 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 | function createConjPanel () { console.log("Conjugueur"); if (xConjPanel !== null) { xConjPanel.style.display = "block"; } else { // create the panel xConjPanel = createPanelFrame("conj_panel", "Conjugueur"); document.body.appendChild(xConjPanel); } } function createTFPanel (xTextArea) { console.log("Formateur de texte"); if (xTFPanel !== null) { xTFPanel.style.display = "block"; } else { // create the panel xTFPanel = createPanelFrame("tf_panel", "Formateur de texte"); document.body.appendChild(xTFPanel); document.getElementById("tf_panel_content").appendChild(createTextFormatter(xTextArea)); } } function createLxgPanel (xTextArea) { console.log("Lexicographe"); if (xLxgPanel !== null) { xLxgPanel.style.display = "block"; } else { // create the panel xLxgPanel = createPanelFrame("lxg_panel", "Lexicographe"); document.body.appendChild(xLxgPanel); } } function createGCPanel (oErrors) { console.log("Correction grammaticale"); if (xGCPanel !== null) { xGCPanel.style.display = "block"; } else { // create the panel xGCPanel = createPanelFrame("gc_panel", "Correcteur"); document.body.appendChild(xGCPanel); document.getElementById("gc_panel_content").appendChild(document.createTextNode(JSON.stringify(oErrors))); } } /* |
︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/panel_creator.js from [16b43963ab] to [dcb12b523e].
1 2 3 4 5 6 | // JavaScript // Panel creator "use strict"; | | | < < < < | < | | | | < < < < < < | < | > | < | < < | > > > > | 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 | // JavaScript // Panel creator "use strict"; function createPanelFrame (sId, sTitle) { try { let xPanel = createNode("div", {id: sId, className: "grammalecte_panel"}); let xBar = createNode("div", {className: "grammalecte_title_bar"}); xBar.appendChild(createCloseButton(xPanel)); let xTitle = createNode("div", {className: "grammalecte_title"}); xTitle.appendChild(createLogo()); xTitle.appendChild(createNode("div", {className: "grammalecte_label", textContent: "Grammalecte · " + sTitle})); xBar.appendChild(xTitle); xPanel.appendChild(xBar); //xPanel.appendChild(createNode("div", {className: "grammalecte_empty_space_under_title_bar"})); xPanel.appendChild(createNode("div", {id: sId+"_content", className: "grammalecte_panel_content"})); return xPanel; } catch (e) { showError(e); } } function createCloseButton (xParentNode) { let xButton = document.createElement("div"); xButton.className = "grammalecte_close_button"; xButton.textContent = "×"; xButton.onclick = function () { xParentNode.style.display = "none"; } return xButton; } /* Common functions */ function createNode (sType, oAttr) { try { let xNode = document.createElement(sType); Object.assign(xNode, oAttr); 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; |
︙ | ︙ |
Modified gc_lang/fr/webext/content_scripts/text_formatter.js from [ad8781cf55] to [44d0e018ce].
1 2 3 4 5 6 7 8 9 | // JavaScript // Text formatter "use strict"; function createTextFormatter (xTextArea) { let xTFNode = document.createElement("div"); try { // Options | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // JavaScript // Text formatter "use strict"; function createTextFormatter (xTextArea) { let xTFNode = document.createElement("div"); try { // Options let xOptions = createNode("div", {id: "tf_options"}); let xSSP = createFieldset("group_ssp", true, "Espaces surnuméraires"); xSSP.appendChild(createOptionInputAndLabel("o_start_of_paragraph", true, "En début de paragraphe")); xSSP.appendChild(createOptionInputAndLabel("o_end_of_paragraph", true, "En fin de paragraphe")); xSSP.appendChild(createOptionInputAndLabel("o_between_words", true, "Entre les mots")); xSSP.appendChild(createOptionInputAndLabel("o_before_punctuation", true, "Avant les points (.), les virgules (,)")); xSSP.appendChild(createOptionInputAndLabel("o_within_parenthesis", true, "À l’intérieur des parenthèses")); xSSP.appendChild(createOptionInputAndLabel("o_within_square_brackets", true, "À l’intérieur des crochets")); |
︙ | ︙ | |||
48 49 50 51 52 53 54 | xOptions.appendChild(xSpace); xOptions.appendChild(xNBSP); xOptions.appendChild(xDelete); xOptions.appendChild(xTypo); xOptions.appendChild(xMisc); xOptions.appendChild(xStruct); // Actions | | | < | | | | | < < < | | | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | xOptions.appendChild(xSpace); xOptions.appendChild(xNBSP); xOptions.appendChild(xDelete); xOptions.appendChild(xTypo); xOptions.appendChild(xMisc); xOptions.appendChild(xStruct); // Actions let xActions = createNode("div", {id: "tf_actions"}); xActions.appendChild(createNode("div", {id: "tf_reset", textContent: "Par défaut", className: "button blue"})); xActions.appendChild(createNode("progress", {id: "progressbar", style: "width: 25px"})); xActions.appendChild(createNode("span", {id: "time_res"})); xActions.appendChild(createNode("div", {id: "tf_apply", textContent: "Appliquer", className: "button green"})); xActions.appendChild(createNode("div", {id: "infomsg", textContent: "blabla"})); // create result xTFNode.appendChild(xOptions); xTFNode.appendChild(xActions); } catch (e) { //console.error(e); showError(e); } return xTFNode; } 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); 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: "result fright"}); // create result xOption.appendChild(xResult); xOption.appendChild(xInput); xOption.appendChild(xLabel); return xOption; } |
︙ | ︙ |
Modified gc_lang/fr/webext/manifest.json from [27e3a301e7] to [da43ad992b].
︙ | ︙ | |||
32 33 34 35 36 37 38 | "background": { "scripts": [ "background.js" ] }, "content_scripts": [ { | | > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | "background": { "scripts": [ "background.js" ] }, "content_scripts": [ { "matches": ["<all_urls>"], "css": ["content_scripts/content_panels.css"], "js": [ "content_scripts/panel_creator.js", "content_scripts/text_formatter.js", "content_scripts/modify_page.js" ] } ], |
︙ | ︙ |