Index: gc_lang/fr/webext/content_scripts/init.js ================================================================== --- gc_lang/fr/webext/content_scripts/init.js +++ gc_lang/fr/webext/content_scripts/init.js @@ -21,24 +21,10 @@ var browser = chrome; bChrome = true; } -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 loadImage (sContainerClass, sImagePath) { let xRequest = new XMLHttpRequest(); xRequest.open('GET', browser.extension.getURL("")+sImagePath, false); xRequest.responseType = "arraybuffer"; @@ -99,10 +85,24 @@ createGCPanel: function () { if (this.oGCPanel === null) { this.oGCPanel = new GrammalecteGrammarChecker("grammalecte_gc_panel", "Grammalecte", 500, 700); this.oGCPanel.insertIntoPage(); } + }, + + createNode: function (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); + } } } /* Index: gc_lang/fr/webext/content_scripts/menu.js ================================================================== --- gc_lang/fr/webext/content_scripts/menu.js +++ gc_lang/fr/webext/content_scripts/menu.js @@ -5,11 +5,11 @@ class GrammalecteMenu { constructor (nMenu, xTextArea) { this.sMenuId = "grammalecte_menu" + nMenu; - this.xButton = createNode("div", {className: "grammalecte_menu_main_button", textContent: " "}); + this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "}); this.xButton.onclick = () => { this.switchMenu(); }; this.xMenu = this._createMenu(xTextArea); this._insertAfter(this.xButton, xTextArea); this._insertAfter(this.xMenu, xTextArea); } @@ -18,21 +18,21 @@ xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling); } _createMenu (xTextArea) { try { - let xMenu = createNode("div", {id: this.sMenuId, className: "grammalecte_menu"}); + let xMenu = oGrammalecte.createNode("div", {id: this.sMenuId, className: "grammalecte_menu"}); // Text formatter - let xTFButton = createNode("div", {className: "grammalecte_menu_item", textContent: "Formateur de texte"}); + let xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_item", textContent: "Formateur de texte"}); xTFButton.onclick = () => { this.switchMenu(); oGrammalecte.createTFPanel(); oGrammalecte.oTFPanel.start(xTextArea); oGrammalecte.oTFPanel.show(); }; // lexicographe - let xLxgButton = createNode("div", {className: "grammalecte_menu_item", textContent: "Lexicographe"}); + let xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_item", textContent: "Lexicographe"}); xLxgButton.onclick = () => { this.switchMenu(); oGrammalecte.createLxgPanel(); oGrammalecte.oLxgPanel.clear(); oGrammalecte.oLxgPanel.show(); @@ -42,11 +42,11 @@ dParam: {sText: xTextArea.value}, dInfo: {sTextAreaId: xTextArea.id} }); }; // Grammar checker - let xGCButton = createNode("div", {className: "grammalecte_menu_item", textContent: "Correction grammaticale"}); + let xGCButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_item", textContent: "Correction grammaticale"}); xGCButton.onclick = () => { this.switchMenu(); oGrammalecte.createGCPanel(); oGrammalecte.oGCPanel.start(xTextArea); oGrammalecte.oGCPanel.show(); @@ -56,32 +56,32 @@ dParam: {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false}, dInfo: {sTextAreaId: xTextArea.id} }); }; // Conjugation tool - let xConjButton = createNode("div", {className: "grammalecte_menu_item_block", textContent: "Conjugueur"}); - let xConjButtonTab = createNode("div", {className: "grammalecte_menu_button", textContent: "Onglet"}); + let xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_item_block", textContent: "Conjugueur"}); + let xConjButtonTab = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Onglet"}); xConjButtonTab.onclick = () => { this.switchMenu(); xGrammalectePort.postMessage({sCommand: "openConjugueurTab", dParam: null, dInfo: null}); }; - let xConjButtonWin = createNode("div", {className: "grammalecte_menu_button", textContent: "Fenêtre"}); + let xConjButtonWin = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Fenêtre"}); xConjButtonWin.onclick = () => { this.switchMenu(); xGrammalectePort.postMessage({sCommand: "openConjugueurWindow", dParam: null, dInfo: null}); }; xConjButton.appendChild(xConjButtonTab); xConjButton.appendChild(xConjButtonWin); // Create - xMenu.appendChild(createNode("div", {className: "grammalecte_menu_header", textContent: "GRAMMALECTE"})); + xMenu.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_menu_header", textContent: "GRAMMALECTE"})); xMenu.appendChild(xTFButton); xMenu.appendChild(xLxgButton); xMenu.appendChild(xGCButton); xMenu.appendChild(xConjButton); - //xMenu.appendChild(createNode("img", {scr: browser.extension.getURL("img/logo-16.png")})); + //xMenu.appendChild(oGrammalecte.createNode("img", {scr: browser.extension.getURL("img/logo-16.png")})); // can’t work, due to content-script policy: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027 - xMenu.appendChild(createNode("div", {className: "grammalecte_menu_footer"})); + xMenu.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_menu_footer"})); return xMenu; } catch (e) { showError(e); } Index: gc_lang/fr/webext/content_scripts/panel.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel.js +++ gc_lang/fr/webext/content_scripts/panel.js @@ -9,24 +9,24 @@ constructor (sId, sTitle, nWidth, nHeight, bFlexible=true) { this.sId = sId; this.nWidth = nWidth; this.nHeight = nHeight; this.bFlexible = bFlexible; - this.xPanelBar = createNode("div", {className: "grammalecte_panel_bar"}); - this.xPanelContent = createNode("div", {className: "grammalecte_panel_content"}); + this.xPanelBar = oGrammalecte.createNode("div", {className: "grammalecte_panel_bar"}); + this.xPanelContent = oGrammalecte.createNode("div", {className: "grammalecte_panel_content"}); this.xWaitIcon = this._createWaitIcon(); this.xPanel = this._createPanel(sTitle); this.center(); } _createPanel (sTitle) { try { - let xPanel = createNode("div", {id: this.sId, className: "grammalecte_panel"}); + let xPanel = oGrammalecte.createNode("div", {id: this.sId, className: "grammalecte_panel"}); this.xPanelBar.appendChild(this._createButtons()); - let xTitle = createNode("div", {className: "grammalecte_panel_title"}); + let xTitle = oGrammalecte.createNode("div", {className: "grammalecte_panel_title"}); xTitle.appendChild(this._createLogo()); - xTitle.appendChild(createNode("div", {className: "grammalecte_panel_label", textContent: sTitle})); + xTitle.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_panel_label", textContent: sTitle})); this.xPanelBar.appendChild(xTitle); xPanel.appendChild(this.xPanelBar); xPanel.appendChild(this.xPanelContent); return xPanel; } @@ -40,11 +40,11 @@ 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; } _createButtons () { - let xButtonLine = createNode("div", {className: "grammalecte_panel_commands"}); + let xButtonLine = oGrammalecte.createNode("div", {className: "grammalecte_panel_commands"}); xButtonLine.appendChild(this.xWaitIcon); if (this.sId === "grammalecte_gc_panel") { xButtonLine.appendChild(this._createCopyButton()); } xButtonLine.appendChild(this._createMoveButton("stickToTop", "¯", "Coller en haut")); @@ -55,30 +55,30 @@ xButtonLine.appendChild(this._createCloseButton()); return xButtonLine; } _createWaitIcon () { - let xWaitIcon = createNode("div", {className: "grammalecte_spinner"}); - xWaitIcon.appendChild(createNode("div", {className: "bounce1"})); - xWaitIcon.appendChild(createNode("div", {className: "bounce2"})); + let xWaitIcon = oGrammalecte.createNode("div", {className: "grammalecte_spinner"}); + xWaitIcon.appendChild(oGrammalecte.createNode("div", {className: "bounce1"})); + xWaitIcon.appendChild(oGrammalecte.createNode("div", {className: "bounce2"})); return xWaitIcon; } _createCopyButton () { - let xButton = createNode("div", {id: "grammalecte_clipboard_button", className: "grammalecte_copy_button", textContent: "∑", title: "Copier dans le presse-papiers"}); + let xButton = oGrammalecte.createNode("div", {id: "grammalecte_clipboard_button", className: "grammalecte_copy_button", textContent: "∑", title: "Copier dans le presse-papiers"}); xButton.onclick = function () { this.copyTextToClipboard(); }.bind(this); return xButton; } _createMoveButton (sAction, sLabel, sTitle) { - let xButton = createNode("div", {className: "grammalecte_move_button", textContent: sLabel, title: sTitle}); + let xButton = oGrammalecte.createNode("div", {className: "grammalecte_move_button", textContent: sLabel, title: sTitle}); xButton.onclick = function () { this[sAction](); }.bind(this); return xButton; } _createCloseButton () { - let xButton = createNode("div", {className: "grammalecte_close_button", textContent: "×", title: "Fermer la fenêtre"}); + let xButton = oGrammalecte.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; } insertIntoPage () { Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -44,12 +44,12 @@ */ constructor (...args) { super(...args); this.aIgnoredErrors = new Set(); - this.xContentNode = createNode("div", {id: "grammalecte_gc_panel_content"}); - this.xParagraphList = createNode("div", {id: "grammalecte_paragraph_list"}); + this.xContentNode = oGrammalecte.createNode("div", {id: "grammalecte_gc_panel_content"}); + this.xParagraphList = oGrammalecte.createNode("div", {id: "grammalecte_paragraph_list"}); this.xContentNode.appendChild(this.xParagraphList); this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false); this.oTooltip = new GrammalecteTooltip(this.xContentNode); this.xPanelContent.appendChild(this.xContentNode); this.oTAC = new GrammalecteTextAreaControl(); @@ -76,17 +76,17 @@ } addParagraphResult (oResult) { try { if (oResult && (oResult.sParagraph.trim() !== "" || oResult.aGrammErr.length > 0 || oResult.aSpellErr.length > 0)) { - let xNodeDiv = createNode("div", {className: "grammalecte_paragraph_block"}); + let xNodeDiv = oGrammalecte.createNode("div", {className: "grammalecte_paragraph_block"}); // actions - let xActionsBar = createNode("div", {className: "grammalecte_paragraph_actions"}); - xActionsBar.appendChild(createNode("div", {id: "grammalecte_check" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_green", textContent: "Réanalyser"}, {para_num: oResult.iParaNum})); - xActionsBar.appendChild(createNode("div", {id: "grammalecte_hide" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_red", textContent: "×", style: "font-weight: bold;"})); + let xActionsBar = oGrammalecte.createNode("div", {className: "grammalecte_paragraph_actions"}); + xActionsBar.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_check" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_green", textContent: "Réanalyser"}, {para_num: oResult.iParaNum})); + xActionsBar.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_hide" + oResult.iParaNum, className: "grammalecte_paragraph_button grammalecte_red", textContent: "×", style: "font-weight: bold;"})); // paragraph - let xParagraph = createNode("p", {id: "grammalecte_paragraph"+oResult.iParaNum, className: "grammalecte_paragraph", lang: "fr", contentEditable: "true"}, {para_num: oResult.iParaNum}); + let xParagraph = oGrammalecte.createNode("p", {id: "grammalecte_paragraph"+oResult.iParaNum, className: "grammalecte_paragraph", lang: "fr", contentEditable: "true"}, {para_num: oResult.iParaNum}); xParagraph.setAttribute("spellcheck", "false"); // doesn’t seem possible to use “spellcheck” as a common attribute. xParagraph.addEventListener("keyup", function (xEvent) { this.oTAC.setParagraph(parseInt(xEvent.target.dataset.para_num), this.purgeText(xEvent.target.textContent)); this.oTAC.write(); }.bind(this) @@ -235,11 +235,11 @@ addSummary () { // todo } addMessage (sMessage) { - let xNode = createNode("div", {className: "grammalecte_gc_panel_message", textContent: sMessage}); + let xNode = oGrammalecte.createNode("div", {className: "grammalecte_gc_panel_message", textContent: sMessage}); this.xParagraphList.appendChild(xNode); } _copyToClipboard (sText) { // recipe from https://github.com/mdn/webextensions-examples/blob/master/context-menu-copy-link-with-types/clipboard-helper.js @@ -277,26 +277,26 @@ class GrammalecteTooltip { constructor (xContentNode) { this.sErrorId = null; - this.xTooltip = createNode("div", {id: "grammalecte_tooltip"}); - this.xTooltipArrow = createNode("img", { + this.xTooltip = oGrammalecte.createNode("div", {id: "grammalecte_tooltip"}); + this.xTooltipArrow = oGrammalecte.createNode("img", { id: "grammalecte_tooltip_arrow", src: " data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwAAADsABataJCQAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNzNun2MAAAAnSURBVChTY/j//z8cq/kW/wdhZDEMSXRFWCVhGKwAmwQyHngFxf8B5fOGYfeFpYoAAAAASUVORK5CYII=", alt: "^", }); - this.xTooltipSuggBlock = createNode("div", {id: "grammalecte_tooltip_sugg_block"}); - let xMessageBlock = createNode("div", {id: "grammalecte_tooltip_message_block"}); - xMessageBlock.appendChild(createNode("p", {id: "grammalecte_tooltip_rule_id"})); - xMessageBlock.appendChild(createNode("p", {id: "grammalecte_tooltip_message", textContent: "Erreur."})); - let xActions = xMessageBlock.appendChild(createNode("div", {id: "grammalecte_tooltip_actions"})); - xActions.appendChild(createNode("div", {id: "grammalecte_tooltip_ignore", textContent: "Ignorer"})); - xActions.appendChild(createNode("div", {id: "grammalecte_tooltip_url", textContent: "Voulez-vous en savoir plus ?…"}, {url: ""})); + this.xTooltipSuggBlock = oGrammalecte.createNode("div", {id: "grammalecte_tooltip_sugg_block"}); + let xMessageBlock = oGrammalecte.createNode("div", {id: "grammalecte_tooltip_message_block"}); + xMessageBlock.appendChild(oGrammalecte.createNode("p", {id: "grammalecte_tooltip_rule_id"})); + xMessageBlock.appendChild(oGrammalecte.createNode("p", {id: "grammalecte_tooltip_message", textContent: "Erreur."})); + let xActions = xMessageBlock.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_tooltip_actions"})); + xActions.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_tooltip_ignore", textContent: "Ignorer"})); + xActions.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_tooltip_url", textContent: "Voulez-vous en savoir plus ?…"}, {url: ""})); xMessageBlock.appendChild(xActions); this.xTooltip.appendChild(xMessageBlock); - this.xTooltip.appendChild(createNode("div", {id: "grammalecte_tooltip_sugg_title", textContent: "SUGGESTIONS :"})); + this.xTooltip.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_tooltip_sugg_title", textContent: "SUGGESTIONS :"})); this.xTooltip.appendChild(this.xTooltipSuggBlock); xContentNode.appendChild(this.xTooltip); xContentNode.appendChild(this.xTooltipArrow); } Index: gc_lang/fr/webext/content_scripts/panel_lxg.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_lxg.js +++ gc_lang/fr/webext/content_scripts/panel_lxg.js @@ -5,11 +5,11 @@ class GrammalecteLexicographer extends GrammalectePanel { constructor (...args) { super(...args); this._nCount = 0; - this._xContentNode = createNode("div", {id: "grammalecte_lxg_panel_content"}); + this._xContentNode = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"}); this.xPanelContent.appendChild(this._xContentNode); } clear () { this._nCount = 0; @@ -18,24 +18,24 @@ } } addSeparator (sText) { if (this._xContentNode.textContent !== "") { - this._xContentNode.appendChild(createNode("div", {className: "grammalecte_lxg_separator", textContent: sText})); + this._xContentNode.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_lxg_separator", textContent: sText})); } } addMessage (sClass, sText) { - this._xContentNode.appendChild(createNode("div", {className: sClass, textContent: sText})); + this._xContentNode.appendChild(oGrammalecte.createNode("div", {className: sClass, textContent: sText})); } addListOfTokens (lTokens) { try { if (lTokens) { this._nCount += 1; - let xNodeDiv = createNode("div", {className: "grammalecte_lxg_list_of_tokens"}); - xNodeDiv.appendChild(createNode("div", {className: "grammalecte_lxg_list_num", textContent: this._nCount})); + let xNodeDiv = oGrammalecte.createNode("div", {className: "grammalecte_lxg_list_of_tokens"}); + xNodeDiv.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_lxg_list_num", textContent: this._nCount})); for (let oToken of lTokens) { xNodeDiv.appendChild(this._createTokenNode(oToken)); } this._xContentNode.appendChild(xNodeDiv); } @@ -44,19 +44,19 @@ showError(e); } } _createTokenNode (oToken) { - let xTokenNode = createNode("div", {className: "grammalecte_lxg_token_block"}); - xTokenNode.appendChild(createNode("div", {className: "grammalecte_lxg_token grammalecte_lxg_token_" + oToken.sType, textContent: oToken.sValue})); - xTokenNode.appendChild(createNode("div", {className: "grammalecte_lxg_token_colon", textContent: ":"})); + let xTokenNode = oGrammalecte.createNode("div", {className: "grammalecte_lxg_token_block"}); + xTokenNode.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_lxg_token grammalecte_lxg_token_" + oToken.sType, textContent: oToken.sValue})); + xTokenNode.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_lxg_token_colon", textContent: ":"})); if (oToken.aLabel.length === 1) { xTokenNode.appendChild(document.createTextNode(oToken.aLabel[0])); } else { - let xTokenList = createNode("div", {className: "grammalecte_lxg_morph_list"}); + let xTokenList = oGrammalecte.createNode("div", {className: "grammalecte_lxg_morph_list"}); for (let sLabel of oToken.aLabel) { - xTokenList.appendChild(createNode("div", {className: "grammalecte_lxg_morph_elem", textContent: "• " + sLabel})); + xTokenList.appendChild(oGrammalecte.createNode("div", {className: "grammalecte_lxg_morph_elem", textContent: "• " + sLabel})); } xTokenNode.appendChild(xTokenList); } return xTokenNode; } Index: gc_lang/fr/webext/content_scripts/panel_tf.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_tf.js +++ gc_lang/fr/webext/content_scripts/panel_tf.js @@ -15,12 +15,12 @@ _createTextFormatter () { let xTFNode = document.createElement("div"); try { // Options - let xOptions = createNode("div", {id: "grammalecte_tf_options"}); - let xColumn1 = createNode("div", {className: "grammalecte_tf_column"}); + let xOptions = oGrammalecte.createNode("div", {id: "grammalecte_tf_options"}); + let xColumn1 = oGrammalecte.createNode("div", {className: "grammalecte_tf_column"}); let xSSP = this._createFieldset("group_ssp", true, "Espaces surnuméraires"); xSSP.appendChild(this._createBlockOption("o_start_of_paragraph", true, "En début de paragraphe")); xSSP.appendChild(this._createBlockOption("o_end_of_paragraph", true, "En fin de paragraphe")); xSSP.appendChild(this._createBlockOption("o_between_words", true, "Entre les mots")); xSSP.appendChild(this._createBlockOption("o_before_punctuation", true, "Avant les points (.), les virgules (,)")); @@ -36,11 +36,11 @@ xNBSP.appendChild(this._createBlockOption("o_nbsp_before_symbol", true, "Avant % ‰ € $ £ ¥ ˚C")); xNBSP.appendChild(this._createBlockOption("o_nbsp_within_numbers", true, "À l’intérieur des nombres")); xNBSP.appendChild(this._createBlockOption("o_nbsp_before_units", true, "Avant les unités de mesure")); let xDelete = this._createFieldset("group_delete", true, "Suppressions"); xDelete.appendChild(this._createBlockOption("o_erase_non_breaking_hyphens", true, "Tirets conditionnels")); - let xColumn2 = createNode("div", {className: "grammalecte_tf_column"}); + let xColumn2 = oGrammalecte.createNode("div", {className: "grammalecte_tf_column"}); let xTypo = this._createFieldset("group_typo", true, "Signes typographiques"); xTypo.appendChild(this._createBlockOption("o_ts_apostrophe", true, "Apostrophe (’)")); xTypo.appendChild(this._createBlockOption("o_ts_ellipsis", true, "Points de suspension (…)")); xTypo.appendChild(this._createBlockOption("o_ts_dash_middle", true, "Tirets d’incise :")); xTypo.appendChild(this._createRadioBoxHyphens("o_ts_m_dash_middle", "o_ts_n_dash_middle", false)); @@ -68,20 +68,20 @@ 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_tf_button"}); + let xActions = oGrammalecte.createNode("div", {id: "grammalecte_tf_actions"}); + let xDefaultButton = oGrammalecte.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_tf_button"}); + let xApplyButton = oGrammalecte.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(oGrammalecte.createNode("progress", {id: "grammalecte_tf_progressbar"})); + xActions.appendChild(oGrammalecte.createNode("span", {id: "grammalecte_tf_time_res", textContent: "…"})); xActions.appendChild(xApplyButton); - //xActions.appendChild(createNode("div", {id: "grammalecte_infomsg", textContent: "blabla"})); + //xActions.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_infomsg", textContent: "blabla"})); // create result xTFNode.appendChild(xOptions); xTFNode.appendChild(xActions); } catch (e) { @@ -90,50 +90,50 @@ return xTFNode; } // Common options _createFieldset (sId, bDefault, sLabel) { - let xFieldset = createNode("div", {id: sId, className: "grammalecte_tf_groupblock"}); - let xGroupOption = createNode("div", {id: "o_"+sId, className: "grammalecte_tf_option grammalecte_tf_option_title_off", textContent: sLabel}, {selected: "false", default: bDefault, linked_ids: ""}); + let xFieldset = oGrammalecte.createNode("div", {id: sId, className: "grammalecte_tf_groupblock"}); + let xGroupOption = oGrammalecte.createNode("div", {id: "o_"+sId, className: "grammalecte_tf_option grammalecte_tf_option_title_off", textContent: sLabel}, {selected: "false", default: bDefault, linked_ids: ""}); xGroupOption.addEventListener("click", (xEvent) => { this.switchOption(xEvent.target.id); this.switchGroup(xEvent.target.id); }); xFieldset.appendChild(xGroupOption); return xFieldset; } _createBlockOption (sId, bDefault, sLabel) { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); xLine.appendChild(this._createOption(sId, bDefault, sLabel)); - xLine.appendChild(createNode("div", {id: "res_"+sId, className: "grammalecte_tf_result", textContent: "·"})); + xLine.appendChild(oGrammalecte.createNode("div", {id: "res_"+sId, className: "grammalecte_tf_result", textContent: "·"})); return xLine; } _createOption (sId, bDefault, sLabel, sLinkedOptionsId="") { - let xOption = createNode("div", {id: sId, className: "grammalecte_tf_option grammalecte_tf_option_off", textContent: sLabel}, {selected: "false", default: bDefault, linked_ids: sLinkedOptionsId}); + let xOption = oGrammalecte.createNode("div", {id: sId, className: "grammalecte_tf_option grammalecte_tf_option_off", textContent: sLabel}, {selected: "false", default: bDefault, linked_ids: sLinkedOptionsId}); xOption.addEventListener("click", (xEvent) => { this.switchOption(xEvent.target.id); }); return xOption; } // Hyphens _createRadioBoxHyphens (sIdEmDash, sIdEnDash, bDefaultEmDash) { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); xLine.appendChild(this._createOption(sIdEmDash, bDefaultEmDash, "cadratin (—)", sIdEnDash)); xLine.appendChild(this._createOption(sIdEnDash, !bDefaultEmDash, "demi-cadratin (—)", sIdEmDash)); return xLine; } // Ligatures _createRadioBoxLigatures () { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); xLine.appendChild(this._createOption("o_ts_ligature", true, "Ligatures")); xLine.appendChild(this._createOption("o_ts_ligature_do", false, "faire", "o_ts_ligature_undo")); xLine.appendChild(this._createOption("o_ts_ligature_undo", true, "défaire", "o_ts_ligature_do")); - xLine.appendChild(createNode("div", {id: "res_"+"o_ts_ligature", className: "grammalecte_tf_result", textContent: "·"})); + xLine.appendChild(oGrammalecte.createNode("div", {id: "res_"+"o_ts_ligature", className: "grammalecte_tf_result", textContent: "·"})); return xLine; } _createLigaturesSelection () { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); xLine.appendChild(this._createOption("o_ts_ligature_ff", true, "ff")); xLine.appendChild(this._createOption("o_ts_ligature_fi", true, "fi")); xLine.appendChild(this._createOption("o_ts_ligature_ffi", true, "ffi")); xLine.appendChild(this._createOption("o_ts_ligature_fl", true, "fl")); xLine.appendChild(this._createOption("o_ts_ligature_ffl", true, "ffl")); @@ -142,22 +142,22 @@ return xLine; } // Apostrophes _createSingleLetterOptions () { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_indent"}); xLine.appendChild(this._createOption("o_ma_1letter_lowercase", false, "lettres isolées (j’ n’ m’ t’ s’ c’ d’ l’)")); xLine.appendChild(this._createOption("o_ma_1letter_uppercase", false, "Maj.")); return xLine; } // Ordinals _createOrdinalOptions () { - let xLine = createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); + let xLine = oGrammalecte.createNode("div", {className: "grammalecte_tf_blockopt grammalecte_tf_underline"}); xLine.appendChild(this._createOption("o_ordinals_no_exponant", true, "Ordinaux (15e, XXIe…)")); xLine.appendChild(this._createOption("o_ordinals_exponant", true, "e → ᵉ")); - xLine.appendChild(createNode("div", {id: "res_"+"o_ordinals_no_exponant", className: "grammalecte_tf_result", textContent: "·"})); + xLine.appendChild(oGrammalecte.createNode("div", {id: "res_"+"o_ordinals_no_exponant", className: "grammalecte_tf_result", textContent: "·"})); return xLine; } /* Actions