From b2f9d8ac70920adc2c850bc626d9f2eb9e208a14 Mon Sep 17 00:00:00 2001 From: Gilson Javier Date: Sun, 29 Dec 2019 22:00:17 +0000 Subject: [PATCH] Actualizar 'js/main.js' --- js/main.js | 133 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 54 deletions(-) diff --git a/js/main.js b/js/main.js index bcdc72a..46ae352 100644 --- a/js/main.js +++ b/js/main.js @@ -1,54 +1,79 @@ -function loadMap() { - var site = "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d1580.5054989176758!2d-0.9796837724532329!3d37.60190018337746!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd6341863c83cf8f%3A0xe24278be476b56b8!2sFOSC!5e0!3m2!1ses!2ses!4v1544058887076"; - document.getElementById('map').src = site; -} - -document.addEventListener("DOMContentLoaded", function() { - var lazyloadImages; - - if ("IntersectionObserver" in window) { - lazyloadImages = document.querySelectorAll(".lazy"); - var imageObserver = new IntersectionObserver(function(entries, observer) { - entries.forEach(function(entry) { - if (entry.isIntersecting) { - var image = entry.target; - image.src = image.dataset.src; - image.classList.remove("lazy"); - imageObserver.unobserve(image); - } - }); - }); - - lazyloadImages.forEach(function(image) { - imageObserver.observe(image); - }); - } else { - var lazyloadThrottleTimeout; - lazyloadImages = document.querySelectorAll(".lazy"); - - function lazyload () { - if(lazyloadThrottleTimeout) { - clearTimeout(lazyloadThrottleTimeout); - } - - lazyloadThrottleTimeout = setTimeout(function() { - var scrollTop = window.pageYOffset; - lazyloadImages.forEach(function(img) { - if(img.offsetTop < (window.innerHeight + scrollTop)) { - img.src = img.dataset.src; - img.classList.remove('lazy'); - } - }); - if(lazyloadImages.length == 0) { - document.removeEventListener("scroll", lazyload); - window.removeEventListener("resize", lazyload); - window.removeEventListener("orientationChange", lazyload); - } - }, 20); - } - - document.addEventListener("scroll", lazyload); - window.addEventListener("resize", lazyload); - window.addEventListener("orientationChange", lazyload); - } -}) \ No newline at end of file +function loadMap() { + var site = "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d1580.5054989176758!2d-0.9796837724532329!3d37.60190018337746!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd6341863c83cf8f%3A0xe24278be476b56b8!2sFOSC!5e0!3m2!1ses!2ses!4v1544058887076"; + document.getElementById('map').src = site; +} + +document.addEventListener("DOMContentLoaded", function() { + var lazyloadImages; + + if ("IntersectionObserver" in window) { + lazyloadImages = document.querySelectorAll(".lazy"); + var imageObserver = new IntersectionObserver(function(entries, observer) { + entries.forEach(function(entry) { + if (entry.isIntersecting) { + var image = entry.target; + image.src = image.dataset.src; + image.classList.remove("lazy"); + imageObserver.unobserve(image); + } + }); + }); + + lazyloadImages.forEach(function(image) { + imageObserver.observe(image); + }); + } else { + var lazyloadThrottleTimeout; + lazyloadImages = document.querySelectorAll(".lazy"); + + function lazyload () { + if(lazyloadThrottleTimeout) { + clearTimeout(lazyloadThrottleTimeout); + } + + lazyloadThrottleTimeout = setTimeout(function() { + var scrollTop = window.pageYOffset; + lazyloadImages.forEach(function(img) { + if(img.offsetTop < (window.innerHeight + scrollTop)) { + img.src = img.dataset.src; + img.classList.remove('lazy'); + } + }); + if(lazyloadImages.length == 0) { + document.removeEventListener("scroll", lazyload); + window.removeEventListener("resize", lazyload); + window.removeEventListener("orientationChange", lazyload); + } + }, 20); + } + + document.addEventListener("scroll", lazyload); + window.addEventListener("resize", lazyload); + window.addEventListener("orientationChange", lazyload); + } +}) + + +(function($) { // Begin jQuery + $(function() { // DOM ready + // If a link has a dropdown, add sub menu toggle. + $('nav ul li a:not(:only-child)').click(function(e) { + $(this).siblings('.nav-dropdown').toggle(); + // Close one dropdown when selecting another + $('.nav-dropdown').not($(this).siblings()).hide(); + e.stopPropagation(); + }); + // Clicking away from dropdown will remove the dropdown class + $('html').click(function() { + $('.nav-dropdown').hide(); + }); + // Toggle open and close nav styles on click + $('#nav-toggle').click(function() { + $('nav ul').slideToggle(); + }); + // Hamburger to X toggle + $('#nav-toggle').on('click', function() { + this.classList.toggle('active'); + }); + }); // end DOM ready +})(jQuery); // end jQuery