jQuery(function($){ 'use strict'; /* ============================================== Detect Mobile Devices =============================================== */ var detectmob = false; if(navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) { detectmob = true; } /* ============================================== Some Edit for WordPress =============================================== */ /* Pagenavi */ if(!$('.pagenavi-inner').children('span').hasClass('page-numbers')){ $('.pagenavi-inner').css('display','none'); $('.popular-post').css('marginTop','35px'); } /* Search Button */ $('.default-search').find('.search-submit').click(function(){ $('.default-search').submit(); }); /* Category */ if(!$('.entry-meta').children('span').hasClass('u-category')){ $('.entry-meta').find('.dt-published').css('padding-right','18px'); } /* ============================================== Responsive Video =============================================== */ $('.container').fitVids(); /* ============================================== Some Animations =============================================== */ /* Sticky menu search */ $('.slip-search-wrap').find('.fa').click(function(){ $(this).fadeOut(10); $(this).siblings('input').fadeIn(0).animate({ width:'100px' },100); }); $('body').click(function(){ $('.slip-search-wrap').find('input').animate({ width:0, },100).fadeOut(0); $('.slip-search-wrap').find('.fa').delay(100).fadeIn(150); }); $('.slip-search-wrap').find('.fa').click(function(e){ e.stopPropagation(); }); $('.slip-search-wrap').find('input').click(function(e){ e.stopPropagation(); }); /* Menu appear */ function fixed_menu(){ var windowWidth=$(window).width(); var windowPos=$(window).scrollTop(); if(windowPos>150 && windowWidth>992){ $('.fixed-header').fadeIn(300); }else{ $('.fixed-header').slideUp(100); } } fixed_menu(); $(window).scroll(fixed_menu); $(window).resize(fixed_menu); /* Sticky Menu */ $('.search-slip').find('.fa').click(function(){ $('.search-slip').find('input').delay(100).fadeIn(0).animate({ width:'100px' },100); $(this).fadeOut(100); }); $('body').click(function(){ $('.search-slip').find('input').animate({ width:0 },100).fadeOut(10); $('.search-slip').find('.fa').fadeIn(); }); $('.search-slip').find('input').click(function(e){ e.stopPropagation(); }); $('.search-slip').find('.fa').click(function(e){ e.stopPropagation(); }); /* Scrolling */ if($('.section-quote').length){ var sectionQuote=$('.section-quote').offset().top; $(window).resize(function(){ sectionQuote=$('.section-quote').offset().top; }); } /* Header Banner Height */ var windowHeight=$(window).height(); $('.front-header').css({ height:windowHeight+'px' }); $(window).resize(function(){ var windowHeight=$(window).height(); $('.front-header').css({ height:windowHeight+'px' }); }); /* Top Texts */ function top_headline(){ if($(window).width()>992){ var topheadline=$('.top-headline').height(); $('.front-header').find('.top-headline').css({ marginTop:-topheadline/2+'px', position:'absolute', top:'45%' }); }else{ $('.front-header').find('.top-headline').css({ marginTop:'30px', position:'relative', top:0 }); $('.blog-single-header').find('.top-headline').css({ marginTop:'100px' }); } } top_headline(); $(window).resize(top_headline); /* ============================================== Drop-down Menu =============================================== */ $('.blog-header,.front-header,.fixed-header').find('.nav li').hover(function(){ $(this).find('ul').stop().fadeIn(300); $(this).find('ul').siblings('a').css('borderBottom','2px solid #c09551'); },function(){ $(this).find('ul').stop().fadeOut(300); $(this).find('ul').siblings('a').css('borderBottom','2px solid transparent'); }); /* ============================================== Masonry =============================================== */ var masonryContainer=$('.post-loop-wrap'); masonryContainer.imagesLoaded( function() { masonryContainer.masonry({ columnWidth: '.col-sm-6.col-md-4', gutterWidth: 30, }); }); /* ============================================== Parallax =============================================== */ if (detectmob == false) { $( '.front-header' ).each(function(){ $(this).parallax('50%',0.3,true); }); $( '.section-features' ).each(function(){ $(this).parallax('50%',0.4,false); }); $( '.section-counter' ).each(function(){ $(this).parallax('50%',0.4,false); }); $( '.section-card' ).each(function(){ $(this).parallax('50%',0.4,false); }); $( '.blog-header' ).each(function(){ $(this).parallax('50%',0.5,true); }); $( '.blog-single-header' ).each(function(){ $(this).parallax('50%',0.3,true); }); } /* ============================================== Top Elements Fading =============================================== */ function element_fading(){ var top=$(window).scrollTop(); var wrap=$('.front-header,.blog-header .top-headline'); var title=$('.front-header,.blog-header .top-headline').find('h1'); var desc=$('.front-header,.blog-header .top-headline').find('.description'); var separator=$('.front-header,.blog-header .top-headline').find('.separator'); var button=$('.front-header').find('.detail-button'); wrap.css('position','relative'); title.css('position','relative'); desc.css('position','relative'); separator.css('position','relative'); button.css('position','relative'); if($(window).width()>992){ title.animate({ top:(top/6)+'px', opacity:1-top/260 },0); desc.animate({ top:(top/1.5)+'px', opacity:.7-top/350 },0); separator.animate({ top:top/2, opacity:1-top/400 },0); button.animate({ top:top/2, opacity:1-top/300 },0); } } $(window).scroll(element_fading); $(window).resize(element_fading); /* ============================================== About Blog Content =============================================== */ $('.dropdown-trigger').hover(function(){ $(this).siblings('ul').stop().fadeToggle('fast'); }); $('.dropdown-trigger').siblings('ul').hover(function(){ $(this).stop().fadeToggle('fast'); }); /* ============================================== Isotope =============================================== */ $('.isotope-container').imagesLoaded( function() { var $container = $('.isotope-container').isotope({ transitionDuration: '.6s', masonry: { columnWidth: '.col-sm-6.col-md-4.col-lg-3' } }); $('.filter-group').find('a').click(function(){ var filterValue = $(this).attr('data-filter'); $container.isotope({ filter: filterValue }); }); }); /* ============================================== Section Features Fading =============================================== */ function feature_rotate(){ if($(window).width()<992){ $('.feature-rotate-first').find('.fa').click(function(){ $(this).parent('article').stop().animate({ opacity:0, zIndex:0 },300); $(this).parent('article').next('article').stop().animate({ opacity:1, zIndex:10 },300); }); $('.feature-rotate-second').find('.fa').click(function(){ $(this).parent('article').stop().animate({ opacity:0, zIndex:0 },300); $(this).parent('article').prev('article').stop().animate({ opacity:1, zIndex:10 }); }); } } feature_rotate(); $(window).resize(feature_rotate); /* ============================================== Gallery =============================================== */ $('.zoom-gallery').magnificPopup({ delegate: '.image-zoom', type: 'image', closeOnContentClick: false, closeBtnInside: false, navigateByImgClick: false, mainClass: 'mfp-with-zoom mfp-img-mobile', gallery: { enabled: true }, image: { verticalFit: true, titleSrc: function(item) { return item.el.attr('title'); } }, zoom: { enabled: true, duration: 300, opener: function(element) { return element.siblings('img'); } }, callbacks: { markupParse : function (template, values, item) { template.find('.desc').html(''); var $desc = item.el.data("desc"); template.find('.desc').append($desc); }, } }); $('.isotope-container').find('.isotope-single').hover(function(){ $(this).children('img').stop().animate({ opacity:'.3' },200); $(this).find('.image-zoom').stop().animate({ marginTop:'-20px', opacity:1 },200); $(this).find('.image-permalink').stop().animate({ marginTop:'-20px', opacity:1 },200); },function(){ $(this).children('img').stop().animate({ opacity:'1' },200); $(this).find('.image-zoom').stop().animate({ marginTop:'-40px', opacity:0 },200); $(this).find('.image-permalink').stop().animate({ marginTop:0, opacity:0 },200); }); $('.filter-inner').find('a').click(function(){ $('.filter-inner').find('a').removeClass('default'); $(this).addClass('default'); }); /* ============================================== Number Counter =============================================== */ $('.section-counter').find('.counter-number').counterUp({ delay: 10, time: 1000 }); /* ============================================== Team Slider =============================================== */ $('.team-img-inner').freetile(); $('.teamslider-wrap').teamslider(); /* ============================================== Timeline Calling =============================================== */ if($('.section-history').length){ $('#timeline').timelinr({ orientation: 'vertical', issuesSpeed: 250, datesSpeed: 100, startAt: 1 }); } /* ============================================== Vertical Slider =============================================== */ $('.vertical').verticalSlider(); /* ============================================== Gallery Big Button =============================================== */ $('.gallery-inner-span').hover(function(){ $('.gallery-inner-button').css('outline-color','white'); $('.border-line-two').css('borderColor','white'); },function(){ $('.gallery-inner-button').css('outline','5px solid rgba(190,190,190,.3)'); $('.border-line-two') .css('borderColor','#3a5386'); }); /* ============================================== Video =============================================== */ $(".player").mb_YTPlayer(); $('.player-icon').click(function(){ $('.player').playYTP(); }); $('.player').on("YTPStart",function(){ $('.video-text-wrap').fadeOut(); }); $('.player').on("YTPPause YTPEnd",function(){ $('.video-text-wrap').fadeIn(); }); /* ============================================== Gallery Inner =============================================== */ $('.zoom-gallery').magnificPopup({ delegate: '.image-zoom', type: 'image', closeOnContentClick: false, closeBtnInside: false, navigateByImgClick: false, mainClass: 'mfp-with-zoom mfp-img-mobile', gallery: { enabled: true }, image: { verticalFit: true, titleSrc: function(item) { return item.el.attr('title'); } }, zoom: { enabled: true, duration: 300, opener: function(element) { return element.siblings('img'); } }, callbacks: { markupParse : function (template, values, item) { template.find('.desc').html(''); var $desc = item.el.data("desc"); template.find('.desc').append($desc); }, } }); $('.isotope-container').find('.isotope-single').hover(function(){ $(this).children('img').stop().animate({ opacity:'.3' },200); $(this).find('.image-zoom').stop().animate({ marginTop:'-20px', opacity:1 },200); $(this).find('.image-permalink').stop().animate({ marginTop:'-20px', opacity:1 },200); },function(){ $(this).children('img').stop().animate({ opacity:'1' },200); $(this).find('.image-zoom').stop().animate({ marginTop:'-40px', opacity:0 },200); $(this).find('.image-permalink').stop().animate({ marginTop:0, opacity:0 },200); }); $('.filter-inner').find('a').click(function(){ $('.filter-inner').find('a').removeClass('default'); $(this).addClass('default'); }); /* ============================================== Cross Browser =============================================== */ /* IE */ if($.browser.msie){ /* All IE */ $('input[type="text"],input[type="email"]').addClass('padding-bottom'); /* IE 10 */ if($.browser.version==10){ $('.gallery-inner-span').addClass('padding-left'); $('.section-gallery-inner .filter-inner').find('a').addClass('padding-top'); } /* IE 9 */ if($.browser.version==9){ $('.gallery-inner-span').addClass('padding-left'); $('.section-gallery-inner .filter-inner').find('a').addClass('padding-top'); $('input[type="text"]').val('Name'); $('input[type="text"]').focus(function(){ if($(this).val()=='Name'){ $(this).val(''); } }); $('input[type="email"]').val('Email'); $('input[type="email"]').focus(function(){ if($(this).val()=='Email'){ $(this).val(''); } }); $('textarea').val('Message'); $('textarea').focus(function(){ if($(this).val()=='Message'){ $(this).val(''); } }); } } /* Fittext */ $('h1').fitText(1.3, { minFontSize: '19px', maxFontSize: '50px' }); $('h2').fitText(1, { minFontSize: '17px', maxFontSize: '40px' }); $('h3').fitText(1, { minFontSize: '15px', maxFontSize: '30px' }); /* Responsive */ $('.menu-open').click(function(){ $('.mobile-menu-wrap').slideDown(200); }); $('.menu-close').click(function(){ $('.mobile-menu-wrap').slideUp(200); }); $('.mobile-menu-wrap').find('a').click(function(){ $('.mobile-menu-wrap').slideUp(200); }); $('.mobile-isotope').click(function(){ $('.filter-inner').slideToggle(200); $('.filter-inner').find('a').click(function(){ $('.filter-inner').slideUp(200); }); }); function mobile_menu_disappear(){ if($(window).width()>992){ $('.mobile-menu-wrap').fadeOut(200); } } mobile_menu_disappear(); $(window).resize(mobile_menu_disappear); /* WPML for mobile */ $('.wpml-wrap-mobile').find('ul').addClass('clearfix'); /* ============================================== Map =============================================== */ function render_map( $el ) { var $markers = $el.find('.marker'); if(detectmob==false){ var args = { zoom : 8, center : new google.maps.LatLng(0, 0), mapTypeId : google.maps.MapTypeId.ROADMAP, streetViewControl:false, draggable:true, scrollwheel:false, mapTypeControl:false, panControl:false, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, }; }else{ var args = { zoom : 8, center : new google.maps.LatLng(0, 0), mapTypeId : google.maps.MapTypeId.ROADMAP, streetViewControl:false, draggable:false, scrollwheel:false, mapTypeControl:false, panControl:false, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, }; } var map = new google.maps.Map( $el[0], args); map.markers = []; map.set('styles', [ { featureType: 'road', elementType: 'geometry', stylers: [ { color: '#e4d4b4' }, { weight: 1 } ] }, { featureType: 'road', elementType: 'labels', stylers: [ { saturation: 1 }, { invert_lightness: false } ] }, { featureType: 'landscape', elementType: 'geometry', stylers: [ { hue: '#ffff00' }, { gamma: 1.4 }, { saturation: 82 }, { lightness: 96 } ] }, { featureType: 'poi.school', elementType: 'geometry', stylers: [ { hue: '##21366c' }, ] } ]); $markers.each(function(){ add_marker( $(this), map ); }); center_map( map ); } function add_marker( $marker, map ) { var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') ); var marker = new google.maps.Marker({ position : latlng, map : map, icon: yacht_path.marker }); map.markers.push( marker ); if( $marker.html() ) { var infowindow = new google.maps.InfoWindow({ content : $marker.html() }); google.maps.event.addListener(marker, 'click', function() { infowindow.open( map, marker ); }); } } function center_map( map ) { var bounds = new google.maps.LatLngBounds(); $.each( map.markers, function( i, marker ){ var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() ); bounds.extend( latlng ); }); if( map.markers.length == 1 ) { map.setCenter( bounds.getCenter() ); map.setZoom( 7 ); } else { map.fitBounds( bounds ); } } $('.acf-map').each(function(){ render_map( $(this) ); }); /* ============================================== Scrolling Top button for Mobile devices =============================================== */ function scrolltop(){ if($(window).scrollTop()>300){ $('.scrolltop-button').stop().fadeIn(); }else{ $('.scrolltop-button').stop().fadeOut(); } } $('.scrolltop-button').click(function(){ $('body').animate({ scrollTop:0 },500); }); if(detectmob==true){ $(window).scroll(scrolltop); scrolltop(); } /* ============================================== Page Loader =============================================== */ $(document).imagesLoaded(function(){ $('.page-loader').find('img').fadeOut(300); $('.page-loader').delay(100).fadeOut(500); }); /* ============================================== Browser Fix =============================================== */ if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){ $('.fixed-header').find('.col-sm-7').css({ paddingBottom:'1px' }); } /* ============================================== Animations =============================================== */ if(detectmob==false){ $('.animated').waypoint(function(){ var elem = $(this); var animation = elem.data('animation'); if ( !elem.hasClass('visible') ) { var animationDelay = elem.data('animation-delay'); if ( animationDelay ) { setTimeout(function(){ elem.addClass( animation + " visible" ); }, animationDelay); } else { elem.addClass( animation + " visible" ); } } },{triggerOnce:true,offset: function() { return $(window).height()-100; }}); $('.blog-single-article, .free-content').find('img').addClass('animated'); $('.blog-single-article, .free-content').find('img').waypoint(function(){ $(this).delay(200).addClass('visible fadeIn'); },{triggerOnce:true,offset: function() { return $(window).height()-200; }}); }else{ $('.animated').css('visibility','visible'); } });