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