jQuery(window).ready(function ($) { /************************************************ Lógica Main Menu *************************************************/ // Caso haja submenus a apresentar /* if ( $("#menu-header li").hasClass("current-menu-parent") || $("#menu-header li").hasClass("current-menu-ancestor") ) { $(".separator-element.last").addClass("show"); $(".bg-header-subnav").addClass("show"); $('header#masthead').animate({ height: '196px' }, 250); $("#menu-header li.current-menu-ancestor").children('ul').addClass("show"); $("#menu-header li").mouseover(function() { $("#menu-header li").children('ul').removeClass("show"); $(this).children('ul').addClass("show"); }); $("#menu-header, #menu-header ul, header#masthead").mouseout(function() { $("#menu-header li").children('ul').removeClass("show"); $("#menu-header li.current-menu-ancestor").children('ul').addClass("show"); }); // Caso NÃO haja submenus a apresentar } else { */ /************************************************ Scroll stuff *************************************************/ // blog post item list mouse over $(".fccn-blog.post-list").mouseover(function () { console.log($(this)); $(this).find('.entry-title').addClass("entry-title--hover"); }); $(".fccn-blog.post-list").mouseout(function () { $(this).find('.entry-title').removeClass("entry-title--hover"); }); // Function Add class if scroll var $document = $(document), $element = $('#masthead'), className = 'hasScrolled'; $document.scroll(function () { $element.toggleClass(className, $document.scrollTop() >= 75); }); function navbarTogglerActive() { if ($(window).innerWidth() <= 1180) { return true; } return false; } // Navegação Desktop if (!navbarTogglerActive()) { // Main Menu Tab (keyboard) Navigation $(function () { $('#menu-header').on('focus', '.menu-item-has-children a', function () { $('.bg-header-subnav').addClass("show"); $(".bg-header-subnav").addClass("shadow"); }).on('blur', '.menu-item-has-children a', function () { $('.bg-header-subnav').removeClass("show"); $(".bg-header-subnav").removeClass("shadow"); }); }); // Main menu Mouse navigation $('#menu-header').removeClass("mobile-menu"); $("#menu-header li.menu-item-has-children").mouseover(function () { $("#menu-header li").children('ul').removeClass("show"); $("#menu-header li.menu-item-has-children a").blur(); $(this).children('ul').addClass("show"); $('.bg-header-subnav').addClass("show"); $(".bg-header-subnav").addClass("shadow"); }); $("header#masthead").mouseout(function () { $('.bg-header-subnav').removeClass("show"); $(".bg-header-subnav").removeClass("shadow"); $("#menu-header li").children('ul').removeClass("show"); }); // Navegação Mobile } else { $('#menu-header').addClass("mobile-menu"); $("#menu-header li.menu-item-has-children").click(function () { $(this).children('ul').toggleClass("show"); }); } window.onresize = function () { if (!navbarTogglerActive()) { // Main Menu Tab (keyboard) Navigation $(function () { $('#menu-header').on('focus', '.menu-item-has-children a', function () { $('.bg-header-subnav').addClass("show"); $(".bg-header-subnav").addClass("shadow"); }).on('blur', '.menu-item-has-children a', function () { $('.bg-header-subnav').removeClass("show"); $(".bg-header-subnav").removeClass("shadow"); }); }); // Main menu Mouse navigation $('#menu-header').removeClass("mobile-menu"); $("#menu-header li.menu-item-has-children").mouseover(function () { $('.bg-header-subnav').addClass("show"); // $(".separator-element.last").addClass("show"); $("#menu-header li").children('ul').removeClass("show"); $(this).children('ul').addClass("show"); $(".bg-header-subnav").addClass("shadow"); }); $("header#masthead").mouseout(function () { $('.bg-header-subnav').removeClass("show"); // $(".separator-element.last").removeClass("show"); $(".bg-header-subnav").removeClass("shadow"); $("#menu-header li").children('ul').removeClass("show"); }); } else { $('#menu-header').addClass("mobile-menu"); $("#menu-header li.menu-item-has-children").off("mouseover mouseout"); $("header#masthead").off("mouseover mouseout"); $("#menu-header li.menu-item-has-children").click(function () { $(this).children('ul').toggleClass("show"); }); } } /* $document.scroll(function() { if ($document.scrollTop() >= 50) { $("#menu-header li").children('ul').removeClass("show"); $('.bg-header-subnav').animate({ top: '104px' }, 100); $(".bg-header-subnav").removeClass("shadow"); $(".separator-element.last").removeClass("show"); } else { } }); */ /************************************************ Scoll to section *************************************************/ // Scoll to section $(".smooth-scroll-to").on('click', function (event) { // Make sure this.hash has a value before overriding default behavior if (this.hash !== "") { // Prevent default anchor click behavior event.preventDefault(); // Store hash var hash = this.hash; // Using jQuery's animate() method to add smooth page scroll // The optional number (600) specifies the number of milliseconds it takes to scroll to the specified area $('html, body').animate({ scrollTop: $(hash).offset().top }, 600, function () { // Add hash (#) to URL when done scrolling (default click behavior) window.location.hash = hash; }); } }); /************************************************ * Show search for mobile */ function closeMobileSearch() { setTimeout(() => $(".mobile-search").removeClass("active"), 400); $(".mobile-search").animate({ top: "10px" }); } $(".search-site-btn").click(function () { if ($(".mobile-search").hasClass("active")) { closeMobileSearch() } else { $(".mobile-search").addClass("active"); $(".mobile-search").animate({ top: "100%" }); } }); $(".mobile-search__close").click(closeMobileSearch); // $(".search-site-btn").click(function () { // if ($(".mobile-search").hasClass("hide")) { // $(".mobile-search").removeClass("hide"); // } else { // $(".mobile-search").addClass("hide"); // } // }); // $(".mobile-search__close").click(function () { // $(".mobile-search").addClass("hide"); // }); /************************************************ Cookie Notice *************************************************/ // if (localStorage.getItem('fccnCookieSeen') != 'shown') { // $('.cookie-banner').delay(1000).fadeIn(); // }; // $('.cookieClose').click(function () { // $('.cookie-banner').fadeOut(); // localStorage.setItem('fccnCookieSeen', 'shown') // }) }); // ************************************************* // Replace SVG images with class .inline-svg to inline SVG // https://gist.github.com/Bloggerschmidt/61beeca2cce94a70c9df // Must be after svg-inline class atributted jQuery('.svg-inline').each(function () { var $img = jQuery(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('url'); var imgSRC = $img.attr('src'); jQuery.get(imgSRC, function (data) { // Get the SVG tag, ignore the rest var $svg = jQuery(data).find('svg'); // Add replaced image's ID to the new SVG if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } // Add replaced image's classes to the new SVG if (typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass + ' replaced-svg'); } // Remove any invalid XML tags as per http://validator.w3.org $svg = $svg.removeAttr('xmlns:a'); // Check if the viewport is set, if the viewport is not set the SVG wont't scale. if (!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) { $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width')) } // Replace image with new SVG $img.replaceWith($svg); }, 'xml'); });