1/** 2 * Creates the section slider functionality 3 */ 4(function($) { 5 6 function highlight( items ) { 7 items.addClass('current-slide'); 8 } 9 function unhighlight( gallery ) { 10 $('li', gallery).removeClass('current-slide'); 11 } 12 function changeImage( items, backObject ){ 13 var bgImage = items.filter(':first').attr('data-bg'); 14 if(backObject != '') { 15 backObject.backstretch(bgImage); 16 } else { 17 $.backstretch(bgImage); 18 } 19 } 20 21 $(window).load(function() { 22 23 ///////////////////////////////////////////// 24 // Section slider 25 ///////////////////////////////////////////// 26 if($('.slider-section').length > 0) { 27 $('.slider-section').each( function(index) { 28 var sectionSlider = this; 29 var itemIndex = ($('li', sectionSlider).length > 5)? '0': '1'; 30 var backObject = $(sectionSlider).closest('section'); 31 $('.slides', sectionSlider).carouFredSel({ 32 responsive: true, 33 circular: themifySectionVars.wrap, 34 infinite: themifySectionVars.wrap, 35 prev: { 36 button: $('.carousel-prev', sectionSlider), 37 key: 'left', 38 onBefore: function(items) { 39 var newItems = items.items.visible; 40 unhighlight( sectionSlider ); 41 changeImage( newItems, backObject ); 42 }, 43 onAfter : function(items) { 44 var newItems = items.items.visible; 45 highlight( newItems.filter(':eq(0)') ); 46 } 47 }, 48 next: { 49 button: $('.carousel-next', sectionSlider), 50 key: 'right', 51 onBefore: function(items) { 52 var newItems = items.items.visible; 53 unhighlight( sectionSlider ); 54 changeImage( newItems, backObject ); 55 }, 56 onAfter : function(items) { 57 var newItems = items.items.visible; 58 highlight( newItems.filter(':eq('+itemIndex+')') ); 59 } 60 }, 61 width: '100%', 62 auto: { 63 play : themifySectionVars.play, 64 pauseDuration: themifySectionVars.autoplay, 65 button: $('.carousel-playback', sectionSlider) 66 }, 67 swipe: true, 68 scroll: { 69 items: 1, 70 duration: themifySectionVars.speed, 71 onBefore: function(items) { 72 var newItems = items.items.visible; 73 unhighlight( sectionSlider ); 74 changeImage( newItems, backObject ); 75 }, 76 onAfter : function(items) { 77 var newItems = items.items.visible; 78 highlight( newItems.filter(':eq('+itemIndex+')') ); 79 } 80 }, 81 items: { 82 visible: 5, 83 minimum: 1, 84 width: 20 85 }, 86 onCreate : function (){ 87 $(sectionSlider).css( { 88 'height': 'auto', 89 'visibility' : 'visible' 90 }); 91 92 $('.carousel-next, .carousel-prev', sectionSlider).wrap('<div class="carousel-arrow"/>'); 93 $('.caroufredsel_wrapper + .carousel-nav-wrap', sectionSlider).remove(); 94 95 $('li:first', sectionSlider).addClass('current-slide'); 96 97 if($('li', sectionSlider).length > 2){ 98 $('.carousel-playback', sectionSlider).css('display', 'inline-block'); 99 } 100 101 if(!themifySectionVars.play) { 102 $('.carousel-playback', sectionSlider).hide(); 103 } 104 } 105 }).find("li").click( function() { 106 unhighlight( sectionSlider ); 107 highlight( $(this) ); 108 $('li', sectionSlider).trigger("slideTo", [ 109 $(this), 110 0, 111 false, 112 { 113 items: 1, 114 duration: 300, 115 onBefore: function(items) { }, 116 onAfter : function(items) { } 117 }, 118 null, 119 'next']); 120 121 // Set image and index using current data properties 122 changeImage( $(this), backObject ); 123 }).css("cursor", "pointer"); 124 125 ///////////////////////////////////////////// 126 // Initialize section slider background 127 ///////////////////////////////////////////// 128 129 var themifyImages = []; 130 131 // Initialize images array with URLs 132 $('li', sectionSlider).each(function(){ 133 themifyImages.push( $(this).attr('data-bg') ); 134 }); 135 136 $(themifyImages).each(function() { 137 $("<img/>").attr('src', this); 138 }); 139 140 // Call backstretch for the first time 141 backObject.backstretch(themifyImages[0], { 142 fade : themifySectionVars.speed 143 }); 144 }); // end each .slider-section 145 } // end if .slider-section 146 }); 147 148 $(document).ready(function() { 149 150 ///////////////////////////////////////////// 151 // Parse injected vars 152 ///////////////////////////////////////////// 153 themifySectionVars.autoplay = parseInt(themifySectionVars.autoplay, 10); 154 if ( themifySectionVars.autoplay <= 10 ) { 155 themifySectionVars.autoplay *= 1000; 156 } 157 themifySectionVars.speed = parseInt(themifySectionVars.speed, 10); 158 themifySectionVars.play = themifySectionVars.play != 'no'; 159 themifySectionVars.wrap = themifySectionVars.wrap != 'no'; 160 161 //////////////////////// 162 // Add wrap for styling 163 //////////////////////// 164 $('.slider-section img').each(function() { 165 $(this).wrap('<span class="image-wrap" style="width: auto; height: auto;"/>'); 166 $(this).removeAttr('class'); 167 }); 168 169 ///////////////////////////////////////////// 170 // Pause carousel
171 ///////////////////////////////////////////// 172 $('.carousel-playback').click(function(){ 173 $(this).toggleClass('paused'); 174 }); 175 176 // Adjust slider on window resizing stop 177 $(window).on('resize', function () { 178 if($('.slider-section').length > 0) { 179 $('.slider-section').closest('section').each( function() { 180 var sectionSlider = $(this).data('backstretch'); 181 if(sectionSlider) 182 sectionSlider.resize(); 183 }); 184 } 185 }); 186 }); 187 188}(jQuery));
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.