diff options
| author | Matt Kosarek <matt.kosarek@canonical.com> | 2026-02-18 17:03:06 -0500 |
|---|---|---|
| committer | Matt Kosarek <matt.kosarek@canonical.com> | 2026-02-18 17:03:06 -0500 |
| commit | 59260c4f7a265f1ad4db9e0ee5e469132cdef094 (patch) | |
| tree | 588cf415f8b819a30090b085d9e32b42836d73ca /public/index.js | |
| parent | 2ef049102f6824a6ab6ae99ee87c115f7608707e (diff) | |
minor: publishing from public with a Makefile instead of having everything at the toplevel
Diffstat (limited to 'public/index.js')
| -rw-r--r-- | public/index.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/public/index.js b/public/index.js new file mode 100644 index 0000000..dc25d20 --- /dev/null +++ b/public/index.js @@ -0,0 +1,38 @@ + +function main() { + var themeSelector = document.getElementById('theme_selector'); + themeSelector.classList.remove('hidden'); + + imageCallbacks(); +} + +function imageCallbacks() { + const imageContainer = document.getElementById('image_container'); + + function onImageClicked() { + var background = document.createElement('div'); // + background.classList.add('image_item_expanded_container'); + var clone = this.cloneNode(true); + clone.classList.add('expanded'); + background.append(clone); + clone.addEventListener('click', function(event) { event.stopPropagation(); }); + background.addEventListener('click', function() { background.remove(); }); + window.addEventListener('keydown', function(e) { if (e.key === 'Escape') background.remove(); }); + document.body.parentElement.prepend(background); + } + + function setImageClicked() { + for (var i = 0; i < numImages; i++) { + var image = imageList[i]; + image.addEventListener('click', onImageClicked); + } + } + + // Set up on image clicked + var imageList = imageContainer.children, + numImages = imageContainer.children.length; + + setImageClicked(); +} + +main(); |
