Commit 5fde764d authored by Maximilian Sprengholz's avatar Maximilian Sprengholz 😵

Bump to v1.2.0

parent 6a1a39e2
Pipeline #15100 failed with stage
in 28 seconds
......@@ -4,17 +4,60 @@
// Author: Maximilian Sprengholz
var Img_Grid_Lightbox = new function() {
// check if organized in grids or not
let allGrids = document.querySelectorAll('.figure,.subfigures');
if (allGrids.length == 0) {
// console.log(allGrids.length);
allGrids = document.getElementsByTagName('body');
}
let allGrids = [];
let lightbox = false;
let imgIndex = [
src = [],
cap = []
];
// init call to count
this.init = function() {
// check if organized in grids or not
let allGrids = document.querySelectorAll('.figure,.subfigures');
if (allGrids.length == 0) {
// console.log(allGrids.length);
allGrids = document.getElementsByTagName('body');
}
// init for all image grids in document
for (let i=0; i<allGrids.length; i++) {
// console.log('Graph grid: ' + i)
// placeholder arrays per grid (sources and caps)
let imgSrc = [];
let imgCap = [];
// index all images within grid
const allImg = allGrids[i].querySelectorAll('img');
// for all images within a single grid
for (let j=0; j<allImg.length; j++) {
// console.log('Image within grid: ' + j);
// get and push source and figcaption in array
imgSrc.push(allImg[j].getAttribute('src'));
let cap = allGrids[i].querySelectorAll('img[id="' + allImg[j].getAttribute('id') + '"]' + ' + figcaption')[0];
if (cap) {
imgCap.push(cap.innerHTML);
} else {
imgCap.push('');
}
// set attributes that will be fed to lightbox to get sources
allImg[j].setAttribute("gridId", i );
allImg[j].setAttribute("imgId", j );
// add click event listener to open lightbox
allImg[j].addEventListener("click", function(){ Img_Grid_Lightbox.startLightbox(allImg[j]); });
};
// push grid specific arrays in main index
imgIndex[0].push(imgSrc);
imgIndex[1].push(imgCap);
};
// append lightbox container once (after pushing all images in Index)
let lightboxContainer = '<div id="lightbox-container">\n'
lightboxContainer += '<a href="#/" id="lightbox-prev">&#9664;</a>\n'
lightboxContainer += '<a href="#/" id="lightbox-next">&#9654;</a>\n'
lightboxContainer += '<a href="#/" id="lightbox-close">&times;</a>\n'
lightboxContainer += '<div id="lightbox-img-scaler"></div>\n'
lightboxContainer += '<p id="lightbox-legend"></p>\n'
lightboxContainer += '</div>\n'
document.body.insertAdjacentHTML('afterbegin', lightboxContainer)
};
// lightbox functionality
this.startLightbox = function(element) {
// start lightbox and set image source
......@@ -57,47 +100,6 @@ var Img_Grid_Lightbox = new function() {
};
document.body.addEventListener("keyup", keyDown);
};
// initialize
this.init = function() {
// for all image grids in document
for (let i=0; i<allGrids.length; i++) {
// console.log('Graph grid: ' + i)
// placeholder arrays per grid (sources and caps)
let imgSrc = [];
let imgCap = [];
// index all images within grid
const allImg = allGrids[i].querySelectorAll('img');
// for all images within a single grid
for (let j=0; j<allImg.length; j++) {
// console.log('Image within grid: ' + j);
// get and push source and figcaption in array
imgSrc.push(allImg[j].getAttribute('src'));
let cap = allGrids[i].querySelectorAll('img[id="' + allImg[j].getAttribute('id') + '"]' + ' + figcaption')[0];
if (cap) {
imgCap.push(cap.innerHTML);
} else {
imgCap.push('');
}
// set attributes that will be fed to lightbox to get sources
allImg[j].setAttribute("gridId", i );
allImg[j].setAttribute("imgId", j );
// add click event listener to open lightbox
allImg[j].addEventListener("click", function(){ Img_Grid_Lightbox.startLightbox(allImg[j]); });
};
// push grid specific arrays in main index
imgIndex[0].push(imgSrc);
imgIndex[1].push(imgCap);
};
// append lightbox container once (after pushing all images in Index)
let lightboxContainer = '<div id="lightbox-container">\n'
lightboxContainer += '<a href="#/" id="lightbox-prev">&#9664;</a>\n'
lightboxContainer += '<a href="#/" id="lightbox-next">&#9654;</a>\n'
lightboxContainer += '<a href="#/" id="lightbox-close">&times;</a>\n'
lightboxContainer += '<div id="lightbox-img-scaler"></div>\n'
lightboxContainer += '<p id="lightbox-legend"></p>\n'
lightboxContainer += '</div>\n'
document.body.insertAdjacentHTML('afterbegin', lightboxContainer)
};
};
// Init on load
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment