-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/colors
- Loading branch information
Showing
13 changed files
with
218 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function theme() { | ||
if (document.body.classList.toggle('light')) { | ||
document.cookie = 'theme=light; Path=/'; | ||
} else { | ||
document.cookie = 'theme=; Path=/; Max-Age=0'; | ||
} | ||
} | ||
|
||
document.onkeydown = function(e) { | ||
switch (e.key) { | ||
case 'ArrowRight': document.location.href = document.querySelector('a.next').href; break; | ||
case 'ArrowLeft': document.location.href = document.querySelector('a.previous').href; break; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,41 @@ | ||
const lightbox = { | ||
$element : document.querySelector('#lightbox'), | ||
show : function($link) { | ||
const $full = lightbox.$element.querySelector('img'); | ||
class Lightbox { | ||
|
||
/** Opens the given lightbox, loading the image and filling in meta data */ | ||
#open($target, $link) { | ||
const $full = $target.querySelector('img'); | ||
$full.src = ''; | ||
lightbox.$element.classList.add('open'); | ||
$target.classList.add('open'); | ||
$full.src = $link.href; | ||
|
||
// Overlay meta data if present | ||
const $img = $link.querySelector('img'); | ||
const $meta = lightbox.$element.querySelector('.meta'); | ||
const $meta = $target.querySelector('.meta'); | ||
if ('' !== ($img.dataset.make ?? '')) { | ||
$meta.querySelectorAll('output').forEach($o => $o.value = $img.dataset[$o.name]); | ||
$meta.style.visibility = 'visible'; | ||
} else { | ||
$meta.style.visibility = 'hidden'; | ||
} | ||
} | ||
|
||
return false; | ||
}, | ||
close : function() { | ||
lightbox.$element.classList.remove('open'); | ||
/** Closes the given lightbox */ | ||
#close($target) { | ||
$target.classList.remove('open'); | ||
} | ||
}; | ||
|
||
document.onkeydown = function(e) { | ||
switch (e.key) { | ||
case 'ArrowRight': document.location.href = document.querySelector('a.next').href; break; | ||
case 'ArrowLeft': document.location.href = document.querySelector('a.previous').href; break; | ||
case 'Escape': lightbox.close(); break; | ||
/** Attach all of the given elements to open the lightbox specified by the given DOM element */ | ||
attach(selector, $target) { | ||
document.addEventListener('keydown', e => { | ||
if ('Escape' === e.key) this.#close($target); | ||
}); | ||
|
||
$target.addEventListener('click', e => { | ||
this.#close($target); | ||
}); | ||
|
||
selector.forEach($link => $link.addEventListener('click', e => { | ||
e.preventDefault(); | ||
this.#open($target, $link); | ||
})); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.