/* * Theme Scripts * Theme: Adena */ jQuery(function($){ "use strict"; $(document).ready(function() { // STICKY INIT if ($(window).scrollTop() > 200) { TweenMax.to( $('.un-header.un-sticky.un-header-menu-white'), 0.4, { backgroundColor:'rgba(34,34,34,1)', ease: Power2.easeOut } ); TweenMax.to( $('.un-header.un-sticky.un-header-menu-black'), 0.4, { backgroundColor:'rgba(255,255,255,1)', ease: Power2.easeOut } ); }else{ TweenMax.to( $('.un-header.un-sticky.un-header-menu-white'), 0.4, { backgroundColor:'rgba(34,34,34,0.01)', ease: Power2.easeOut } ); TweenMax.to( $('.un-header.un-sticky.un-header-menu-black'), 0.4, { backgroundColor:'rgba(255,255,255,0.01)', ease: Power2.easeOut } ); } // NAV ICONS $('.un-icon-nav').closest('.vc_row').css('z-index','9998'); $('.un-icon-nav ul li a').on({ mouseenter: function(){ if( $(window).scrollTop() == 0 ) { var data = $(this).data('label'); var $target = $('.un-icon-nav-label', $(this).parent().parent().parent()); $target.html(data); TweenMax.to($target, 0.3, {display: 'block', opacity: 1, ease: Power2.easeInOut}); } }, mouseleave: function(){ if( $(window).scrollTop() == 0 ) { var $target = $('.un-icon-nav-label', $(this).parent().parent().parent()); $('.un-icon-nav-label').html(''); TweenMax.to($target, 0.3, {display: 'none', opacity: 0, ease: Power2.easeInOut}); } } }); if( $('.un-icon-nav').length > 0 ){ $('.wrap-full').css('margin-bottom', '50px'); } $('.un-btn-navbar-close').on( 'click', function(){ TweenMax.to( $(this).parent(), 0.3, { bottom:-60, ease: Power2.easeOut } ); TweenMax.to( $('.un-btn-navbar-open', $(this).parent()), 0.3, { display:'block', opacity:1, top:-60, ease: Power2.easeOut } ); TweenMax.to( $('.wrap-full'), 0.3, { marginBottom:0, ease: Power2.easeOut } ); }); $('.un-btn-navbar-open').on( 'click', function(){ TweenMax.to( $(this).parent(), 0.3, { bottom:0, ease: Power2.easeOut } ); TweenMax.to( $('.un-btn-navbar-open', $(this).parent()), 0.3, { display:'none', opacity:0, top:0, ease: Power2.easeOut } ); TweenMax.to( $('.wrap-full'), 0.3, { marginBottom:50, ease: Power2.easeOut } ); }); // Grid Hover $('.un-img-zoom').on({ mouseenter: function(){ TweenMax.killTweensOf($('.un-item-image img', this)); TweenMax.to( $('.un-item-image img', this), 0.5, {scale:1.2, rotation:5, ease:Power2.easeOut} ); }, mouseleave: function(){ TweenMax.killTweensOf($('.un-item-image img', this)); TweenMax.to( $('.un-item-image img', this), 0.3, {scale:1, rotation:0, ease:Power2.easeOut} ); } }); $('.un-img-opacity').on({ mouseenter: function(){ TweenMax.killTweensOf($('.un-item-image img', this)); TweenMax.to( $('.un-item-image img', this), 0.3, {opacity:0.7, ease:Power2.easeOut} ); }, mouseleave: function(){ TweenMax.killTweensOf($('.un-item-image img', this)); TweenMax.to( $('.un-item-image img', this), 0.3, {opacity:1, ease:Power2.easeOut} ); } }); // Team Hover $('.un-person-top').on({ mouseenter: function(){ TweenMax.killTweensOf($('.un-overlay', this)); TweenMax.to( $('.un-overlay', this), 0.5, {bottom:0, ease:Power3.easeOut} ); }, mouseleave: function(){ TweenMax.killTweensOf($('.un-overlay', this)); TweenMax.to( $('.un-overlay', this), 0.5, {bottom:'-100%', ease:Power3.easeOut} ); } }); // Post Navy Hover $('.un-page-nav-next, .un-page-nav-prev').on({ mouseenter: function(){ TweenMax.killTweensOf($('.un-page-nav-label', this)); TweenMax.to( $('.un-page-nav-label', this), 0.3, {opacity:0, display:'none', ease:Power2.easeOut} ); }, mouseleave: function(){ TweenMax.killTweensOf($('.un-page-nav-label', this)); TweenMax.to( $('.un-page-nav-label', this), 0.3, {opacity:1, display:'block', ease:Power2.easeOut} ); } }); // Countdown var $countdown = $('.un-countdown'); var day = $countdown.data('day'), month = $countdown.data('month'), year = $countdown.data('year'), format = $countdown.data('format'); $('.un-timer').countdown(year+'/'+month+'/'+day, function(event) { $(this).html(event.strftime(format)); }); // Menu #GOTO $('a').on('click', function(e){ var hash = this.hash; if( hash ){ e.preventDefault(); var $target = $(hash); if( $target.length > 0 ) { var targetPos = $target.offset(); targetPos = targetPos.top - 100; var timeSec = targetPos / 2000; TweenMax.to(window, timeSec, {scrollTo: {y: targetPos}, ease: Power2.easeOut}); } } }); }); $(window).load(function() { // Fix Carousel IMG width $('.ui-carousel .slick-slide img').each(function(){ $(this).css('max-width', 'none'); var colW = $('.ui-carousel .slick-slide').width(); var colH = $('.ui-carousel .slick-slide').height(); var imgW = $(this).width(); var margin; if( imgW > colW ){ $(this).css({'width':colW, 'height':'auto' }); margin = (colH - $(this).height()) / 2; $(this).css({'margin-top': margin, 'margin-bottom': margin }); } }); // SEARCH $('#un-btn-search').on( 'click', function(){ TweenMax.to( $('#un-modal-search'), 0.8, { top:0, ease: Power2.easeOut } ); }); $('#un-btn-search-close').on( 'click', function(){ TweenMax.to( $('#un-modal-search'), 0.8, { top:'-100%', ease: Power2.easeIn } ); }); // SOCIALS $('.un-post-links li.first, .un-page-author-links li.first').on( 'click', function(){ if($(this).hasClass('close')){ TweenMax.to($(this).parent(), 0.5, {width: '40', ease: Power2.easeOut}); TweenMax.to($(this), 0.5, {backgroundColor: 'inherit', ease: Power2.easeOut}); $(this).removeClass('close'); }else{ var totalWidth = $(this).parent().children().length * 40; TweenMax.to($(this).parent(), 0.5, {width: totalWidth, ease: Power2.easeOut}); TweenMax.to($(this), 0.5, {backgroundColor: '#f0f0f0', ease: Power2.easeOut}); $(this).addClass('close'); } }); // MOBILE MENU $('#un-btn-menu').on( 'click', function(){ TweenMax.killTweensOf( $('#un-mobile-menu') ); var button = $(this), menuH = $('#mobile-menu').height(), navH = $('#un-mobile-menu').height(); if( navH == 0 ) { setTimeout( function(){ $('.fe-icon-menu', button).addClass('fe-icon-cross').removeClass('fe-icon-menu'); }, 250); TweenMax.to($('#un-mobile-menu'), 0.5, {height: menuH, ease: Power2.easeInOut}); TweenMax.set($('#un-mobile-menu'), {height: 'auto', delay: 0.5}); }else{ setTimeout( function(){ $('.fe-icon-cross', button).addClass('fe-icon-menu').delay(1000).removeClass('fe-icon-cross'); }, 250); TweenMax.to($('#un-mobile-menu'), 0.5, {height: 0, ease: Power2.easeInOut}); } }); $('#un-mobile-menu #mobile-menu > .menu-item-has-children').on( 'click', function(){ var target = $('.sub-menu', $(this)); TweenMax.killTweensOf( target ); var subH = target.height(); var subRealH = target.children().length * 41; var button = $(this); if( subH == 0 ) { setTimeout( function(){ button.addClass('close'); }, 150); TweenMax.to(target, 0.3, {height: subRealH, ease: Power2.easeInOut}); }else{ setTimeout( function(){ button.removeClass('close'); }, 150); TweenMax.to(target, 0.5, {height: 0, ease: Power2.easeInOut}); } }); $(window).scroll(function(){ // Icon Navigator var $iconNav = $('.un-icon-nav ul'); var startColor = $iconNav.data('start-color'); var startBg = $iconNav.data('start-bg'); var scrollColor = $iconNav.data('scroll-color'); var scrollBg = $iconNav.data('scroll-bg'); if( $(window).scrollTop() > 1 ) { TweenMax.to( $iconNav, 0.5, { color: scrollColor, backgroundColor: scrollBg, ease: Power2.easeOut } ); TweenMax.to( $('.un-icon-nav-label', $iconNav.parent()), 0.5, { color: scrollColor, ease: Power2.easeOut } ); TweenMax.to( $('.un-btn-navbar-close', $iconNav.parent()), 0.5, { color: scrollColor, display:'block', opacity:1, ease: Power2.easeOut } ); TweenMax.set( $('.un-btn-navbar-open', $iconNav.parent()), { color: scrollColor, background: scrollBg } ); TweenMax.to( $('.un-icon-nav-label', $iconNav.parent()), 0.5, { display:'none', opacity:0, ease: Power2.easeOut } ); }else{ TweenMax.to( $iconNav, 0.5, { color:startColor, backgroundColor:startBg, ease: Power2.easeOut } ); TweenMax.to( $('.un-icon-nav-label', $iconNav.parent()), 0.5, { color: startColor, ease: Power2.easeOut } ); TweenMax.to( $('.un-btn-navbar-close', $iconNav.parent()), 0.5, { display:'', opacity:'', ease: Power2.easeOut } ); TweenMax.to( $('.un-btn-navbar-open', $iconNav.parent()), 0.5, { color: startColor, ease: Power2.easeOut } ); } // Sticky Scrolling if ($(window).scrollTop() > 200) { TweenMax.to( $('.un-header.un-sticky.un-header-menu-white'), 0.4, { backgroundColor:'rgba(34,34,34,1)', ease: Power2.easeOut } ); TweenMax.to( $('.un-header.un-sticky.un-header-menu-black'), 0.4, { backgroundColor:'rgba(255,255,255,1)', ease: Power2.easeOut } ); }else{ TweenMax.to( $('.un-header.un-sticky.un-header-menu-white'), 0.4, { backgroundColor:'rgba(34,34,34,0.01)', ease: Power2.easeOut } ); TweenMax.to( $('.un-header.un-sticky.un-header-menu-black'), 0.4, { backgroundColor:'rgba(255,255,255,0.01)', ease: Power2.easeOut } ); } // Go to Top if( $(window).scrollTop() > 500 ) { TweenMax.killTweensOf( $('.un-btn-up') ); TweenMax.to( $('.un-btn-up'), 0.3, { opacity: 1, display:'block', bottom:0, ease: Power2.easeOut } ); }else{ TweenMax.killTweensOf( $('.un-btn-up') ); TweenMax.to( $('.un-btn-up'), 0.3, { opacity: 0, display:'none', bottom:-100, ease: Power2.easeOut } ); } }); }); });