(function () { "use strict"; window.onload = function () { window.setTimeout(fadeout, 200); } function fadeout() { document.querySelector('.preloader').style.opacity = '0'; document.querySelector('.preloader').style.display = 'none'; } /*===================================== Sticky ======================================= */ window.onscroll = function () { var header_navbar = document.querySelector(".navbar-area"); var sticky = header_navbar.offsetTop; var logo = document.querySelector('.navbar-brand img'); if (window.pageYOffset > sticky) { header_navbar.classList.add("sticky"); logo.src = 'assets/img/2movie2.png'; } else { header_navbar.classList.remove("sticky"); logo.src = 'assets/img/2movie2.png'; } var backToTo = document.querySelector(".scroll-top"); if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) { backToTo.style.display = "block"; } else { backToTo.style.display = "none"; } }; tns({ container: '.client-logo-carousel', slideBy: 'page', autoplay: true, autoplayButtonOutput: false, mouseDrag: true, gutter: 15, nav: false, controls: false, responsive: { 0: { items: 1, }, 540: { items: 2, }, 768: { items: 3, }, 992: { items: 4, } } }); var wow = new WOW({ mobile: false }); wow.init(); var cu = new counterUp({ start: 0, duration: 2000, intvalues: true, interval: 100, }); cu.start(); imagesLoaded('#container', function () { var elem = document.querySelector('.grid'); var iso = new Isotope(elem, { itemSelector: '.grid-item', masonry: { columnWidth: '.grid-item' } }); let filterButtons = document.querySelectorAll('.portfolio-btn-wrapper button'); filterButtons.forEach(e => e.addEventListener('click', () => { let filterValue = event.target.getAttribute('data-filter'); iso.arrange({ filter: filterValue }); })); }); var elements = document.getElementsByClassName("portfolio-btn"); for (var i = 0; i < elements.length; i++) { elements[i].onclick = function () { var el = elements[0]; while (el) { if (el.tagName === "BUTTON") { el.classList.remove("active"); } el = el.nextSibling; } this.classList.add("active"); }; } var pageLink = document.querySelectorAll('.page-scroll'); pageLink.forEach(elem => { elem.addEventListener('click', e => { e.preventDefault(); document.querySelector(elem.getAttribute('href')).scrollIntoView({ behavior: 'smooth', offsetTop: 1 - 60, }); }); }); function onScroll(event) { var sections = document.querySelectorAll('.page-scroll'); var scrollPos = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; for (var i = 0; i < sections.length; i++) { var currLink = sections[i]; var val = currLink.getAttribute('href'); var refElement = document.querySelector(val); var scrollTopMinus = scrollPos + 73; if (refElement.offsetTop <= scrollTopMinus && (refElement.offsetTop + refElement.offsetHeight > scrollTopMinus)) { document.querySelector('.page-scroll').classList.remove('active'); currLink.classList.add('active'); } else { currLink.classList.remove('active'); } } }; window.document.addEventListener('scroll', onScroll); let navbarToggler = document.querySelector(".navbar-toggler"); var navbarCollapse = document.querySelector(".navbar-collapse"); document.querySelectorAll(".page-scroll").forEach(e => e.addEventListener("click", () => { navbarToggler.classList.remove("active"); navbarCollapse.classList.remove('show') })); navbarToggler.addEventListener('click', function () { navbarToggler.classList.toggle("active"); }); const myGallery = GLightbox({ 'type': 'image', }); const contactForm = document.getElementById('contact-form'); contactForm.addEventListener('submit', function (e) { e.preventDefault(); const fieldName = document.getElementById('input-name'); const fieldEmail = document.getElementById('input-email'); const fieldPhone = document.getElementById('input-phone'); const fieldSubject = document.getElementById('input-subject'); const fieldMessage = document.getElementById('input-message'); const data = { name: fieldName.value, email: fieldEmail.value, phone: fieldPhone.value, subject: fieldSubject.value, message: fieldMessage.value }; const url = 'https://siteapi.2movie.com.br/contact'; const options = { body: JSON.stringify(data), headers: { 'Content-Type': 'application/json; charset=UTF-8' }, method: 'POST' }; fetch(url, options) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch((error) => { console.error('Error:', error); }); }); })();