remove iframe previewer logic
This commit is contained in:
parent
0660137321
commit
f0e50e2541
@ -5,6 +5,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<iframe class="dn" id="link-preview-iframe">
|
|
||||||
</iframe>
|
|
||||||
|
@ -4,7 +4,6 @@ let opacityTimeout
|
|||||||
let contentTimeout
|
let contentTimeout
|
||||||
const transitionDurationMs = 100
|
const transitionDurationMs = 100
|
||||||
|
|
||||||
const iframe = document.getElementById('link-preview-iframe')
|
|
||||||
const tooltipWrapper = document.getElementById('tooltip-wrapper')
|
const tooltipWrapper = document.getElementById('tooltip-wrapper')
|
||||||
const tooltipContent = document.getElementById('tooltip-content')
|
const tooltipContent = document.getElementById('tooltip-content')
|
||||||
|
|
||||||
@ -24,19 +23,22 @@ function showTooltip (event) {
|
|||||||
const top = window.pageYOffset || document.documentElement.scrollTop
|
const top = window.pageYOffset || document.documentElement.scrollTop
|
||||||
|
|
||||||
if (event.target.host === window.location.host) {
|
if (event.target.host === window.location.host) {
|
||||||
iframe.src = event.target.href
|
window.fetch(event.target.href)
|
||||||
iframe.onload = function () {
|
.then(response => response.text())
|
||||||
let tooltipContentHtml = ''
|
.then(data => {
|
||||||
tooltipContentHtml += '<div class="b">' + iframe.contentWindow.document.querySelector('h1').innerHTML + '</div>'
|
const parser = new window.DOMParser()
|
||||||
tooltipContentHtml += iframe.contentWindow.document.querySelector('.note-contents').innerHTML
|
const doc = parser.parseFromString(data, 'text/html')
|
||||||
|
let tooltipContentHtml = ''
|
||||||
|
tooltipContentHtml += '<div class="b">' + doc.querySelector('h1').innerHTML + '</div>'
|
||||||
|
tooltipContentHtml += doc.querySelector('.note-contents').innerHTML
|
||||||
|
|
||||||
tooltipContent.innerHTML = tooltipContentHtml
|
tooltipContent.innerHTML = tooltipContentHtml
|
||||||
|
|
||||||
tooltipWrapper.style.display = 'block'
|
tooltipWrapper.style.display = 'block'
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
tooltipWrapper.style.opacity = 1
|
tooltipWrapper.style.opacity = 1
|
||||||
}, 1)
|
}, 1)
|
||||||
}
|
})
|
||||||
|
|
||||||
tooltipWrapper.style.left = elemProps.left - (tooltipWrapper.offsetWidth / 2) + (elemProps.width / 2) + 'px'
|
tooltipWrapper.style.left = elemProps.left - (tooltipWrapper.offsetWidth / 2) + (elemProps.width / 2) + 'px'
|
||||||
if ((window.innerHeight - elemProps.top) < (tooltipWrapper.offsetHeight)) {
|
if ((window.innerHeight - elemProps.top) < (tooltipWrapper.offsetHeight)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user