Skip to content

Commit

Permalink
Merge pull request apu52#516 from Ramben0909/mySite
Browse files Browse the repository at this point in the history
I have fixed the modal window
  • Loading branch information
apu52 authored May 21, 2024
2 parents 90f2c8b + 418704f commit 0755ad2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
20 changes: 15 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function sendMail() {
// Modal JS

const modalContainer = document.querySelector(".modal-container");
const closeBtn = document.querySelector("#close-btn");
const closeBtn = document.querySelector(".close-btn");
const subscribeBtn = document.querySelector("#news-subscribe");
const form = document.querySelector("#modal-form");

Expand All @@ -41,15 +41,25 @@ function subscribe(e) {
e.preventDefault();
const emailInput = document.querySelector("#modal-email").value;
// You can add your logic to handle the form submission here
// alert("Email subscribed: "+emailInput);
// alert("Email subscribed: " + emailInput);
closeModal();
}

form.addEventListener("submit", subscribe)
// closeBtn.addEventListener("click", closeModal);
// Close the modal when clicking outside the modal content (new code)
window.addEventListener("click", (e) => {
if (e.target === modalContainer) {
closeModal();
}
});

// Close the modal when clicking the exit button (new code)
closeBtn.addEventListener("click", closeModal);

form.addEventListener("submit", subscribe);
closeBtn.addEventListener("click", closeModal);

// Open the modal as soon as the page loads
window.onload = openModal();
window.onload = openModal;


// carousel JS
Expand Down

0 comments on commit 0755ad2

Please sign in to comment.