/** * Theme functions file */ (function ($) { var $document = $(document); var $window = $(window); /** * Document ready (jQuery) */ $document.ready(function() { /** * Activate superfish menu. */ $('.sf-menu').superfish({ 'speed': 'fast', 'delay' : 0, 'animation': { 'height': 'show' } }); /** * Activate jQuery.mmenu. */ $("#menu-main-slide").mmenu({ "slidingSubmenus": false, "extensions": [ "theme-dark", "pageshadow", "border-full" ] }) /** * Activate FitVids. */ $(".entry-content").fitVids(); /** * Activate main slider. */ $('#slider').sllider(); $('#slider .slides h3').css({'margin-top':0,'opacity':0}); $('#slider .slides .excerpt').css({'left':'-680px','opacity':0}); $.fn.responsiveSliderImages(); /** * Isotope filter for Portfolio Isotope template. */ $('.portfolio-taxonomies-filter-by').portfolioIsotopeFilter(); }); $.fn.sllider = function() { return this.each(function () { var $this = $(this); $this.flexslider({ controlNav: true, directionNav: true, animationLoop: true, useCSS: true, smoothHeight: false, touch: true, pauseOnAction: true, animationSpeed: 600, slideshow: zoomOptions.slideshow_auto, animation: zoomOptions.slideshow_effect.toLowerCase(), slideshowSpeed: parseInt(zoomOptions.slideshow_speed, 10), start: wpz_sliderTextAnimate, before: wpz_sliderTextAnimate }); }); }; $.fn.responsiveSliderImages = function () { $(window).on('resize orientationchange', update); function update() { var windowWidth = $(window).width(); if (windowWidth <= 680) { $('#slider .slides li').each(function () { var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); var smallimg = $(this).data('smallimg'); if (bgurl) { bgurl = bgurl[1]; } if (bgurl == smallimg) return; $(this).css('background-image', 'url("' + smallimg + '")'); }); } if (windowWidth > 680) { $('#slider .slides li').each(function () { var bgurl = $(this).css('background-image').match(/^url\(['"]?(.+)["']?\)$/); var bigimg = $(this).data('bigimg'); if (bgurl) { bgurl = bgurl[1]; } if (bgurl == bigimg) return; $(this).css('background-image', 'url("' + bigimg + '")'); }); } } update(); }; $.fn.portfolioIsotopeFilter = function () { return this.each(function() { var $this = $(this); var $taxs = $this.find('li'); var $portfolio = $('.portfolio-grid'); $(window).load(function () { $portfolio.fadeIn().isotope({ layoutMode : 'fitRows', itemSelector: 'li' }); setTimeout( function() { $portfolio.addClass('isotope') }, 100 ); }); var tax_filter_regex = /cat-item-([0-9]+)/gi; var preferences = { duration: 400, adjustHeight: 'dynamic', useScaling: true }; $taxs.on('click', function(event) { event.preventDefault(); $this = $(this); $taxs.removeClass('current-cat'); $this.addClass('current-cat'); var catID = tax_filter_regex.exec($this.attr('class')); tax_filter_regex.lastIndex = 0; if (catID === null) { filter = '.type-portfolio'; } else { filter = '.portfolio_' + catID[1] +'_item'; } $portfolio.isotope({ 'filter': filter }); }); }); }; $("#portfolio-slider").flexslider({ controlNav: false, directionNav:true, animationLoop: true, slideshow: false, animation: "slide", useCSS: false, touch: true, smoothHeight: true, animationSpeed: 300 }); })(jQuery); function wpz_sliderTextAnimate(slider) { var $currentSlide = jQuery('#slider .slides li').not('.clone').eq(slider.animatingTo), $otherSlides = jQuery('#slider .slides li').not($currentSlide); $otherSlides.find('h3').animate({ 'margin-top': 0, 'opacity': 0 }, 800); $otherSlides.find('.excerpt').animate({ 'left': '-680px', 'opacity': 0 }, 800); $currentSlide.find('h3').animate({ 'margin-top': '130px', 'opacity': 1 }, 800); $currentSlide.find('.excerpt').animate({ 'left': 0, 'opacity': 1 }, 800); }