{I" class:ETI"BundledAsset;FI"logical_path;TI"(spotlight/blocks/slideshow_block.js;FI" pathname;TI"d/Users/cabeer/Projects/sul/spotlight/app/assets/javascripts/spotlight/blocks/slideshow_block.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+N‡TI" length;Ti¸I" digest;TI"%96fea9c166a91180d36826ae89f45325;FI" source;TI"¸/*! waitForImages jQuery Plugin 2013-07-20 */ !function(a){var b="waitForImages";a.waitForImages={hasImageProperties:["backgroundImage","listStyleImage","borderImage","borderCornerImage","cursor"]},a.expr[":"].uncached=function(b){if(!a(b).is('img[src!=""]'))return!1;var c=new Image;return c.src=b.src,!c.complete},a.fn.waitForImages=function(c,d,e){var f=0,g=0;if(a.isPlainObject(arguments[0])&&(e=arguments[0].waitForAll,d=arguments[0].each,c=arguments[0].finished),c=c||a.noop,d=d||a.noop,e=!!e,!a.isFunction(c)||!a.isFunction(d))throw new TypeError("An invalid callback was supplied.");return this.each(function(){var h=a(this),i=[],j=a.waitForImages.hasImageProperties||[],k=/url\(\s*(['"]?)(.*?)\1\s*\)/g;e?h.find("*").addBack().each(function(){var b=a(this);b.is("img:uncached")&&i.push({src:b.attr("src"),element:b[0]}),a.each(j,function(a,c){var d,e=b.css(c);if(!e)return!0;for(;d=k.exec(e);)i.push({src:d[2],element:b[0]})})}):h.find("img:uncached").each(function(){i.push({src:this.src,element:this})}),f=i.length,g=0,0===f&&c.call(h[0]),a.each(i,function(e,i){var j=new Image;a(j).on("load."+b+" error."+b,function(a){return g++,d.call(i.element,g,f,"load"==a.type),g==f?(c.call(h[0]),!1):void 0}),j.src=i.src})})}}(jQuery); (function($){ var slideshowBlock = function (element, options) { this.$element = $(element); this.options = options; this.paused = false; this.activeIndex = 0; this.init = function() { this.$items = this.$element.find('.item'); this.$indicators = this.$element.find('.slideshow-indicators li'); this.prepAndStart(); this.attachEvents(); } this.init(); } slideshowBlock.prototype = { // Slide to a given image and adjust indicators slide: function(item) { if (this.elementExistsInDom()) { this.activeIndex = this.$items.index(item); this.$items.hide(); $(item).fadeIn(); this.$indicators.removeClass('active'); $(this.$indicators[this.activeIndex]).addClass('active'); if (this.options.autoPlay && !this.paused) this.play(); return this; } else { this.destroy(); } }, // Play slideshow using preset interval play: function() { this.paused = false; if (this.interval) clearInterval(this.interval); this.interval = setInterval($.proxy(this.next, this), this.options.interval); }, // Pause slideshow pause: function() { this.paused = true; this.interval = clearInterval(this.interval); return this; }, // Next function for attaching events in play next: function() { return this.to('next'); }, // Navigate to to: function(pos) { if (pos === 'next') pos = this.activeIndex + 1; if (pos === 'prev') pos = this.activeIndex - 1; return this.slide(this.$items[this.getValidIndex(pos)]); }, // Validate a given index getValidIndex: function(index) { if (typeof index === 'undefined' || index > (this.$items.length - 1)) index = 0; if (index < 0) index = this.$items.length - 1; return index; }, // Resize/re-position elements to a fixed and start slideshow prepAndStart: function() { var maxHeight = 1, _this = this; // wait for all images to load, find the biggest image size and balance others this.$element.waitForImages(function() { $.each(_this.$items.find('a > img'), function(index, img) { maxHeight = Math.max(maxHeight, $(img).outerHeight()); }); maxHeight = Math.min(maxHeight, _this.options.size); $.each(_this.$items, function(index, item) { var img = $(item).find('a > img'); // resize the image (if larger than config size) $(img).height(Math.min(_this.options.size, $(img).height())); // vertically align smaller images to bottom $(img).css('margin-top', maxHeight - $(img).outerHeight()); $(item).height(maxHeight + $(item).find('.caption').outerHeight()); }); _this.to(_this.activeIndex); }); }, // Attach event handlers attachEvents: function() { var $img = this.$element.find('.item a > img'), $caption = this.$element.find('.caption'), _this = this; // pause slideshow on image mouseenter event $img.on('mouseenter', function() { _this.pause(); }); // play slideshow on image mouseleave event $img.on('mouseleave', function() { if (_this.options.autoPlay) _this.play(); }); // show full caption text (primary & secondary) on mouseenter $caption.on('mouseenter', function() { var $caption = $(this), $primary = $caption.find('.primary'), $secondary = $caption.find('.secondary'); $primary.addClass('caption-hover'); $secondary.addClass('caption-hover'); if ($secondary.length > 0) { $primary.css('bottom', $secondary.height()); } }); // revert back to one-line caption text (primary & secondary) on mouseleave $caption.on('mouseleave', function() { var $caption = $(this), $primary = $caption.find('.primary'), $secondary = $caption.find('.secondary'); $primary.removeClass('caption-hover').css('bottom', 0); $secondary.removeClass('caption-hover'); }); this.$element.on('click', '[data-slide], [data-slide-to]', function(e) { pos = parseInt($(this).attr('data-slide-to'), 10) || $(this).attr('data-slide'); _this.pause(); _this.to(pos); e.preventDefault(); }); }, // Destroy obsolete slideshow objects destroy: function() { this.pause(); this.$element.removeData('slideshowBlock').unbind('slideshowBlock').remove(); }, // Check if element exists in DOM elementExistsInDom: function() { return $(document).find(this.$element).length !== 0 ? true : false; } } // Plugin default options slideshowBlock.DEFAULTS = { size: 350, autoPlay: true, interval: 5000 // in milliseconds } // Plugin definition $.fn.slideshowBlock = function(options) { return this.each(function() { var $this = $(this); var options = $.extend({}, slideshowBlock.DEFAULTS, $this.data(), typeof options == 'object' && options); $this.data('slideshowBlock', new slideshowBlock(this, options)); }) } })(jQuery); Spotlight.onLoad(function() { $('.slideshow-block').slideshowBlock(); }); ;TI"required_assets_digest;TI"%c09e95ed22f329c17abb2e57fe91ba63;FI" _version;TI"%069e88c06b889877799890854d7f4c40;F