(function($){ "use strict"; /* Portfolio Sections */ var portfoliosect = function(){ var $port = jQuery.noConflict(); var container = $port('.portfolio-box'); var filter = $port('.portfolio-filters'); container.isotope({ itemSelector : '.item' }); container.infinitescroll({ navSelector : '.load-more-portfolio', nextSelector : '.load-more-portfolio a', itemSelector : '.item', errorCallback: function(){ $port('.load-more-portfolio').remove(); }, }, function(newElements) { var $newElems = $port(newElements); $newElems.imagesLoaded(function(){ container.isotope('appended', $newElems ); newCols(); container.isotope('reLayout'); portfolioitem(); }); } ); $port(window).unbind('.infscr'); $port(".load-more-portfolio a").click(function(){ $port('.portfolio-box').infinitescroll('retrieve'); $port('.load-more-portfolio').show(); return false; }); filter.find('a').click(function() { var selector = $port(this).attr('data-filter'); filter.find('a').removeClass('active'); $port(this).addClass('active'); container.isotope({ filter: selector, animationOptions:{ animationDuration: 400, queue: false } }); return false; }); function colType() { var winWidthfP = $(window).width(), colNumber = 1; if (winWidthfP > 1200) { colNumber = 4; } else if (winWidthfP > 767) { colNumber = 3; } else if (winWidthfP > 480) { colNumber = 1; } return colNumber; } function newCols() { var winWidthfP = $(window).width(), colNumber = colType(), itemWdt = Math.floor(winWidthfP / colNumber); container.find('.item').each(function () { $(this).css( { width : itemWdt + 'px' }); }); } $port(window).bind('resize', function () { newCols(); container.isotope('reLayout'); }); container.imagesLoaded(function () { newCols(); container.isotope('reLayout'); }); } /* Portfolio Items */ var portfolioitem = function(){ var $pitem = jQuery.noConflict(); jQuery('.portfolio-details').click(function(){ var portfolioItemUrl = jQuery(this).attr("href")+"?"+(new Date()).getTime(); jQuery('html, body').animate({ scrollTop: jQuery(".portfolio-top").offset().top - 50},400); jQuery('.portfolio-loading').css({ "display": "block", "opacity": "0"}).animate({"opacity": "0.6"},300); jQuery('#portfolio-details-box').animate({opacity:0}, 400,function(){ $pitem("#portfolio-details-box").load(portfolioItemUrl,function(){ jQuery('.flexslider').flexslider({animation: "fade",controlNav:false}); jQuery(".container").fitVids(); }); jQuery('#portfolio-details-box').animate({opacity:1},400); }); jQuery('.portfolio-wrapper').slideUp(400, function(){ jQuery('.portfolio-loading').delay(800).animate({ "opacity": "0" }, 100,function(){ jQuery('.portfolio-loading').css("display","none"); }); jQuery('#portfolio-details-box').css('visibility', 'visible');}).delay(800).slideDown(400,function(){ jQuery('#portfolio-details-box').animate({opacity:1}, 400); }); return false; }); jQuery('#portfolio-next').click(function(){ var portfolioItemNextUrl = jQuery(".projectNextUrl").attr("href")+"?"+(new Date()).getTime(); jQuery('#portfolio-details-box').animate({opacity:0}, 400,function(){ jQuery("#portfolio-details-box").load(portfolioItemNextUrl,function(){ jQuery('.flexslider').flexslider({animation: "fade",controlNav:false}); jQuery(".container").fitVids(); }); jQuery('#portfolio-details-box').animate({opacity:1},400); }); return false; }); jQuery('#portfolio-prev').click(function(){ var portfolioItemPrevUrl = jQuery(".projectPrevUrl").attr("href")+"?"+(new Date()).getTime(); jQuery('#portfolio-details-box').animate({opacity:0}, 400,function(){ jQuery("#portfolio-details-box").load(portfolioItemPrevUrl,function(){ jQuery('.flexslider').flexslider({animation: "fade",controlNav:false}); jQuery(".container").fitVids(); }); jQuery('#portfolio-details-box').animate({opacity:1},400); }); return false; }); jQuery('#portfolio-close').click(function(){ jQuery('.portfolio-wrapper').slideUp(400, function(){ jQuery('#portfolio-details-box').empty(); }); return false; }); } /* Animations */ var vesaAnimations = function(){ $(window).scroll(function() { $(".animated-area").each(function() { if($(window).height() + $(window).scrollTop() - $(this).offset().top > 0) { $(this).trigger("animate-it"); } }); }); $(".animated-area").on("animate-it", function() { var cf = $(this); cf.find(".animated").each(function() { $(this).css("-webkit-animation-duration","0.6s"); $(this).css("-moz-animation-duration","0.6s"); $(this).css("-ms-animation-duration","0.6s"); $(this).css("animation-duration","0.6s"); $(this).css("-webkit-animation-delay",$(this).attr("data-animation-delay")); $(this).css("-moz-animation-delay",$(this).attr("data-animation-delay")); $(this).css("-ms-animation-delay",$(this).attr("data-animation-delay")); $(this).css("animation-delay",$(this).attr("data-animation-delay")); $(this).addClass($(this).attr("data-animation")); }); cf.find(".animated-numbers").each(function() { var targetnumber = $(this).attr("data-target-number"); $(this).animateNumbers(targetnumber, true, 3000); }); cf.find(".animated-skills").each(function() { $(this).css("width",$(this).attr("data-skills-width")); }); }); } /* Responsive Menu */ var scrwdth; scrwdth = $(window).width() - 70; $(window).bind('resize', function () { scrwdth = $(window).width() - 70; }); $('#responsive-menu-button').sidr({ name: 'sidr-main', source: '#navigation', onOpen: function(){ jQuery(".logo").animate({'margin-top':'-9999px'},300,function(){ jQuery("#mobile-header").animate({'right':scrwdth}); }); jQuery('#responsive-menu-button').addClass('selected'); }, onClose: function(){ jQuery(".logo").animate({'margin-top':'0'},300,function(){ jQuery("#mobile-header").animate({'right':'10px'}); }); jQuery('#responsive-menu-button').removeClass('selected'); } }); $("#sidr-id-menu ul li").click(function(){ jQuery.sidr('close', 'sidr-main'); }); /* Responsive Menu */ $(window).load(function(){ $('#loading-area').fadeOut().remove(); portfoliosect(); portfolioitem(); }); })(jQuery);