Differences From Artifact [1c8166f9c8]:
- File gc_lang/fr/webext/content_scripts/menu.js — part of check-in [dc0a47993e] at 2020-04-08 13:50:39 on branch trunk — [fx] text area button: don’t show it for editable node that aren’t <p> or <div> (user: olr, size: 3549) [annotate] [blame] [check-ins using] [more...]
To Artifact [56c56fae1e]:
- File gc_lang/fr/webext/content_scripts/menu.js — part of check-in [f16babf55d] at 2020-04-08 20:12:40 on branch trunk — [fx] button: node examination update (user: olr, size: 3965) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
34 35 36 37 38 39 40 |
if (oOptions.hasOwnProperty("ui_options")) {
this._bTextArea = oOptions.ui_options.textarea;
this._bEditableNode = oOptions.ui_options.editablenode;
}
}
examineNode (xNode) {
| | > > > > | > | | | | < | < | | | | > | | < > > > > > > | | < | > | | | > | 34 35 36 37 38 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
if (oOptions.hasOwnProperty("ui_options")) {
this._bTextArea = oOptions.ui_options.textarea;
this._bEditableNode = oOptions.ui_options.editablenode;
}
}
examineNode (xNode) {
if (!xNode || !xNode instanceof HTMLElement) {
// not a node
this.reject();
return;
}
if (xNode === this.xTextNode) {
// same node -> possibly click for resizing -> move it
this.move();
return;
}
if ( ( (xNode.tagName == "TEXTAREA" && this._bTextArea && xNode.getAttribute("spellcheck") !== "false")
|| (xNode.tagName == "IFRAME" && this._bIframe) )
&& !(xNode.dataset.grammalecte_button && xNode.dataset.grammalecte_button == "false") ) {
// textarea or iframe
this.accept(xNode)
}
else if (xNode.isContentEditable && this._bEditableNode) {
// editable node
const findOriginEditableNode = function (xNode) {
return (!xNode.parentNode.isContentEditable) ? xNode : findOriginEditableNode(xNode.parentNode);
}
xNode = findOriginEditableNode(xNode);
if ((xNode.tagName == "P" || xNode.tagName == "DIV") && !(xNode.dataset.grammalecte_button && xNode.dataset.grammalecte_button == "false")) {
this.accept(xNode);
} else {
this.reject();
}
} else {
this.reject();
}
}
accept (xNode=null) {
if (xNode) {
this.xTextNode = xNode;
this.xButton.style.display = "none"; // we hide it before showing it again to relaunch the animation
this.move();
this.xButton.style.display = "block";
}
}
reject () {
this.xTextNode = null;
this.xButton.style.display = "none";
}
move () {
if (this.xTextNode) {
let oCoord = oGrammalecte.getElementCoord(this.xTextNode);
this.xButton.style.top = `${oCoord.bottom}px`;
|
| ︙ | ︙ |