inital commit
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
AOS.init({
|
||||
once: true
|
||||
});
|
||||
|
||||
// logic responsible for hidding mobile menu
|
||||
|
||||
const offcanvasEl = $('#mobileNavbar');
|
||||
const offcanvas = new bootstrap.Offcanvas(offcanvasEl);
|
||||
let timer;
|
||||
|
||||
$('.nav-link')
|
||||
.each(function (index, el) {
|
||||
el.addEventListener('click', function () {
|
||||
const href = event.target.href;
|
||||
const loc = window.location.href;
|
||||
if (loc.substr(loc.indexOf('#')) === href.substr(href.indexOf('#'))) {
|
||||
scrollEnded();
|
||||
return;
|
||||
}
|
||||
showMenuSpinner();
|
||||
document.addEventListener('scroll', function (event) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(scrollEnded, 200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function scrollEnded() {
|
||||
offcanvas.hide();
|
||||
hideMenuSpinner();
|
||||
}
|
||||
|
||||
function showMenuSpinner() {
|
||||
if ($('#mobileNavbarButton').is(':visible')) {
|
||||
$('#menu-spinner').css('display', 'block');
|
||||
}
|
||||
}
|
||||
|
||||
function hideMenuSpinner() {
|
||||
$('#menu-spinner').css('display', 'none');
|
||||
}
|
||||
|
||||
function showSpinner() {
|
||||
$('#spinner').css('display', 'block');
|
||||
}
|
||||
|
||||
function hideSpinner() {
|
||||
$('#spinner').css('display', 'none');
|
||||
}
|
||||
|
||||
// logic responsible for newsletter
|
||||
$('#newsletter-form-button').on('click', function($event) {
|
||||
const email = $('#newsletter-email').val();
|
||||
const form = $('#newsletter-form');
|
||||
|
||||
if (form[0].checkValidity()) {
|
||||
showSpinner();
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "./newsletter.php",
|
||||
data: {
|
||||
email: email
|
||||
}
|
||||
})
|
||||
.done(function( msg ) {
|
||||
hideSpinner();
|
||||
$('#newsletter-success-alert').addClass('show');
|
||||
form[0].reset();
|
||||
form.removeClass('was-validated');
|
||||
})
|
||||
.fail(function (error) {
|
||||
hideSpinner();
|
||||
$('#newsletter-error-alert').addClass('show');
|
||||
});
|
||||
}
|
||||
form[0].classList.add('was-validated');
|
||||
$event.preventDefault();
|
||||
});
|
||||
|
||||
// logic responsible for contact form
|
||||
|
||||
$('#contact-form-button').on('click', function($event) {
|
||||
const email = $('#email').val();
|
||||
const content = $('#content').val();
|
||||
const form = $('#contact-form');
|
||||
|
||||
if (form[0].checkValidity()) {
|
||||
showSpinner();
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "./contact.php",
|
||||
data: {
|
||||
email: email,
|
||||
content: content
|
||||
}
|
||||
})
|
||||
.done(function( msg ) {
|
||||
hideSpinner();
|
||||
$('#form-success-alert').addClass('show');
|
||||
form[0].reset();
|
||||
form.removeClass('was-validated');
|
||||
})
|
||||
.fail(function (error) {
|
||||
hideSpinner();
|
||||
$('#form-error-alert').addClass('show');
|
||||
});
|
||||
}
|
||||
form[0].classList.add('was-validated');
|
||||
$event.preventDefault();
|
||||
});
|
||||
|
||||
$('.btn-close').click(function () {
|
||||
$('.alert').removeClass('show');
|
||||
});
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user