Fix lightbox script, Update example content

This commit is contained in:
Patrick Neff 2019-01-08 23:42:24 +01:00
parent 99545a988b
commit 57afeb1b10
3 changed files with 28 additions and 4 deletions

View File

@ -4,6 +4,20 @@ date = "2019-01-08T19:30:48+01:00"
draft = true
type = "page"
keywords = []
[[resources]]
src = "bilder/bild-1.jpg"
title = "Bild 1"
[resources.params]
alt = "Alt Bild 1"
description = "Description Bild 1"
[[resources]]
src = "bilder/bild-2.jpg"
title = "Bild 2"
[resources.params]
alt = "Alt Bild 2"
description = "Description Bild 2"
+++
# Text

File diff suppressed because one or more lines are too long

View File

@ -11,12 +11,17 @@ class Lightbox {
this.element = images[idx];
this.figure = this.element.parentElement;
this.image = this.element.firstChild;
this.title = this.figure.querySelector('h3').innerHTML
this.description = this.figure.querySelector('.description p').innerHTML
this.title = this.figure.querySelector('h3')
this.title = this.image.getAttribute('title')
this.description = this.figure.querySelector('.description p')
if (this.description !== null) {
this.description = this.description.innerHTML
}
this.href = this.element.getAttribute('href')
this.alt = this.image.getAttribute('alt')
this.template = template.cloneNode(true);
console.log(this.title);
}
update() {
@ -47,7 +52,12 @@ class Lightbox {
img.setAttribute('alt', this.alt);
let title = lightbox.querySelector('.lightbox-title');
let description = lightbox.querySelector('.lightbox-footer');
if (this.title !== null) {
title.innerHTML = this.title;
}
else {
title.innerHtml = this.alt;
}
if (this.description !== null) {
description.innerHTML = this.description;
}