Spaces:
Running
Running
File size: 1,860 Bytes
40559c4 |
1 2 3 4 5 6 7 8 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 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 |
!(() => {
var ttFnSel = d3.select('body').selectAppend('div.tooltip-footnote.tooltip-footnote-hidden')
function index2superscipt(i){
return (i + 1 + '')
.split('')
.map(num => '⁰¹²³⁴⁵⁶⁷⁸⁹'[num])
.join('')
}
var footendSel = d3.selectAll('.footend')
.each(function(d, i){
var sel = d3.select(this)
var ogHTML = sel.parent().html()
sel
.at({href: '#footstart-' + i, id: 'footend-' + i})
.text(index2superscipt(i))
.datum(ogHTML)
})
footendSel.parent().parent().selectAll('br').remove()
var footstartSel = d3.selectAll('.footstart')
.each(function(d, i){
d3.select(this)
.at({
href: '#footend-' + i,
})
.text(index2superscipt(i))
.datum(footendSel.data()[i])
.parent().at({id: 'footstart-' + i})
})
.call(addLockedTooltip)
function addLockedTooltip(sel){
sel
.on('mouseover', function(d, i){
ttFnSel
.classed('tooltip-footnote-hidden', 0)
.html(d).select('.footend').remove()
var [x, y] = d3.mouse(d3.select('html').node())
var bb = ttFnSel.node().getBoundingClientRect(),
left = d3.clamp(20, (x-bb.width/2), window.innerWidth - bb.width - 20),
top = innerHeight + scrollY > y + 20 + bb.height ? y + 20 : y - bb.height - 10;
ttFnSel.st({left, top})
})
.on('mousemove', mousemove)
.on('mouseout', mouseout)
ttFnSel
.on('mousemove', mousemove)
.on('mouseout', mouseout)
function mousemove(){
if (window.__ttfade) window.__ttfade.stop()
}
function mouseout(){
if (window.__ttfade) window.__ttfade.stop()
window.__ttfade = d3.timeout(
() => ttFnSel.classed('tooltip-footnote-hidden', 1),
250
)
}
}
})()
|