added dynamic script for gallery generation
This commit is contained in:
parent
f2e1d0ea12
commit
95d2cbfccb
BIN
assets/pics/centerpiece/centerpiece-cover.webp
Normal file
BIN
assets/pics/centerpiece/centerpiece-cover.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 932 KiB |
1
assets/pics/classic/ceiling.txt
Normal file
1
assets/pics/classic/ceiling.txt
Normal file
@ -0,0 +1 @@
|
||||
Ceiling Fill
|
||||
1
assets/pics/classic/classic-cover.txt
Normal file
1
assets/pics/classic/classic-cover.txt
Normal file
@ -0,0 +1 @@
|
||||
30ft Areopole Arch
|
||||
BIN
assets/pics/organic/organic-cover.webp
Normal file
BIN
assets/pics/organic/organic-cover.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
BIN
assets/pics/sculptures/sculpture-cover.webp
Normal file
BIN
assets/pics/sculptures/sculpture-cover.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
0
gallery/centerpiece/index.html
Normal file
0
gallery/centerpiece/index.html
Normal file
100
gallery/classic.html
Normal file
100
gallery/classic.html
Normal file
@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="../assets/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="../assets/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../assets/favicon/favicon-16x16.png">
|
||||
<link rel="manifest" href="../assets/favicon/site.webmanifest">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Beach Party Balloons - Gallery</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Autour+One&family=Mogra&family=Rubik+Glitch&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../style.css">
|
||||
<style>
|
||||
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; padding: 20px; max-width: 1200px; margin: auto; }
|
||||
.gallery-item { text-align: center; }
|
||||
.gallery img { width: 100%; height: 200px; object-fit: cover; border-radius: 10px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
|
||||
.gallery img:hover { transform: scale(1.05); box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2); }
|
||||
.caption { font-size: 0.9rem; margin-top: 5px; color: #4a4a4a; font-family: 'Autour One', cursive; }
|
||||
.lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); display: none; justify-content: center; align-items: center; z-index: 1000; }
|
||||
.lightbox img { max-width: 90%; max-height: 80%; border-radius: 10px; }
|
||||
.lightbox:target { display: flex; }
|
||||
.close { position: absolute; top: 20px; right: 30px; font-size: 30px; color: white; text-decoration: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar is-info is-spaced has-shadow" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand is-size-1">
|
||||
<a class="navbar-item" href="../index.html">
|
||||
<img style="background-color: white;" src="../assets/logo/BeachPartyBalloons-logo.png" alt="Beach Party Balloons logo">
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="navbarBasicExample" class="navbar-menu has-text-right">
|
||||
<div class="navbar-end">
|
||||
<a class="navbar-item" href="../index.html">Home</a>
|
||||
<a class="navbar-item" href="../about/index.html">About Us</a>
|
||||
<a class="navbar-item" href="../faq/index.html">FAQ</a>
|
||||
<a class="navbar-item" href="../terms/index.html">Terms</a>
|
||||
<a class="navbar-item is-tab is-active" href="../gallery/index.html">Gallery</a>
|
||||
<a class="navbar-item" href="../contact/index.html">Contact</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title has-text-centered is-dark">Organic</h1>
|
||||
<div class="gallery">
|
||||
<div class="gallery-item">
|
||||
<a href="#lightbox1"><img src="../assets/pics/organic/img1.webp" alt=""></a>
|
||||
<p class="caption"></p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<a href="#lightbox2"><img src="../assets/pics/organic/img2.webp" alt=""></a>
|
||||
<p class="caption"></p>
|
||||
</div>
|
||||
<div class="gallery-item">
|
||||
<a href="#lightbox3"><img src="../assets/pics/organic/organic-cover.webp" alt=""></a>
|
||||
<p class="caption"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div id="lightbox1" class="lightbox">
|
||||
<a href="#" class="close">×</a>
|
||||
<img src="../assets/pics/organic/img1.webp" alt="">
|
||||
<p class="caption" style="color: white; text-align: center; margin-top: 10px;"></p>
|
||||
</div>
|
||||
<div id="lightbox2" class="lightbox">
|
||||
<a href="#" class="close">×</a>
|
||||
<img src="../assets/pics/organic/img2.webp" alt="">
|
||||
<p class="caption" style="color: white; text-align: center; margin-top: 10px;"></p>
|
||||
</div>
|
||||
<div id="lightbox3" class="lightbox">
|
||||
<a href="#" class="close">×</a>
|
||||
<img src="../assets/pics/organic/organic-cover.webp" alt="">
|
||||
<p class="caption" style="color: white; text-align: center; margin-top: 10px;"></p>
|
||||
</div>
|
||||
|
||||
<footer class="footer has-background-primary-light">
|
||||
<div class="content has-text-centered">
|
||||
<h7>Copyright © <span id="year"></span> Beach Party Balloons</h7>
|
||||
<h7>All images & content are property of Beach Party Balloons. Use of images without written permission is prohibited.</h7>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div id="footer"></div>
|
||||
<script src="../script.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
127
gallery/classic/index.html
Normal file
127
gallery/classic/index.html
Normal file
@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="../../assets/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="../../assets/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../../assets/favicon/favicon-16x16.png">
|
||||
<link rel="manifest" href="../../assets/favicon/site.webmanifest">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Beach Party Balloons</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Autour+One&family=Mogra&family=Rubik+Glitch&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../../style.css">
|
||||
<link href="../../lightbox.css" rel="stylesheet" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-info is-spaced has-shadow" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand is-size-1">
|
||||
<a class="navbar-item" href="../../index.html">
|
||||
<img style="background-color: white;" src="../../assets/logo/BeachPartyBalloons-logo.png" alt="Beach Party Balloons logo">
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="navbarBasicExample" class="navbar-menu has-text-right">
|
||||
<div class="navbar-end">
|
||||
<a class="navbar-item " href="../../index.html">
|
||||
Home
|
||||
</a>
|
||||
|
||||
<a class="navbar-item" href="../../about/index.html">
|
||||
About Us
|
||||
</a>
|
||||
<a class="navbar-item" href="../../faq/index.html">
|
||||
FAQ
|
||||
</a>
|
||||
<a class="navbar-item" href="../../terms/index.html">
|
||||
Terms
|
||||
</a>
|
||||
<!-- <div class="navbar-item "> -->
|
||||
<a class="navbar-item is-tab is-active" href="../../gallery/index.html">
|
||||
Gallery
|
||||
</a>
|
||||
|
||||
<a class="navbar-item" href="../../contact/index.html">
|
||||
Contact
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="navbar-end">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title has-text-centered">Modern Bulma Gallery</h1>
|
||||
<div class="gallery">
|
||||
<a href="#lightbox1"><img src="../../assets/pics/classic/20240825_104716.webp" alt="Gallery Image"></a>
|
||||
<a href="#lightbox2"><img src="../../assets/pics/classic/hero.jpg" alt="Gallery Image"></a>
|
||||
<a href="#lightbox3"><img src="https://source.unsplash.com/random/802x602" alt="Gallery Image"></a>
|
||||
<a href="#lightbox4"><img src="https://source.unsplash.com/random/803x603" alt="Gallery Image"></a>
|
||||
<a href="#lightbox5"><img src="https://source.unsplash.com/random/804x604" alt="Gallery Image"></a>
|
||||
<a href="#lightbox6"><img src="https://source.unsplash.com/random/805x605" alt="Gallery Image"></a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Lightbox Overlays -->
|
||||
<div id="lightbox1" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/800x600" alt="Gallery Image">
|
||||
</div>
|
||||
<div id="lightbox2" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/801x601" alt="Gallery Image">
|
||||
</div>
|
||||
<div id="lightbox3" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/802x602" alt="Gallery Image">
|
||||
</div>
|
||||
<div id="lightbox4" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/803x603" alt="Gallery Image">
|
||||
</div>
|
||||
<div id="lightbox5" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/804x604" alt="Gallery Image">
|
||||
</div>
|
||||
<div id="lightbox6" class="lightbox">
|
||||
<a href="#" class="close"><i class="fas fa-times"></i></a>
|
||||
<img src="https://source.unsplash.com/random/805x605" alt="Gallery Image">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<footer class="footer has-background-primary-light">
|
||||
<div class="content has-text-centered">
|
||||
<h7>Copyright © <span id="year"></span> Beach Party Balloons</h7>
|
||||
<h7>All images & content are property of Beach Party Balloons. Use of images without written permission is prohibited.</h7>
|
||||
</div>
|
||||
</footer>
|
||||
<div id="footer"></div>
|
||||
<script src="../../script.js"></script>
|
||||
<script src="../../lightbox-plus-jquery.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -73,13 +73,14 @@
|
||||
<div class="image-container">
|
||||
<img class="image is-16by9" src="../assets/pics/classic/classic-cover.webp" alt="">
|
||||
<div class="overlay">
|
||||
<p class="has-text-white has-text-weight-bold is-size-2-desktop">Classic Balloon Décor</p>
|
||||
<a href="classic/index.html"><p class="has-text-white has-text-weight-bold is-size-2-desktop">Classic Balloon Décor</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="image-container">
|
||||
<img class="image is-16by9" src="../assets/pics/classic/20240825_104716.webp" alt="">
|
||||
<img class="image is-16by9" src="../assets/pics/organic/organic-cover.webp" alt="">
|
||||
<div class="overlay">
|
||||
<p class="has-text-white has-text-weight-bold is-size-2-desktop">Organic Balloon Décor</p>
|
||||
</div>
|
||||
@ -89,7 +90,7 @@
|
||||
<div class="columns is-desktop">
|
||||
<div class="column">
|
||||
<div class="image-container">
|
||||
<img class="image is-16by9" src="../assets/pics/classic/hero.jpg" alt="">
|
||||
<img class="image is-16by9" src="../assets/pics/centerpiece/centerpiece-cover.webp" alt="">
|
||||
<div class="overlay">
|
||||
<p class="has-text-white has-text-weight-bold is-size-2-desktop">Centerpieces</p>
|
||||
</div>
|
||||
@ -97,7 +98,7 @@
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="image-container">
|
||||
<img class="image is-16by9" src="../assets/pics/classic/20240825_104716.webp" alt="">
|
||||
<img class="image is-16by9" src="../assets/pics/sculptures/sculpture-cover.webp" alt="">
|
||||
<div class="overlay">
|
||||
<p class="has-text-white has-text-weight-bold is-size-2-desktop">Sculptures & Themes</p>
|
||||
</div>
|
||||
|
||||
0
gallery/organic/index.html
Normal file
0
gallery/organic/index.html
Normal file
0
gallery/sculpture/index.html
Normal file
0
gallery/sculpture/index.html
Normal file
144
gallery/updateGallery.sh
Executable file
144
gallery/updateGallery.sh
Executable file
@ -0,0 +1,144 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory where images are stored
|
||||
IMAGE_DIR="../assets/pics/organic"
|
||||
OUTPUT_FILE="classic.html"
|
||||
|
||||
# Ensure the images directory exists
|
||||
if [ ! -d "$IMAGE_DIR" ]; then
|
||||
echo "Error: Directory '$IMAGE_DIR' not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start writing the HTML file
|
||||
cat > "$OUTPUT_FILE" <<EOL
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="../assets/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="../assets/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../assets/favicon/favicon-16x16.png">
|
||||
<link rel="manifest" href="../assets/favicon/site.webmanifest">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Beach Party Balloons - Gallery</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Autour+One&family=Mogra&family=Rubik+Glitch&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../style.css">
|
||||
<style>
|
||||
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; padding: 20px; max-width: 1200px; margin: auto; }
|
||||
.gallery-item { text-align: center; }
|
||||
.gallery img { width: 100%; height: 200px; object-fit: cover; border-radius: 10px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
|
||||
.gallery img:hover { transform: scale(1.05); box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.2); }
|
||||
.caption { font-size: 0.9rem; margin-top: 5px; color: #4a4a4a; font-family: 'Autour One', cursive; }
|
||||
.lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); display: none; justify-content: center; align-items: center; z-index: 1000; }
|
||||
.lightbox img { max-width: 90%; max-height: 80%; border-radius: 10px; }
|
||||
.lightbox:target { display: flex; }
|
||||
.close { position: absolute; top: 20px; right: 30px; font-size: 30px; color: white; text-decoration: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar is-info is-spaced has-shadow" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand is-size-1">
|
||||
<a class="navbar-item" href="../index.html">
|
||||
<img style="background-color: white;" src="../assets/logo/BeachPartyBalloons-logo.png" alt="Beach Party Balloons logo">
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="navbarBasicExample" class="navbar-menu has-text-right">
|
||||
<div class="navbar-end">
|
||||
<a class="navbar-item" href="../index.html">Home</a>
|
||||
<a class="navbar-item" href="../about/index.html">About Us</a>
|
||||
<a class="navbar-item" href="../faq/index.html">FAQ</a>
|
||||
<a class="navbar-item" href="../terms/index.html">Terms</a>
|
||||
<a class="navbar-item is-tab is-active" href="../gallery/index.html">Gallery</a>
|
||||
<a class="navbar-item" href="../contact/index.html">Contact</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title has-text-centered is-dark">Organic</h1>
|
||||
<div class="gallery">
|
||||
EOL
|
||||
|
||||
# Add images dynamically with captions
|
||||
count=1
|
||||
for img in "$IMAGE_DIR"/*.{jpg,jpeg,png,gif,webp}; do
|
||||
if [[ -f "$img" ]]; then
|
||||
filename=$(basename "$img")
|
||||
caption_file="${img%.*}.txt"
|
||||
|
||||
# Read caption if available, otherwise use default
|
||||
if [[ -f "$caption_file" ]]; then
|
||||
caption=$(cat "$caption_file")
|
||||
else
|
||||
caption=""
|
||||
fi
|
||||
|
||||
echo " <div class=\"gallery-item\">" >> "$OUTPUT_FILE"
|
||||
echo " <a href=\"#lightbox$count\"><img src=\"$IMAGE_DIR/$filename\" alt=\"$caption\"></a>" >> "$OUTPUT_FILE"
|
||||
echo " <p class=\"caption\">$caption</p>" >> "$OUTPUT_FILE"
|
||||
echo " </div>" >> "$OUTPUT_FILE"
|
||||
|
||||
count=$((count+1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Add closing tags for the gallery
|
||||
cat >> "$OUTPUT_FILE" <<EOL
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
EOL
|
||||
|
||||
# Add lightbox overlays with captions
|
||||
count=1
|
||||
for img in "$IMAGE_DIR"/*.{jpg,jpeg,png,gif,webp}; do
|
||||
if [[ -f "$img" ]]; then
|
||||
filename=$(basename "$img")
|
||||
caption_file="${img%.*}.txt"
|
||||
|
||||
if [[ -f "$caption_file" ]]; then
|
||||
caption=$(cat "$caption_file")
|
||||
else
|
||||
caption=""
|
||||
fi
|
||||
|
||||
echo " <div id=\"lightbox$count\" class=\"lightbox\">" >> "$OUTPUT_FILE"
|
||||
echo " <a href=\"#\" class=\"close\">×</a>" >> "$OUTPUT_FILE"
|
||||
echo " <img src=\"$IMAGE_DIR/$filename\" alt=\"$caption\">" >> "$OUTPUT_FILE"
|
||||
echo " <p class=\"caption\" style=\"color: white; text-align: center; margin-top: 10px;\">$caption</p>" >> "$OUTPUT_FILE"
|
||||
echo " </div>" >> "$OUTPUT_FILE"
|
||||
|
||||
count=$((count+1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Finish the HTML file
|
||||
cat >> "$OUTPUT_FILE" <<EOL
|
||||
|
||||
<footer class="footer has-background-primary-light">
|
||||
<div class="content has-text-centered">
|
||||
<h7>Copyright © <span id="year"></span> Beach Party Balloons</h7>
|
||||
<h7>All images & content are property of Beach Party Balloons. Use of images without written permission is prohibited.</h7>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div id="footer"></div>
|
||||
<script src="../script.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOL
|
||||
|
||||
echo "Gallery generated with captions! Open $OUTPUT_FILE in your browser."
|
||||
115
script.js
115
script.js
@ -33,3 +33,118 @@ document.addEventListener("load", function () {
|
||||
document.querySelectorAll("formFooter").style.display = "none";
|
||||
});
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Close lightbox when clicking outside the image
|
||||
document.querySelectorAll(".lightbox").forEach(function (lightbox) {
|
||||
lightbox.addEventListener("click", function (event) {
|
||||
if (event.target === lightbox) {
|
||||
window.location.hash = ""; // Close lightbox
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Close lightbox when pressing Escape key
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (event.key === "Escape") {
|
||||
window.location.hash = ""; // Close lightbox
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
let images = Array.from(document.querySelectorAll(".gallery-item a"));
|
||||
let lightboxImages = images.map(img => img.getAttribute("href"));
|
||||
let currentIndex = 0;
|
||||
|
||||
function openLightbox(index) {
|
||||
currentIndex = index;
|
||||
let lightbox = document.getElementById("lightbox");
|
||||
if (!lightbox) {
|
||||
lightbox = document.createElement("div");
|
||||
lightbox.id = "lightbox";
|
||||
lightbox.className = "lightbox";
|
||||
lightbox.innerHTML = `
|
||||
<a href="#" class="close">×</a>
|
||||
<img id="lightbox-img" src="" alt="">
|
||||
<p id="lightbox-caption" class="caption" style="color: white; text-align: center; margin-top: 10px;"></p>
|
||||
`;
|
||||
document.body.appendChild(lightbox);
|
||||
}
|
||||
|
||||
let lightboxImg = document.getElementById("lightbox-img");
|
||||
let lightboxCaption = document.getElementById("lightbox-caption");
|
||||
let caption = images[currentIndex].parentElement.querySelector(".caption").textContent;
|
||||
|
||||
lightboxImg.src = images[currentIndex].querySelector("img").src;
|
||||
lightboxCaption.textContent = caption;
|
||||
lightbox.style.display = "flex";
|
||||
|
||||
document.getElementById("prev").onclick = () => navigateLightbox(-1);
|
||||
document.getElementById("next").onclick = () => navigateLightbox(1);
|
||||
}
|
||||
|
||||
function navigateLightbox(direction) {
|
||||
currentIndex += direction;
|
||||
if (currentIndex < 0) currentIndex = images.length - 1;
|
||||
if (currentIndex >= images.length) currentIndex = 0;
|
||||
|
||||
let lightboxImg = document.getElementById("lightbox-img");
|
||||
let lightboxCaption = document.getElementById("lightbox-caption");
|
||||
|
||||
lightboxImg.src = images[currentIndex].querySelector("img").src;
|
||||
lightboxCaption.textContent = images[currentIndex].parentElement.querySelector(".caption").textContent;
|
||||
}
|
||||
|
||||
// Open lightbox when clicking a thumbnail
|
||||
images.forEach((img, index) => {
|
||||
img.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
openLightbox(index);
|
||||
});
|
||||
});
|
||||
|
||||
// Close lightbox when clicking outside the image
|
||||
document.addEventListener("click", (event) => {
|
||||
if (event.target.classList.contains("lightbox")) {
|
||||
document.getElementById("lightbox").style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
// Close lightbox with Escape key, navigate with Left/Right arrows
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape") {
|
||||
document.getElementById("lightbox").style.display = "none";
|
||||
} else if (event.key === "ArrowRight") {
|
||||
navigateLightbox(1);
|
||||
} else if (event.key === "ArrowLeft") {
|
||||
navigateLightbox(-1);
|
||||
}
|
||||
});
|
||||
|
||||
// Swipe gestures for mobile
|
||||
let touchStartX = 0;
|
||||
let touchEndX = 0;
|
||||
|
||||
document.addEventListener("touchstart", (event) => {
|
||||
touchStartX = event.changedTouches[0].screenX;
|
||||
});
|
||||
|
||||
document.addEventListener("touchend", (event) => {
|
||||
touchEndX = event.changedTouches[0].screenX;
|
||||
handleSwipe();
|
||||
});
|
||||
|
||||
function handleSwipe() {
|
||||
let swipeDistance = touchStartX - touchEndX;
|
||||
if (swipeDistance > 50) {
|
||||
navigateLightbox(1); // Swipe left → Next image
|
||||
} else if (swipeDistance < -50) {
|
||||
navigateLightbox(-1); // Swipe right → Previous image
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user