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
|
this.xNode = xNode;
this.sMenuId = "grammalecte_menu" + nMenu;
this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "});
this.xButton.onclick = () => { this.switchMenu(); };
this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex;
this.xMenu = this._createMenu();
let style = window.getComputedStyle(this.xNode);
let topMargin = -1 * (8 + parseInt(style.marginBottom.replace('px', ''), 10));
let insAfterThis = this.xNode;
if ( document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')){
insAfterThis = this.xNode.parentNode;
}
this._insertAfter(this.xButton, insAfterThis);
this.xButton.style.marginTop = topMargin + 'px';
this._insertAfter(this.xMenu, insAfterThis);
this.xMenu.style.marginTop = (topMargin + 8) + 'px';
this._createListenersOnReferenceNode();
}
_insertAfter (xNewNode, xReferenceNode) {
xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling);
}
_createListenersOnReferenceNode () {
this.xNode.addEventListener('focus', (e) => {
this.xButton.style.display = "block";
});
this.xNode.addEventListener('blur', (e) => {
window.setTimeout(() => {this.xButton.style.display = "none";}, 300);
});
}
|
|
|
|
|
|
|
<
<
|
<
<
|
|
>
|
|
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
|
this.xNode = xNode;
this.sMenuId = "grammalecte_menu" + nMenu;
this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "});
this.xButton.onclick = () => { this.switchMenu(); };
this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex;
this.xMenu = this._createMenu();
let xStyle = window.getComputedStyle(this.xNode);
let nMarginTop = -1 * (8 + parseInt(xStyle.marginBottom.replace('px', ''), 10));
let xNodeInsertAfter = this.xNode;
if (document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')) {
xNodeInsertAfter = this.xNode.parentNode;
}
this._insertAfter(this.xButton, xNodeInsertAfter, nMarginTop);
this._insertAfter(this.xMenu, xNodeInsertAfter, nMarginTop + 8);
this._createListeners();
}
_insertAfter (xNewNode, xReferenceNode, nMarginTop) {
xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling);
xNewNode.style.marginTop = nMarginTop + "px";
}
_createListeners () {
this.xNode.addEventListener('focus', (e) => {
this.xButton.style.display = "block";
});
this.xNode.addEventListener('blur', (e) => {
window.setTimeout(() => {this.xButton.style.display = "none";}, 300);
});
}
|