MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / highlightTooltip

Function highlightTooltip

scripts/main.js:86–121  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

84});
85
86function highlightTooltip(e) {
87 if (!(e.target === this)) return
88
89 if(e.type=="mouseout") {
90 d3.select("body").selectAll(".syntax-tooltip").remove();
91 return;
92 }
93
94 var codeClass = this.getAttribute('class');
95 var codeClasses = {
96 "hljs-keyword": "Language keywords mean something special in the language.",
97 "hljs-number": "A number",
98 "hljs-title": "A title names something, like a function in C or an element in XML",
99 "hljs-params": "The parameters that get passed to the function",
100 "hljs-function": "A function declaration",
101 "hljs-built_in": "A built-in function",
102 "hljs-string": "This is a string; it may mean something to you, but to the computer it’s pretty much just an arbitrary sequence of letters.",
103 "hljs-list": "A list",
104 "hljs-tag": "A tag",
105 "hljs-attribute": "The name of an attribute",
106 "hljs-value": "The value of an attribute",
107 "hljs-import": "An import lets you use code written somewhere else",
108 "hljs-class": "A class",
109 "hljs-container": "A container",
110 "hljs-type": "A type",
111 "hljs-variable": "A variable"
112 }
113
114 if(typeof codeClasses[codeClass] === 'undefined') return;
115
116 var popup = d3.select("body").selectAll(".syntax-tooltip").data([codeClass]);
117 popup.enter().append("div").classed("syntax-tooltip", true);
118 popup.text(codeClasses[codeClass])
119 .style("left", this.getBoundingClientRect().left + this.getBoundingClientRect().width/2 +"px")
120 .style("top", (this.getBoundingClientRect().bottom + document.getElementsByTagName("body")[0].scrollTop) +"px");
121}
122
123
124function footnotes() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected