/** * Creates the section slider functionality */ (function($) { function highlight( items ) { items.addClass('current-slide'); } function unhighlight( gallery ) { $('li', gallery).removeClass('current-slide'); } function changeImage( items, backObject ){ var bgImage = items.filter(':first').attr('data-bg'); if(backObject != '') { backObject.backstretch(bgImage); } else { $.backstretch(bgImage); } } $(window).load(function() { ///////////////////////////////////////////// // Section slider ///////////////////////////////////////////// if($('.slider-section').length > 0) { $('.slider-section').each( function(index) { var sectionSlider = this; var itemIndex = ($('li', sectionSlider).length > 5)? '0': '1'; var backObject = $(sectionSlider).closest('section'); $('.slides', sectionSlider).carouFredSel({ responsive: true, circular: themifySectionVars.wrap, infinite: themifySectionVars.wrap, prev: { button: $('.carousel-prev', sectionSlider), key: 'left', onBefore: function(oldItems, newItems) { unhighlight( sectionSlider ); changeImage( newItems, backObject ); }, onAfter : function(oldItems, newItems) { highlight( newItems.filter(':eq(0)') ); } }, next: { button: $('.carousel-next', sectionSlider), key: 'right', onBefore: function(oldItems, newItems) { unhighlight( sectionSlider ); changeImage( newItems, backObject ); }, onAfter : function(oldItems, newItems) { highlight( newItems.filter(':eq('+itemIndex+')') ); } }, width: '100%', auto: { play : themifySectionVars.play, pauseDuration: themifySectionVars.autoplay, button: $('.carousel-playback', sectionSlider) }, scroll: { items: 1, duration: themifySectionVars.speed, wipe: true, onBefore: function(oldItems, newItems) { unhighlight( sectionSlider ); changeImage( newItems, backObject ); }, onAfter : function(oldItems, newItems) { highlight( newItems.filter(':eq('+itemIndex+')') ); } }, items: { visible: 5, minimum: 1, width: 20 }, onCreate : function (){ $(sectionSlider).css( { 'height': 'auto', 'visibility' : 'visible' }); $('.carousel-next, .carousel-prev', sectionSlider).wrap('