Skip to content

Commit

Permalink
chore: toast notification after form submission
Browse files Browse the repository at this point in the history
  • Loading branch information
iiio2 committed Mar 18, 2024
1 parent a428c88 commit 5875076
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
href="./fontawesome-free-5.12.1-web/css/all.min.css"
/>
<!-- css -->
<link rel="stylesheet" href="./css//lightbox.min.css" />
<link rel="stylesheet" href="./css/lightbox.min.css" />
<link
rel="stylesheet"
type="text/css"
href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css"
/>
<link rel="stylesheet" href="./css/styles.css" />
</head>
<body>
Expand Down Expand Up @@ -439,6 +444,10 @@ <h3>want lastest tour info & updates</h3>
<!-- js -->
<script type="module" src="./js/jquery.min.js"></script>
<script type="module" src="./js/lightbox.min.js"></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/toastify-js"
></script>
<script type="module" src="./js/app.js"></script>
</body>
</html>
54 changes: 36 additions & 18 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
// ********** navbar toggle ************
const navBtn = document.getElementById("nav-toggle");
const links = document.getElementById("nav-links");
navBtn.addEventListener("click", () => {
links.classList.toggle("show-links");
});

const navBtn = document.getElementById('nav-toggle')
const links = document.getElementById('nav-links')
navBtn.addEventListener('click', () => {
links.classList.toggle('show-links')
})

// ********** set date ************
const date = (document.getElementById("date").innerHTML =
new Date().getFullYear());
const date = (document.getElementById('date').innerHTML =
new Date().getFullYear())

// ********** smooth scroll ************
const scrollLinks = document.querySelectorAll(".scroll-link");
const scrollLinks = document.querySelectorAll('.scroll-link')
scrollLinks.forEach((link) => {
link.addEventListener("click", (e) => {
e.preventDefault();
links.classList.remove("show-links");
link.addEventListener('click', (e) => {
e.preventDefault()
links.classList.remove('show-links')

const id = e.target.getAttribute("href").slice(1);
const element = document.getElementById(id);
let position = element.offsetTop - 62;
const id = e.target.getAttribute('href').slice(1)
const element = document.getElementById(id)
let position = element.offsetTop - 62

window.scrollTo({
left: 0,
top: position,
behavior: "smooth",
});
});
});
behavior: 'smooth',
})
})
})

// ********** toast notification ************
const form = document.querySelector('.contact-form')
const email = document.querySelector('input[name="email"]')

form.addEventListener('submit', function (e) {
e.preventDefault()
if (email.value.trim()) {
Toastify({
text: 'Your email is successfully submitted',
style: {
background: 'rgba(46, 204, 113, 1)',
},
}).showToast()
email.value = ''
}
})

0 comments on commit 5875076

Please sign in to comment.