1function lbSlideshow (prefix, passed_opts) { 2 var opts = { 3 'fx' : 'fade', 4 'timeout' : 0, 5 'delay' : 2000, 6 'speed' : 1000, 7 'sync' : 1, 8 'resize' : true, 9 'keyboard' : true, 10 'next' : '.ss_next', 11 'prev' : '.ss_prev', 12 'starting_index' : 0, 13 }; 14 15 $.extend(opts, passed_opts); 16 17 $('.' + prefix + '_slideshow').each(function() { 18 var _ss = $(this); 19 var _pager = $(this).find('.ss_pager'); 20 var _next = $(this).find(opts.next); 21 var _prev = $(this).find(opts.prev); 22 23 if($('.slideshow li', this).length >= 1) { 24 $('.slideshow', this).cycle({ 25 fx: opts.fx, 26 delay: opts.delay, 27 speed: opts.speed, 28 timeout: opts.timeout, 29 sync: opts.sync, 30 containerResize: 0, 31 slideResize: 0, 32 startingSlide: opts.starting_index, 33 pager: _pager, 34 next: _next, 35 prev: _prev, 36 before: onBefore, 37 after: onAfter 38 }); 39 } 40 if($('.slideshow li', this).length < 2) { 41 // if slideshow only has one image, then hide prev next buttons 42 $('.ss_next', this).hide(); 43 $('.ss_prev', this).hide(); 44 } 45 46 // Swipe for mobile 47 if (mcConf.mobile) { 48 if($('.slideshow li', this).length >= 1) { 49 $('.slideshow li', this).swipe({ 50 swipeLeft: imageNextMobile, 51 swipeRight: imagePrevMobile, 52 threshold: 100 53 }); 54 $('.assettype2, .panoramic').addClass('noSwipe'); 55 } 56 } 57 58 if (opts.keyboard) { 59 $(document).bind('keydown', function(e) { 60 if (e.which == 37) 61 $('.ss_prev').trigger('click'); 62 else if (e.which == 39) 63 $('.ss_next').trigger('click'); 64 }); 65 } 66 67 // thumbnails 68 $('.ss_thumbs li', this).bind('click', function() { 69 var index = $(this).index(); 70 var _ss = $(this).parents('.slideshow_wrapper'); 71 $('.slideshow', _ss).cycle(index); 72 }); 73 74 preloadAllElementImages($('.slideshow_image', this).first()); 75 76 if (opts.resize) { 77 resizeSlideshow(_ss); 78 $(window).bind('resize', function() { 79 resizeSlideshow(_ss); 80 }); 81 } 82 }); 83 84 function onBefore(curr,next,opts) { 85 // preload images 86 var lastSlide = opts.slideCount; 87 var prevIndex = correctIndex(opts.currSlide - 1, opts.slideCount); 88 var nextIndex = correctIndex(opts.currSlide + 1, opts.slideCount); 89 preloadAllElementImages(curr); 90 preloadAllElementImages(opts['$cont'].children('li')[prevIndex]); 91 preloadAllElementImages(opts['$cont'].children('li')[nextIndex]); 92 93 // setup videos 94 if($(next).hasClass('assettype2')) { 95 setupVideo(next); 96 } 97 if($(next).hasClass('assettype2') || $(next).hasClass('assettype4')) { 98 $(this).parents('.slideshow_wrapper').addClass('ss_showing_video'); 99 } else { 100 $(this).parents('.slideshow_wrapper').removeClass('ss_showing_video'); 101 } 102 103 // stop external (Youtube and Vimeo) 104 if ($(curr).hasClass('assettype4')) { 105 stopExternalVideos(); 106 } 107 108 $(curr).parents('.slideshow').find('.current').removeClass('current'); 109 110 $(this).trigger('onBefore', [curr, next, opts]); 111 } 112 113 function onAfter(curr,next,opts) { 114 // preload images 115 preloadAllElementImages(next); 116 var twoPrev = correctIndex(opts.currSlide - 2, opts.slideCount); 117 var twoNext = correctIndex(opts.currSlide + 2, opts.slideCount); 118 preloadAllElementImages(opts['$cont'].find('.slideshow_image')[twoPrev]); 119 preloadAllElementImages(opts['$cont'].find('.slideshow_image')[twoNext]); 120 121 // remove previous video 122 if (opts.lastSlide != opts.currSlide) { 123 removeVideo(curr); 124 } 125 // update pagination 126 var index = opts.currSlide + 1; 127 opts['$cont'].parents('.slideshow_wrapper').find('.ss_pag_current').text(index); 128 129 $(next).addClass('current'); 130 if ($(this).parents('.slideshow_wrapper').find('.ss_thumbs').length) { 131 $(this).parents('.slideshow_wrapper').find('.ss_thumbs li').removeClass('sel'); 132 $(this).parents('.slideshow_wrapper').find('.ss_thumbs li:eq('+opts.currSlide+')').addClass('sel'); 133 } 134 135 $(this).trigger('onAfter', [curr, next, opts]); 136 } 137 138 // next slide 139 function imageNext(_ss) { 140 $(_ss).find('.slideshow').cycle('next'); 141 } 142 143 // prevous slide 144 function imagePrev(_ss) { 145 $(_ss).find('.slideshow').cycle('prev'); 146 } 147 148 // next slide mobile 149 function imageNextMobile() { 150 var wrapper = $(this).parents('.slideshow_wrapper'); 151 wrapper.find('.slideshow').cycle('next'); 152 } 153 // previous slide mobile 154 function imagePrevMobile() { 155 var wrapper = $(this).parents('.slideshow_wrapper'); 156 wrapper.find('.slideshow').cycle('prev'); 157 } 158 159 function resizeSlideshow(_ss) { 160 _ss.trigger('beforeResize'); 161 var width = _ss.find('.slideshow').width(); 162 var height = _ss.find('.slideshow').height(); 163 _ss.find('.slideshow_image').width(width).height(height); 164 _ss.find('.slideshow_image img').css({'max-width': width, 'max-height': height}); 165 _ss.trigger('afterResize'); 166 } 167 168 function correctIndex(index, length) { 169 if (index < 0) { 170 index = index + length; 171 } 172 if (index >= length) { 173 index = index - length; 174 } 175 return index; 176 } 177 178 function stopExternalVideos() { 179 var videos = document.querySelectorAll('iframe'); 180 Array.prototype.forEach.call(videos, function (video) { 181 if (video.tagName.toLowerCase() === 'video') { 182 video.pause(); 183 } else { 184 var src = video.src; 185 video.src = src; 186 } 187 }); 188 } 189}
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.