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 @@ -43,22 +43,22 @@ } */ const oGrammalecte = { - nWrapper: 0, - lWrapper: [], + nMenu: 0, + lMenu: [], oTFPanel: null, oLxgPanel: null, oGCPanel: null, - wrapTextareas: function () { + createMenus: function () { let lNode = document.getElementsByTagName("textarea"); for (let xNode of lNode) { - this.lWrapper.push(new GrammalecteWrapper(this.nWrapper, xNode)); - this.nWrapper += 1; + this.lMenu.push(new GrammalecteMenu(this.nMenu, xNode)); + this.nMenu += 1; } }, createTFPanel: function () { if (this.oTFPanel === null) { @@ -132,6 +132,6 @@ /* Start */ -oGrammalecte.wrapTextareas(); +oGrammalecte.createMenus(); ADDED gc_lang/fr/webext/content_scripts/menu.css Index: gc_lang/fr/webext/content_scripts/menu.css ================================================================== --- gc_lang/fr/webext/content_scripts/menu.css +++ gc_lang/fr/webext/content_scripts/menu.css @@ -0,0 +1,72 @@ +/* + CSS + Menu for Grammalecte +*/ + +.grammalecte_menu_main_button { + position: absolute; + margin: -17px 0 0 -16px; + border-radius: 16px; + background-color: hsla(210, 50%, 50%, .5); + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA3XAAAN1wFCKJt4AAAJHElEQVRYha3Xa3BTVQLA8XPOvWmebdq8bhJSkhaoS3n0QbE81BVwBsFVXn24uwLuzjjuKAiIzA5dZmdERwfZod11x/0idXdGFIsiuIOLjjq7gpbWlpY06SNtQ5ImadM8m0fzuPeesx+SYnkIZWfvx+TO/f3PPck59wJwnwdECAIAkEwiBs+/+rcPn//rF7FVP3/sYQAAoCiavt/rUfeFQwQJwVAiFuNnDh1rHaGMOwcmonll1Y/UF3CBdpd92A4RogAh5P8eABFChGAolYjxb4+0nLLi4l2SAjlXseQBYHFMCkuXr6mTpSYvux2jDogQmmsEmiMOCcZAKhGTZ5uaP7iW1v4q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XNRhJBMMBDIW6lMffXBmy9tmfSNR0wlpaotLzdfvOvIZeHzra/trYvGbsfvGDArgrb19w3kc+HOFWs3bPWEk5JKSejLU2/s2+r3+6cNBoNi68ET//rOg2tuwsVZPBIMClbk3x3/yYDZEaO2/mE+5Li8sBC6P37n9f3BYCCh1WoLdhxqufD9OFy1cIGJk0lvHnkkFBJU54fPtR7dW383HAAA4J0+nH0ghBDGmAAICSAEFMjlwl1H3rnQGZZsMBnncfkyGZ1O3/ircZFQiK6WhT9tPbqnPhqL47vhAMzhsRxnn/GhQJAnAgCAHc+9cqQ3Lt8wT6dJy/ML6HQ6k7vtfjYSCtPV0sjZGRzeA59TwEwEz3EsAAAM9bRfWlmq4sY843kcz2GpWAwmfNlFploW/uTkay82zIyc3AMH4D5ezWZeNMbsthElnbQsr11f32MbozDBbHxqSlCZHz7benRPYyw38rng9xUwU4EoirZZr/Wr6GTvkpqHtjnGg8IqabDtvaN7G2PxOLkf/H8+KJoWAADAU79+7jdH3z1/USaV0gAAOJdXsVuP/wIS/4KXKIWf7AAAAABJRU5ErkJggg=='); + background-repeat: no-repeat; + width: 32px; + height: 32px; + cursor: pointer; + z-index: 100000000; +} + +.grammalecte_menu { + display: none; + position: absolute; + margin-left: -10px; + border-radius: 5px; + border: 3px solid hsl(210, 50%, 30%); + box-shadow: 0px 0px 2px hsla(210, 10%, 10%, .5); + font-family: "Trebuchet MS", "Liberation Sans", sans-serif; +} + +.grammalecte_menu_item { + padding: 3px 10px; + background-color: hsl(210, 50%, 50%); + font-size: 14px; + color: hsl(210, 50%, 92%); + cursor: pointer; +} +.grammalecte_menu_item:hover { + background-color: hsl(210, 60%, 60%); + color: hsl(210, 60%, 100%); +} + +.grammalecte_menu_item_block { + padding: 3px 10px; + background-color: hsl(210, 50%, 50%); + font-size: 14px; + color: hsl(210, 50%, 92%); + border-top: 1px solid hsl(210, 50%, 30%);; +} + +.grammalecte_menu_button { + display: inline-block; + padding: 0 5px; + margin-left: 10px; + border-radius: 2px; + background-color: hsl(210, 50%, 55%); + font-size: 12px; + line-height: 1.6; + text-align: center; + cursor: pointer; +} +.grammalecte_menu_button:hover { + background-color: hsl(210, 60%, 60%); +} + +.grammalecte_menu_header { + padding: 2px 10px; + background-color: hsl(210, 50%, 30%); + font-size: 12px; + font-variant-caps: small-caps; + color: hsl(210, 50%, 90%); + text-shadow: 0px 0px 2px hsla(210, 10%, 10%, .9); + text-align: center; +} ADDED gc_lang/fr/webext/content_scripts/menu.js 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 @@ -0,0 +1,94 @@ +// JavaScript + +"use strict"; + + +class GrammalecteMenu { + + constructor (nMenu, xTextArea) { + this.sMenuId = "grammalecte_menu" + nMenu; + let xButton = createNode("div", {className: "grammalecte_menu_main_button"}); + xButton.onclick = () => { this.switchMenu(); }; + let xMenu = this._createMenu(xTextArea); + this._insertAfter(xButton, xTextArea); + this._insertAfter(xMenu, xTextArea); + } + + _insertAfter (xNewNode, xReferenceNode) { + xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling); + } + + _createMenu (xTextArea) { + try { + let xMenu = createNode("div", {id: this.sMenuId, className: "grammalecte_menu"}); + // Text formatter + let xTFButton = 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"}); + xLxgButton.onclick = () => { + this.switchMenu(); + oGrammalecte.createLxgPanel(); + oGrammalecte.oLxgPanel.clear(); + oGrammalecte.oLxgPanel.show(); + oGrammalecte.oLxgPanel.startWaitIcon(); + xGrammalectePort.postMessage({ + sCommand: "getListOfTokens", + dParam: {sText: xTextArea.value}, + dInfo: {sTextAreaId: xTextArea.id} + }); + }; + // Grammar checker + let xGCButton = createNode("div", {className: "grammalecte_menu_item", textContent: "Correction grammaticale"}); + xGCButton.onclick = () => { + this.switchMenu(); + oGrammalecte.createGCPanel(); + oGrammalecte.oGCPanel.start(xTextArea); + oGrammalecte.oGCPanel.show(); + oGrammalecte.oGCPanel.startWaitIcon(); + xGrammalectePort.postMessage({ + sCommand: "parseAndSpellcheck", + 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"}); + xConjButtonTab.onclick = () => { + this.switchMenu(); + xGrammalectePort.postMessage({sCommand: "openConjugueurTab", dParam: null, dInfo: null}); + }; + let xConjButtonWin = 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(xTFButton); + xMenu.appendChild(xLxgButton); + xMenu.appendChild(xGCButton); + xMenu.appendChild(xConjButton); + //xMenu.appendChild(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_header"})); + return xMenu; + } + catch (e) { + showError(e); + } + } + + switchMenu () { + let xMenu = document.getElementById(this.sMenuId); + xMenu.style.display = (xMenu.style.display == "block") ? "none" : "block"; + } +} DELETED gc_lang/fr/webext/content_scripts/wrapper.css Index: gc_lang/fr/webext/content_scripts/wrapper.css ================================================================== --- gc_lang/fr/webext/content_scripts/wrapper.css +++ gc_lang/fr/webext/content_scripts/wrapper.css @@ -1,75 +0,0 @@ -/* - CSS - Wrappen for Grammalecte -*/ - - -.grammalecte_wrapper { - margin: 0 0 5px 0; - padding: 2px 5px 5px 5px; - box-sizing: border-box; - border-radius: 0 0 3px 3px; - background-color: hsla(210, 100%, 96%, .2); - border-left: 1px solid hsla(210, 100%, 92%, .2); - border-right: 1px solid hsla(210, 100%, 92%, .2); - border-bottom: 1px solid hsla(210, 100%, 92%, .2); - /*box-shadow: 0 0 2px hsla(210, 100%, 0%, .2);*/ - font-family: "Trebuchet MS", "Liberation Sans", sans-serif; -} - -.grammalecte_wrapper_title { - display: inline-block; - padding: 2px 5px; - font-size: 14px; - font-weight: bold; - font-variant: small-caps; - text-shadow: 0px 1px 0px hsla(210, 10%, 10%, .8); - color: hsla(210, 100%, 90%, .5); -} - -.grammalecte_wrapper_toolbar { - display: flex; - justify-content: flex-end; - margin-top: 5px; - padding: 5px 10px; -} - -.grammalecte_wrapper_button { - display: inline-block; - padding: 0 5px; - margin-left: 5px; - background-color: hsl(210, 60%, 80%); - border-radius: 2px; - border: 1px solid hsl(210, 60%, 70%); - font-size: 14px; - color: hsl(210, 40%, 40%); - cursor: pointer; -} -.grammalecte_wrapper_button:hover { - background-color: hsl(210, 80%, 70%); - border: 1px solid hsl(210, 80%, 60%); - box-shadow: 0 0 1px 1px hsla(210, 100%, 50%, .5); - color: hsl(210, 80%, 98%); -} - -.grammalecte_wrapper_conj_section { - display: none; -} - -.grammalecte_wrapper_button2 { - display: inline-block; - padding: 0 5px; - margin-left: 5px; - background-color: hsl(180, 60%, 80%); - border-radius: 2px; - border: 1px solid hsl(180, 60%, 70%); - font-size: 14px; - color: hsl(180, 40%, 40%); - cursor: pointer; -} -.grammalecte_wrapper_button2:hover { - background-color: hsl(180, 80%, 70%); - border: 1px solid hsl(180, 80%, 60%); - box-shadow: 0 0 1px 1px hsl(180, 80%, 80%); - color: hsl(180, 80%, 98%); -} DELETED gc_lang/fr/webext/content_scripts/wrapper.js Index: gc_lang/fr/webext/content_scripts/wrapper.js ================================================================== --- gc_lang/fr/webext/content_scripts/wrapper.js +++ gc_lang/fr/webext/content_scripts/wrapper.js @@ -1,93 +0,0 @@ -// JavaScript - -"use strict"; - - -class GrammalecteWrapper { - - constructor (nWrapper, xTextArea) { - this.nWrapper = nWrapper; - let xWrapper = createNode("div", {id: "grammalecte_wrapper" + nWrapper, className: "grammalecte_wrapper"}); - xWrapper.appendChild(this._createWrapperToolbar(xTextArea)); - this._insertAfter(xWrapper, xTextArea); - xWrapper.style.marginBottom = xTextArea.style.marginBottom; - xTextArea.style.marginBottom = "0px"; - xWrapper.style.width = xTextArea.style.width; - } - - _insertAfter (xNewNode, xReferenceNode) { - xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling); - } - - _createWrapperToolbar (xTextArea) { - try { - let xToolbar = createNode("div", {className: "grammalecte_wrapper_toolbar"}); - let xConjButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Conjuguer"}); - xConjButton.onclick = () => { this.showConjButtons(); }; - let xConjSection = createNode("div", {id: "grammalecte_wrapper_conj_section"+this.nWrapper, className: "grammalecte_wrapper_conj_section"}); - let xConjButtonTab = createNode("div", {className: "grammalecte_wrapper_button2", textContent: ">Onglet"}); - xConjButtonTab.onclick = function () { - xGrammalectePort.postMessage({sCommand: "openConjugueurTab", dParam: null, dInfo: null}); - this.hideConjButtons(); - }.bind(this); - let xConjButtonWin = createNode("div", {className: "grammalecte_wrapper_button2", textContent: ">Fenêtre"}); - xConjButtonWin.onclick = function () { - xGrammalectePort.postMessage({sCommand: "openConjugueurWindow", dParam: null, dInfo: null}); - this.hideConjButtons(); - }.bind(this); - let xTFButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Formater"}); - xTFButton.onclick = function () { - oGrammalecte.createTFPanel(); - oGrammalecte.oTFPanel.start(xTextArea); - oGrammalecte.oTFPanel.show(); - }; - let xLxgButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Analyser"}); - xLxgButton.onclick = function () { - oGrammalecte.createLxgPanel(); - oGrammalecte.oLxgPanel.clear(); - oGrammalecte.oLxgPanel.show(); - oGrammalecte.oLxgPanel.startWaitIcon(); - xGrammalectePort.postMessage({ - sCommand: "getListOfTokens", - dParam: {sText: xTextArea.value}, - dInfo: {sTextAreaId: xTextArea.id} - }); - }; - let xGCButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Corriger"}); - xGCButton.onclick = function () { - oGrammalecte.createGCPanel(); - oGrammalecte.oGCPanel.start(xTextArea); - oGrammalecte.oGCPanel.show(); - oGrammalecte.oGCPanel.startWaitIcon(); - xGrammalectePort.postMessage({ - sCommand: "parseAndSpellcheck", - dParam: {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false}, - dInfo: {sTextAreaId: xTextArea.id} - }); - }; - // Create - //xToolbar.appendChild(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 - xToolbar.appendChild(createNode("div", {className: "grammalecte_wrapper_title", textContent: "Grammalecte"})) - xToolbar.appendChild(xConjButton); - xConjSection.appendChild(xConjButtonTab); - xConjSection.appendChild(xConjButtonWin); - xToolbar.appendChild(xConjSection); - xToolbar.appendChild(xTFButton); - xToolbar.appendChild(xLxgButton); - xToolbar.appendChild(xGCButton); - return xToolbar; - } - catch (e) { - showError(e); - } - } - - showConjButtons () { - document.getElementById("grammalecte_wrapper_conj_section"+this.nWrapper).style.display = "block"; - } - - hideConjButtons () { - document.getElementById("grammalecte_wrapper_conj_section"+this.nWrapper).style.display = "none"; - } -} Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -42,20 +42,20 @@ "css": [ "content_scripts/panel.css", "content_scripts/panel_tf.css", "content_scripts/panel_gc.css", "content_scripts/panel_lxg.css", - "content_scripts/wrapper.css", + "content_scripts/menu.css", "3rd/font-awesome-4.7.0/css/font-awesome.min.css" ], "js": [ "content_scripts/panel.js", "grammalecte/fr/textformatter.js", "content_scripts/panel_tf.js", "content_scripts/panel_gc.js", "content_scripts/panel_lxg.js", - "content_scripts/wrapper.js", + "content_scripts/menu.js", "content_scripts/init.js" ], "run_at": "document_end" } ],