;(function($){ $.expr[':'].external = function(obj){ return !obj.href.match(/^mailto\:/) && ( obj.hostname && (obj.hostname != location.hostname) ) && $(obj).find('img').length === 0 && $(obj).hasClass('banner') === false; }; /** * --------------------------------------------------------------------- * Av Heights * --------------------------------------------------------------------- **/ $.fn.heights = function(args){ var defaults = { itemClass : 'equal-height-item' }; return $(this).each( function(){ var obj = this; // Extend if( $.isEmptyObject(args) === false ) $.extend( defaults, args ); obj.init = function(defaults, obj){ tallest = 0; $(obj).find('.'+defaults.itemClass).each(function(){ $(this).css({ 'height': 'auto' }); if ( $(this).outerHeight() > tallest ) tallest = $(this).outerHeight(); }); $(obj).find('.'+defaults.itemClass).css({'height': tallest}); }; // Default Initialization obj.init(defaults, obj); // initilice with $(window) resize (resizeEnd) $(window).load( function(){ obj.init(defaults, obj); }); // initilice with $(window) resize (resizeEnd) $(window).on( 'resizeEnd', function(){ obj.init(defaults, obj); }); }); }; /** * --------------------------------------------------------------------- * Initialization Functions * --------------------------------------------------------------------- **/ $.av = { triggerEvents : { init : function( context ){ //$.av.fancybox.init( context ); //$.av.carousel.init( context ); $.av.heights.init( context ); //$.av.navHelper.init(); //$.av.makeColumns.init( context ); } }, /* Av Heights */ heights : { init : function( context ){ // if ($(window).width() < 721) { // $('.equal-heights', context).heights(); // }); $('.equal-heights', context).heights(); } }, }; })(jQuery); /** * --------------------------------------------------------------------- * Sticky nav * --------------------------------------------------------------------- **/ jQuery(document).ready( function($){ $(window).resize(function(){ if( this.resizeTO ) clearTimeout(this.resizeTO); this.resizeTO = setTimeout(function(){ $(this).trigger('resizeEnd'); }, 100); }); /*-------------------------------------- Equal Heights */ $.av.heights.init(); /*-------------------------------------- Sticky Nav */ var stickyNavTop = $('#header').offset().top + 75; var stickyNav = function(){ var scrollTop = $(window).scrollTop(); if (scrollTop > stickyNavTop) { $('#wrap-main-nav').addClass('sticky'); } else { $('#wrap-main-nav').removeClass('sticky'); } }; stickyNav(); $(window).scroll(function() { stickyNav(); }); /** * --------------------------------------------------------------------- * Sub-navs - appear on hover * --------------------------------------------------------------------- **/ $("#main-nav").find('a').hoverIntent( function(){ // Desatar timeout para detectar mouseleave $(document).delay(100).on( 'mousemove', function(e){ if( $(e.target).parents('#main-nav, #sub-navs').length === 0 ){ $(document).off('mousemove'); $("#main-nav").find('a.hovered').each( function(){ $(this).removeClass('hovered'); var id = $(this).data('id'); $('#'+id).stop().fadeOut('fast', function(){ $(this).css({ display : 'inherit' }).addClass('hidden'); }) }); } }); // Si el elemento no ha sido ingresado con mouse if( $(this).hasClass('hovered') === false ){ // buscar los navs activos y desactivarlos var fadeIn = true; if( $("#main-nav").find('a.hovered').length > 0 ) fadeIn = false; $("#main-nav").find('a.hovered').each( function(){ $(this).removeClass('hovered'); var id = $(this).data('id'); $('#'+id).stop().css({ display : 'inherit' }).addClass('hidden'); }); // aƱadir active $(this).addClass('hovered'); var id = $(this).data('id'); if( fadeIn ) $('#'+id).stop().css({ display : 'none' }).removeClass('hidden').fadeIn('fast'); else $('#'+id).stop().css({ display : 'none' }).removeClass('hidden').show(); } }); /** * --------------------------------------------------------------------- * Search Form * --------------------------------------------------------------------- **/ /* Start of: T3h ugly way*/ $(".search-form-input").keyup(function(e) { var value = $.trim($(this).val()); if (e.keyCode == 13 && value.length > 0){ $("form[name='searchForm']").submit(); } }); $("form[name='searchForm']").submit(function(event){ $("#campoBusquedaBus").val($("#search-form-input").val()); $("#tipoContenidoBus").val($("#category").val()); }); $(".pagination li").click(function(){ if($(this).attr("id")!== undefined && $(this).attr("id")!=""){ $("#indiceSearch").val($(this).attr("id")); $("form[name='searchForm']").submit() } }); /* End of: T3h ugly way*/ // Artificial custom focus action for Search Bar var searchInput = $(".search-form .search-form-input"), selectInput = $("#category"); // Focus if we click searchInput.focus(function() { $(this).parent().addClass('is-focused'); }); searchInput.blur(function() { window.setTimeout(blurTester, 100); }); selectInput.blur(function() { window.setTimeout(blurTester, 100); }); function blurTester() { if ($(searchInput).is(":focus") || $(selectInput).is(":focus")) {} else if ($(searchInput).val()) { } else { $('.search-form').removeClass('is-focused'); searchInput.parent().removeClass('show-search-form-submit'); } } // Show search-form-submit on input type searchInput.keyup(function() { var value = $.trim($(this).val()); if (value.length > 0) { $(this).parent().addClass('show-search-form-submit'); } else { $(this).parent().removeClass('show-search-form-submit'); } }); }); /** * --------------------------------------------------------------------- * Menu mobile toggle * --------------------------------------------------------------------- **/ jQuery(document).ready(function(){ $(".menu-mobile_toggle").click(function(e){ e.preventDefault(); var menuOverlay = $(".menu-mobile_overlay"); if(menuOverlay.hasClass("active")){ menuOverlay.removeClass("active"); $("body").removeClass("body-fixed"); }else{ menuOverlay.addClass("active"); $("body").addClass("body-fixed"); } }); //ARROW $(".submenu-mobile").click(function(e){ e.preventDefault(); $(this).find(".arrow-mobile").toggleClass("arrow-mobile_flipped"); }); }); jQuery(document).ready(mobileNav); jQuery(window).on('resize', mobileNav); function mobileNav() { // Set the matchMedia if (window.matchMedia('(min-width: 768px)').matches) { jQuery(".menu-mobile_overlay").removeClass("active"); jQuery("body").removeClass("body-fixed"); } }