Index: gc_lang/fr/webext/content_scripts/panel_gc.css ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.css +++ gc_lang/fr/webext/content_scripts/panel_gc.css @@ -140,11 +140,11 @@ div#grammalecte_tooltip_ignore:hover { background-color: hsl(30, 30%, 50%); color: hsla(0, 0%, 100%, 1); text-shadow: 0 0 3px hsl(30, 30%, 60%); } -div#grammalecte_tooltip_url { +div#grammalecte_tooltip_url, div#grammalecte_tooltip_db_search { display: inline-block; margin-left: 10px; padding: 1px 5px; background-color: hsl(210, 50%, 50%); color: hsla(210, 0%, 96%, 1); @@ -152,15 +152,16 @@ cursor: pointer; font-family: Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; font-size: 12px; text-decoration: none; } -div#grammalecte_tooltip_url:hover { +div#grammalecte_tooltip_url:hover, div#grammalecte_tooltip_db_search:hover { background-color: hsl(210, 50%, 60%); color: hsla(0, 0%, 100%, 1); text-shadow: 0 0 3px hsl(210, 30%, 60%); } + div#grammalecte_tooltip_sugg_title { padding: 0 10px; background-color: hsl(210, 10%, 90%); color: hsl(210, 50%, 30%); font-family: Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; 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 @@ -16,11 +16,11 @@ xElem.parentNode.parentNode.style.display = "none"; } else if (xElem.id.startsWith("grammalecte_err") && xElem.className !== "grammalecte_error_corrected" && xElem.className !== "grammalecte_error_ignored") { oGrammalecte.oGCPanel.oTooltip.show(xElem.id); - } else if (xElem.id === "grammalecte_tooltip_url") { + } else if (xElem.id === "grammalecte_tooltip_url" || xElem.id === "grammalecte_tooltip_db_search") { oGrammalecte.oGCPanel.openURL(xElem.dataset.url); } else { oGrammalecte.oGCPanel.oTooltip.hide(); } } else { @@ -284,10 +284,11 @@ class GrammalecteTooltip { constructor (xContentNode) { this.sErrorId = null; + this.bDebug = false; 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: "^", @@ -303,10 +304,11 @@ this.xTooltip.appendChild(this.xTooltipSuggBlock); // actions let xActions = 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: ""})); + xActions.appendChild(oGrammalecte.createNode("div", {id: "grammalecte_tooltip_db_search", textContent: " ››› base de données"}, {url: ""})); this.xTooltip.appendChild(xActions); // add tooltip to the page xContentNode.appendChild(this.xTooltip); xContentNode.appendChild(this.xTooltipArrow); } @@ -322,18 +324,20 @@ this.xTooltipArrow.style.left = (xNodeErr.offsetLeft + Math.floor((nUsefulErrorWidth / 2)) - 4) + "px"; // 4 is half the width of the arrow. this.xTooltip.style.top = (xNodeErr.offsetTop + 20) + "px"; this.xTooltip.style.left = (xNodeErr.offsetLeft > nTooltipLeftLimit) ? nTooltipLeftLimit + "px" : xNodeErr.offsetLeft + "px"; if (xNodeErr.dataset.error_type === "grammar") { // grammar error - document.getElementById("grammalecte_tooltip_add_word").style.display = "none"; + document.getElementById("grammalecte_tooltip_db_search").style.display = "none"; if (xNodeErr.dataset.gc_message.includes(" ##")) { + this.bDebug = true; // display rule id let n = xNodeErr.dataset.gc_message.indexOf(" ##"); document.getElementById("grammalecte_tooltip_message").textContent = xNodeErr.dataset.gc_message.slice(0, n); document.getElementById("grammalecte_tooltip_rule_id").textContent = "Règle : " + xNodeErr.dataset.gc_message.slice(n+2); document.getElementById("grammalecte_tooltip_rule_id").style.display = "block"; } else { + this.bDebug = false; document.getElementById("grammalecte_tooltip_message").textContent = xNodeErr.dataset.gc_message; document.getElementById("grammalecte_tooltip_rule_id").style.display = "none"; } if (xNodeErr.dataset.gc_url != "") { document.getElementById("grammalecte_tooltip_url").dataset.url = xNodeErr.dataset.gc_url; @@ -360,15 +364,15 @@ document.getElementById("grammalecte_tooltip_message").textContent = "Mot inconnu du dictionnaire."; document.getElementById("grammalecte_tooltip_ignore").dataset.error_id = xNodeErr.dataset.error_id; document.getElementById("grammalecte_tooltip_rule_id").style.display = "none"; document.getElementById("grammalecte_tooltip_url").dataset.url = ""; document.getElementById("grammalecte_tooltip_url").style.display = "none"; - if (xNodeErr.dataset.gc_message.includes(" ##")) { - // display rule id - document.getElementById("grammalecte_tooltip_add_word").style.display = "block"; + if (this.bDebug) { + document.getElementById("grammalecte_tooltip_db_search").style.display = "inline"; + document.getElementById("grammalecte_tooltip_db_search").dataset.url = "https://www.dicollecte.org/dictionary.php?prj=fr&lemma="+xNodeErr.textContent; } else { - document.getElementById("grammalecte_tooltip_add_word").style.display = "none"; + document.getElementById("grammalecte_tooltip_db_search").style.display = "none"; } this.clearSuggestionBlock(); this.xTooltipSuggBlock.textContent = "Recherche de graphies possibles…"; xGrammalectePort.postMessage({ sCommand: "getSpellSuggestions",