(function() { "use strict"; window.addEventListener('load', () => { on_page_load() }); /** * Function gets called when page is loaded. */ function on_page_load() { // Initialize On-scroll Animations AOS.init({ anchorPlacement: 'top-left', duration: 600, easing: "ease-in-out", once: true, mirror: false, disable: 'mobile' }); } /** * Navbar effects and scrolltop buttons upon scrolling */ const navbar = document.getElementById('header-nav') var body = document.getElementsByTagName("body")[0] const scrollTop = document.getElementById('scrolltop') window.onscroll = () => { if (window.scrollY > 0) { navbar.classList.add('fixed-top', 'shadow-sm') body.style.paddingTop = navbar.offsetHeight + "px" scrollTop.style.visibility = "visible"; scrollTop.style.opacity = 1; } else { navbar.classList.remove('fixed-top', 'shadow-sm') body.style.paddingTop = "0px" scrollTop.style.visibility = "hidden"; scrollTop.style.opacity = 0; } }; /** * Masonry Grid */ var elem = document.querySelector('.grid'); if(elem) { imagesLoaded(elem, function() { new Masonry(elem, { itemSelector: '.grid-item', percentPosition: true, horizontalOrder: true }); }) } /** * Big Picture Popup for images and videos */ document.querySelectorAll("[data-bigpicture]").forEach((function(e) { e.addEventListener("click", (function(t){ t.preventDefault(); const data =JSON.parse(e.dataset.bigpicture) BigPicture({ el: t.target, ...data }) }) ) })) /** * Big Picture Popup for Photo Gallary */ document.querySelectorAll(".bp-gallery a").forEach((function(e) { var caption = e.querySelector('figcaption') var img = e.querySelector('img') // set the link present on the item to the caption in full view img.dataset.caption = '' + caption.innerHTML + ''; window.console.log(caption, img) e.addEventListener("click", (function(t){ t.preventDefault(); BigPicture({ el: t.target, gallery: '.bp-gallery', }) }) ) })) // Add your javascript here // document.getElementById("form-button").addEventListener("click", function () { // var form = document.getElementById("message-form"); // console.log('helooooo......'); // submit(form); // }); document.addEventListener("submit", (e) => { // Store reference to form to make later code easier to read const form = e.target; // Post data using the Fetch API fetch(form.action, { method: form.method, body: new FormData(form), }); // Prevent the default form submit e.preventDefault(); form.reset(); swal("Alright!", "I've heard you. Thanks for your message!", "success"); }); async function submit(form) { console.log('inside async..'); if (form !== undefined) { // Validation succeeded, submit the form form.submit(); } } })();