// ----------------------------------------------------------------------------------- // // Lightbox Slideshow v1.1 // by Justin Barkhuff - http://www.justinbarkhuff.com/lab/lightbox_slideshow/ // Updated: 2007-08-15 // // Largely based on Lightbox v2.02 // by Lokesh Dhakar - http://huddletogether.com/projects/lightbox2/ // 3/31/06 // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // // The code inserts html at the bottom of the page that looks similar to this: // //
// // // ----------------------------------------------------------------------------------- // // Lightbox Object // var Lightbox = { activeImage : null, badObjects : ['select','object','embed'], container : null, enableSlideshow : null, groupName : null, imageArray : [], options : null, overlayDuration : null, overlayOpacity : null, playSlides : null, refTags : ['a','area'], relAttribute : null, resizeDuration : null, slideShowTimer : null, startImage : null, // // initialize() // Constructor sets class properties and configuration options and // inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function(options) { if (!document.getElementsByTagName){ return; } this.options = $H({ animate : true, // resizing animations autoPlay : false, // should slideshow start automatically /* config */ borderSize : 10, // if you adjust the padding in the CSS, you will need to update this variable containerID : document, // lightbox container object enableSlideshow : true, // enable slideshow feature /* config? */ googleAnalytics : false, // track individual image views using Google Analytics imageDataLocation : 'south', // location of image caption information initImage : '', // ID of image link to automatically launch when upon script initialization loop : true, // whether to continuously loop slideshow images /* config? */ overlayDuration : .2, // time to fade in shadow overlay overlayOpacity : .8, // transparency of shadow overlay prefix : '', // ID prefix for all dynamically created html elements relAttribute : 'lightbox', // specifies the rel attribute value that triggers lightbox resizeSpeed : 7, // controls the speed of the image resizing (1=slowest and 10=fastest) showGroupName : false, // show group name of images in image details slideTime : 4, // time to display images during slideshow /* config */ strings : { // allows for localization closeLink : 'close', loadingMsg : 'loading', nextLink : 'next »', prevLink : '« prev', startSlideshow : 'start slideshow', stopSlideshow : 'stop slideshow', numDisplayPrefix : 'Image', numDisplaySeparator : 'of' } }).merge(options); if(this.options.animate){ this.overlayDuration = Math.max(this.options.overlayDuration,0); this.options.resizeSpeed = Math.max(Math.min(this.options.resizeSpeed,10),1); this.resizeDuration = (11 - this.options.resizeSpeed) * 0.15; }else{ this.overlayDuration = 0; this.resizeDuration = 0; } this.enableSlideshow = this.options.enableSlideshow; this.overlayOpacity = Math.max(Math.min(this.options.overlayOpacity,1),0); this.playSlides = this.options.autoPlay; this.container = $(this.options.containerID); this.relAttribute = this.options.relAttribute; this.updateImageList(); var objBody = this.container != document ? this.container : document.getElementsByTagName('body').item(0); var objOverlay = document.createElement('div'); objOverlay.setAttribute('id',this.getID('overlay')); objOverlay.style.display = 'none'; objBody.appendChild(objOverlay); Event.observe(objOverlay,'click',this.end.bindAsEventListener(this)); var objLightbox = document.createElement('div'); objLightbox.setAttribute('id',this.getID('lightbox')); objLightbox.style.display = 'none'; objBody.appendChild(objLightbox); var objImageDataContainer = document.createElement('div'); objImageDataContainer.setAttribute('id',this.getID('imageDataContainer')); objImageDataContainer.className = this.getID('clearfix'); var objImageData = document.createElement('div'); objImageData.setAttribute('id',this.getID('imageData')); objImageDataContainer.appendChild(objImageData); var objImageDetails = document.createElement('div'); objImageDetails.setAttribute('id',this.getID('imageDetails')); objImageData.appendChild(objImageDetails); var objCaption = document.createElement('span'); objCaption.setAttribute('id',this.getID('caption')); objImageDetails.appendChild(objCaption); var objNumberDisplay = document.createElement('span'); objNumberDisplay.setAttribute('id',this.getID('numberDisplay')); objImageDetails.appendChild(objNumberDisplay); var objDetailsNav = document.createElement('span'); objDetailsNav.setAttribute('id',this.getID('detailsNav')); objImageDetails.appendChild(objDetailsNav); var objPrevLink = document.createElement('a'); objPrevLink.setAttribute('id',this.getID('prevLinkDetails')); objPrevLink.setAttribute('href','javascript:void(0);'); objPrevLink.innerHTML = this.options.strings.prevLink; objDetailsNav.appendChild(objPrevLink); Event.observe(objPrevLink,'click',this.showPrev.bindAsEventListener(this)); var objNextLink = document.createElement('a'); objNextLink.setAttribute('id',this.getID('nextLinkDetails')); objNextLink.setAttribute('href','javascript:void(0);'); objNextLink.innerHTML = this.options.strings.nextLink; objDetailsNav.appendChild(objNextLink); Event.observe(objNextLink,'click',this.showNext.bindAsEventListener(this)); var objSlideShowControl = document.createElement('a'); objSlideShowControl.setAttribute('id',this.getID('slideShowControl')); objSlideShowControl.setAttribute('href','javascript:void(0);'); objDetailsNav.appendChild(objSlideShowControl); Event.observe(objSlideShowControl,'click',this.toggleSlideShow.bindAsEventListener(this)); var objClose = document.createElement('div'); objClose.setAttribute('id',this.getID('close')); objImageData.appendChild(objClose); var objCloseLink = document.createElement('a'); objCloseLink.setAttribute('id',this.getID('closeLink')); objCloseLink.setAttribute('href','javascript:void(0);'); objCloseLink.innerHTML = this.options.strings.closeLink; objClose.appendChild(objCloseLink); Event.observe(objCloseLink,'click',this.end.bindAsEventListener(this)); if(this.options.imageDataLocation == 'north'){ objLightbox.appendChild(objImageDataContainer); } var objOuterImageContainer = document.createElement('div'); objOuterImageContainer.setAttribute('id',this.getID('outerImageContainer')); objLightbox.appendChild(objOuterImageContainer); var objImageContainer = document.createElement('div'); objImageContainer.setAttribute('id',this.getID('imageContainer')); objOuterImageContainer.appendChild(objImageContainer); var objLightboxImage = document.createElement('img'); objLightboxImage.setAttribute('id',this.getID('lightboxImage')); objImageContainer.appendChild(objLightboxImage); var objHoverNav = document.createElement('div'); objHoverNav.setAttribute('id',this.getID('hoverNav')); objImageContainer.appendChild(objHoverNav); var objPrevLinkImg = document.createElement('a'); objPrevLinkImg.setAttribute('id',this.getID('prevLinkImg')); objPrevLinkImg.setAttribute('href','javascript:void(0);'); objHoverNav.appendChild(objPrevLinkImg); Event.observe(objPrevLinkImg,'click',this.showPrev.bindAsEventListener(this)); var objNextLinkImg = document.createElement('a'); objNextLinkImg.setAttribute('id',this.getID('nextLinkImg')); objNextLinkImg.setAttribute('href','javascript:void(0);'); objHoverNav.appendChild(objNextLinkImg); Event.observe(objNextLinkImg,'click',this.showNext.bindAsEventListener(this)); var objLoading = document.createElement('div'); objLoading.setAttribute('id',this.getID('loading')); objImageContainer.appendChild(objLoading); var objLoadingLink = document.createElement('a'); objLoadingLink.setAttribute('id',this.getID('loadingLink')); objLoadingLink.setAttribute('href','javascript:void(0);'); objLoadingLink.innerHTML = this.options.strings.loadingMsg; objLoading.appendChild(objLoadingLink); Event.observe(objLoadingLink,'click',this.end.bindAsEventListener(this)); if(this.options.imageDataLocation != 'north'){ objLightbox.appendChild(objImageDataContainer); } if(this.options.initImage != ''){ this.start($(this.options.initImage)); } }, // // updateImageList() // Loops through specific tags within 'container' looking for // 'lightbox' references and applies onclick events to them. // updateImageList: function(){ var el, els, rel; for(var i=0; i < this.refTags.length; i++){ els = this.container.getElementsByTagName(this.refTags[i]); for(var j=0; j < els.length; j++){ el = els[j]; rel = String(el.getAttribute('rel')); if (el.getAttribute('href') && (rel.toLowerCase().match(this.relAttribute))){ el.onclick = function(){Lightbox.start(this); return false;} } } } }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { this.hideBadObjects(); // stretch overlay to fill page and fade in var pageSize = this.getPageSize(); $(this.getID('overlay')).setStyle({height:pageSize.pageHeight+'px'}); new Effect.Appear(this.getID('overlay'), { duration: this.overlayDuration, from: 0, to: this.overlayOpacity }); this.imageArray = []; this.groupName = null; var rel = imageLink.getAttribute('rel'); var imageTitle = ''; // if image is NOT part of a group.. if(rel == this.relAttribute){ // add single image to imageArray imageTitle = imageLink.getAttribute('title') ? imageLink.getAttribute('title') : ''; this.imageArray.push({'link':imageLink.getAttribute('href'), 'title':imageTitle}); this.startImage = 0; } else { // if image is part of a group.. var els = this.container.getElementsByTagName(imageLink.tagName); // loop through anchors, find other images in group, and add them to imageArray for (var i=0; i