Template:Team:Leeds TouchGalleryjs

From 2013.igem.org

/*!

* To use this javascript, reference the url with the suffix ?action=raw&ctype=text/javascript
* This and other javascript files from http://www.dynamicdrive.com
*/

(function(e){var t={width:300,height:250,navarea:"45%",curslide:0,threshold:75,navbuttons:["Leeds_GalleryLeft.png","Leeds_GalleryRight.png",250]};var n={triggerOnTouchEnd:true,triggerOnTouchLeave:true,allowPageScroll:"vertical"};e.fn.touchgallery=function(r){return this.each(function(){function c(e){clearTimeout(i.hidenavtimer);var t=i.curslide;switch(e){case"forth":i.curslide=t0?t-1:u-1;break;default:i.curslide=parseInt(e)}f.removeClass("selected").eq(i.curslide).addClass("selected");s.css("left",-i.width*i.curslide)}var i=e.extend({},t,r);$slideshow=e(this),swipestart=false,initialx=0,dist=0,swipecount=0;var s=$slideshow.find("ul:eq(0)");var o=s.find("li");var u=o.length;var a=e('<div class="jumptodiv" />').html(function(){var e="";for(var t=0;t<u;t++){e+=' '}return e}()).appendTo($slideshow);var f=a.find("span");var l=e('<div style="position:absolute; width: '+i.navarea+"; height: 100%; left: 0; top: 0; text-align: left; line-height:"+i.height+'px; cursor: pointer; opacity: 0" />').clone().addBack().eq(0).data({dir:"back"}).html('<img src="'+i.navbuttons[0]+'" style="vertical-align: middle; position:relative; top:'+i.navbuttons[2]+'px" title="Back one image" />').end().eq(1).data({dir:"forth"}).css({left:"auto",right:0,textAlign:"right"}).html('<img src="'+i.navbuttons[1]+'" style="vertical-align: middle; position:relative; top:'+i.navbuttons[2]+'px" title="Forward one image" />').end().on("selectstart",function(){return false}).appendTo($slideshow);$slideshow.on("mouseenter mouseleave",function(e){var t=e.type=="mouseenter"?1:0;l.animate({opacity:t},200)});$slideshow.add(o).css({width:i.width,height:i.height});s.css({width:i.width*u});c(i.curslide);n.swipeStatus=function(e,t,n,r){if(t=="start"){swipestart=true;swipecount=0;initialx=parseInt(s.css("left"));dist=0}else if(t=="move"&&swipestart){dist=(n=="left"?-1:1)*r+initialx;s.css("left",Math.min(dist,(i.curslide+1)*i.width))}else if(t=="cancel"){s.css("left",-i.width*i.curslide)}else if(t=="end"){if(r<i.threshold){c(i.curslide)}else{swipecount++;if(swipecount==1){c(n=="left"?"forth":"back")}}swipestart=false}};n.tap=function(e,t){l.css({opacity:1});i.hidenavtimer=setTimeout(function(){l.css({opacity:0})},2e3)};$slideshow.swipe(n);l.swipe({tap:function(t){var n=e(this);c(n.data("dir"))}});a.swipe({tap:function(t){if(t.target.tagName=="SPAN"){var n=e(t.target);c(parseInt(n.data("image")))}}})})}})(jQuery)