fix cw handling again, maybe???

This commit is contained in:
Rhiannon Morris 2020-09-14 01:34:45 +02:00
parent 2a9e9cfa7b
commit 046dc59834

View file

@ -25,21 +25,23 @@ function addCWListeners(id, caption) {
function setImage(id, src, width, height, href, cw, firstLoad) { function setImage(id, src, width, height, href, cw, firstLoad) {
let caption = document.getElementById('cw'); let caption = document.getElementById('cw');
let cwText = `<span id=cw-text>cw: <b>${cw}</b></span>`; let newCaption;
if (!opened.has(id) && cw && caption) { if (!opened.has(id) && cw) {
caption.innerHTML = cwText;
} else if (caption) {
openCW(id, caption);
} else if (!opened.has(id) && cw) {
let template = document.createElement('template'); let template = document.createElement('template');
template.innerHTML = ` template.innerHTML = `
<figcaption id=cw aria-role=button tabindex=0> <figcaption id=cw aria-role=button tabindex=0>
${cwText} <span id=cw-text>cw: <b>${cw}</b></span>
</figcaption>`; </figcaption>`;
let content = template.content; newCaption = template.content;
addCWListeners(id, content.getElementById('cw')); addCWListeners(id, newCaption.getElementById('cw'));
mainfig.insertBefore(content, mainlink); }
if (caption) {
openCW(null, caption);
}
if (newCaption) {
mainfig.insertBefore(newCaption, mainlink);
mainlink.tabIndex = -1; mainlink.tabIndex = -1;
} }