diff --git a/src/css/lightbox.css b/src/css/lightbox.css index 238b636..77d9312 100644 --- a/src/css/lightbox.css +++ b/src/css/lightbox.css @@ -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 = '×\n' + - '
' - - 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() - }) - }) -})()