1 2var mgntBGHandler = (function() { 3 4 var $slideshow = $( '#background' ), 5 $items = $slideshow.children( 'li' ), 6 itemsCount = $items.length, 7 current = 0, 8 slideshowtime, 9 isSlideshowActive = false, 10 interval = 5000; 11 12 function init( config ) { 13 14 // preload the images 15 $slideshow.imagesLoaded( function() { 16 17 if( Modernizr.backgroundsize ) { 18 $items.each( function() { 19 var $item = $( this ); 20 $item.css( 'background-image', 'url(' + $item.find( 'img' ).attr( 'src' ) + ')' ); 21 } ); 22 } 23 else { 24 $slideshow.find( 'img' ).show(); 25 // for older browsers add fallback here (image size and centering) 26 } 27 28 // show first item 29 if ($items.eq(current).attr('class') != null) 30 $items.eq( current ).css( 'opacity', $items.eq( current ).attr('class') ); 31 startSlideshow(); 32 } ); 33 } 34 35 function navigate( direction ) { 36 37 var $oldItem = $items.eq( current ); 38 39 if( direction === 'next' ) { 40 current = current < itemsCount - 1 ? ++current : 0; 41 } 42 else if( direction === 'prev' ) { 43 current = current > 0 ? --current : itemsCount - 1; 44 } 45 46 var $newItem = $items.eq( current ); 47 48 $oldItem.css( 'opacity', 0 ); 49 $newItem.css( 'opacity', $newItem.attr('class') ); 50 } 51 52 function startSlideshow() { 53 54 if (itemsCount > 1) { 55 isSlideshowActive = true; 56 clearTimeout( slideshowtime ); 57 slideshowtime = setTimeout( function() { 58 navigate( 'next' ); 59 startSlideshow(); 60 }, interval ); 61 } 62 } 63 64 function stopSlideshow() { 65 isSlideshowActive = false; 66 clearTimeout( slideshowtime ); 67 } 68 69 return { init : init }; 70 71})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.