Skip to content

Commit

Permalink
try fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieuremre committed Sep 11, 2024
1 parent bf12e28 commit b7c4835
Showing 1 changed file with 0 additions and 59 deletions.
59 changes: 0 additions & 59 deletions src/css/lightbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,62 +61,3 @@ img.lightbox {
text-decoration: none;
cursor: pointer;
}
src/css/site.css
+
1
0
@@ -14,4 +14,5 @@
@import "header.css";
@import "footer.css";
@import "highlight.css";
@import "lightbox.css";
@import "print.css";
src/js/06-lightbox.js 0 → 100644
+
43
0
;(function () {
'use strict'
var lightbox

function init () {
if (!lightbox) {
lightbox = document.createElement('div')
lightbox.className = 'modal'
lightbox.innerHTML = '<span class="close cursor">&times;</span>\n' +
' <div class="modal-content">\n' +
' <img alt="filled at runtime">\n' +
' </div>'

var footer = document.getElementsByTagName('footer')[0]
footer.parentNode.insertBefore(lightbox, footer.nextSibling)

lightbox.getElementsByTagName('div')[0].onclick = closeModal
lightbox.getElementsByTagName('span')[0].onclick = closeModal
}
}

function openModal () {
lightbox.style.display = 'block'
}

function closeModal () {
lightbox.style.display = 'none'
}

document.querySelectorAll('.imageblock img').forEach(function (element) {
if (element.parentNode.nodeName === 'A') {
// if parent node is an anchor, keep the anchor instead of opening lightbox
return
}
element.className += ' lightbox'
element.addEventListener('click', function (evt) {
init()
lightbox.getElementsByTagName('img')[0].setAttribute('src', evt.currentTarget.getAttribute('src'))
lightbox.getElementsByTagName('img')[0].setAttribute('alt', evt.currentTarget.getAttribute('alt'))
openModal()
})
})
})()

0 comments on commit b7c4835

Please sign in to comment.