67 lines
11 KiB
JavaScript
67 lines
11 KiB
JavaScript
/*!
|
|
* reveal.js 1.5 r15
|
|
* http://lab.hakim.se/reveal-js
|
|
* MIT licensed
|
|
*
|
|
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
|
*/
|
|
var Reveal=(function(){var j=".reveal .slides>section",a=".reveal .slides>section.present>section",e=!!("ontouchstart" in window),K={controls:true,progress:true,history:false,keyboard:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:"default",transition:"default"},k=0,c=0,v,C,W=[],d={},M="WebkitPerspective" in document.body.style||"MozPerspective" in document.body.style||"msPerspective" in document.body.style||"OPerspective" in document.body.style||"perspective" in document.body.style,l="WebkitTransform" in document.body.style||"MozTransform" in document.body.style||"msTransform" in document.body.style||"OTransform" in document.body.style||"transform" in document.body.style,y=!!document.body.classList;
|
|
mouseWheelTimeout=0,autoSlideTimeout=0,writeURLTimeout=0,touch={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:40};function h(Y){if((!l&&!M)||!y){document.body.setAttribute("class","no-transforms");
|
|
return;}d.wrapper=document.querySelector(".reveal");d.progress=document.querySelector(".reveal .progress");d.progressbar=document.querySelector(".reveal .progress span");
|
|
if(K.controls){d.controls=document.querySelector(".reveal .controls");d.controlsLeft=document.querySelector(".reveal .controls .left");d.controlsRight=document.querySelector(".reveal .controls .right");
|
|
d.controlsUp=document.querySelector(".reveal .controls .up");d.controlsDown=document.querySelector(".reveal .controls .down");}A();q(K,Y);F();E();H();if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll";
|
|
document.body.style.height="120%";window.addEventListener("load",S,false);window.addEventListener("orientationchange",S,false);}}function F(){if(M===false){K.transition="linear";
|
|
}if(K.controls&&d.controls){d.controls.style.display="block";}if(K.progress&&d.progress){d.progress.style.display="block";}if(K.transition!=="default"){d.wrapper.classList.add(K.transition);
|
|
}if(K.theme!=="default"){document.documentElement.classList.add("theme-"+K.theme);}if(K.mouseWheel){document.addEventListener("DOMMouseScroll",m,false);
|
|
document.addEventListener("mousewheel",m,false);}if(K.rollingLinks){G();}}function A(){document.addEventListener("touchstart",w,false);document.addEventListener("touchmove",U,false);
|
|
document.addEventListener("touchend",O,false);window.addEventListener("hashchange",t,false);if(K.keyboard){document.addEventListener("keydown",V,false);
|
|
}if(K.controls&&d.controls){d.controlsLeft.addEventListener("click",n(x),false);d.controlsRight.addEventListener("click",n(i),false);d.controlsUp.addEventListener("click",n(r),false);
|
|
d.controlsDown.addEventListener("click",n(B),false);}}function N(){document.removeEventListener("keydown",V,false);document.removeEventListener("touchstart",w,false);
|
|
document.removeEventListener("touchmove",U,false);document.removeEventListener("touchend",O,false);window.removeEventListener("hashchange",t,false);if(K.controls&&d.controls){d.controlsLeft.removeEventListener("click",n(x),false);
|
|
d.controlsRight.removeEventListener("click",n(i),false);d.controlsUp.removeEventListener("click",n(r),false);d.controlsDown.removeEventListener("click",n(B),false);
|
|
}}function q(Z,Y){for(var aa in Y){Z[aa]=Y[aa];}}function L(aa,Y){var ab=aa.x-Y.x,Z=aa.y-Y.y;return Math.sqrt(ab*ab+Z*Z);}function n(Y){return function(Z){Z.preventDefault();
|
|
Y.call();};}function S(){setTimeout(function(){window.scrollTo(0,1);},0);}function V(Z){if(Z.target.contentEditable!="inherit"||Z.shiftKey||Z.altKey||Z.ctrlKey||Z.metaKey){return;
|
|
}var Y=false;switch(Z.keyCode){case 80:case 33:Q();Y=true;break;case 78:case 34:u();Y=true;break;case 72:case 37:x();Y=true;break;case 76:case 39:i();Y=true;
|
|
break;case 75:case 38:r();Y=true;break;case 74:case 40:B();Y=true;break;case 36:I(0);Y=true;break;case 35:I(Number.MAX_VALUE);Y=true;break;case 32:R()?T():u();
|
|
Y=true;break;case 13:if(R()){T();Y=true;}break;}if(Y){Z.preventDefault();}else{if(Z.keyCode===27&&M){P();Z.preventDefault();}}H();}function w(Y){touch.startX=Y.touches[0].clientX;
|
|
touch.startY=Y.touches[0].clientY;touch.startCount=Y.touches.length;if(Y.touches.length===2){touch.startSpan=L({x:Y.touches[1].clientX,y:Y.touches[1].clientY},{x:touch.startX,y:touch.startY});
|
|
}}function U(ad){if(!touch.handled){var ab=ad.touches[0].clientX;var aa=ad.touches[0].clientY;if(ad.touches.length===2&&touch.startCount===2){var ac=L({x:ad.touches[1].clientX,y:ad.touches[1].clientY},{x:touch.startX,y:touch.startY});
|
|
if(Math.abs(touch.startSpan-ac)>touch.threshold){touch.handled=true;if(ac<touch.startSpan){D();}else{T();}}}else{if(ad.touches.length===1){var Z=ab-touch.startX,Y=aa-touch.startY;
|
|
if(Z>touch.threshold&&Math.abs(Z)>Math.abs(Y)){touch.handled=true;x();}else{if(Z<-touch.threshold&&Math.abs(Z)>Math.abs(Y)){touch.handled=true;i();}else{if(Y>touch.threshold){touch.handled=true;
|
|
r();}else{if(Y<-touch.threshold){touch.handled=true;B();}}}}}}ad.preventDefault();}}function O(Y){touch.handled=false;}function m(Y){clearTimeout(mouseWheelTimeout);
|
|
mouseWheelTimeout=setTimeout(function(){var Z=Y.detail||-Y.wheelDelta;if(Z>0){u();}else{Q();}},100);}function t(Y){E();}function G(){if(M&&!("msPerspective" in document.body.style)){var Z=document.querySelectorAll(".reveal .slides section a:not(.image)");
|
|
for(var aa=0,Y=Z.length;aa<Y;aa++){var ab=Z[aa];if(ab.textContent&&!ab.querySelector("img")&&(!ab.className||!ab.classList.contains(ab,"roll"))){ab.classList.add("roll");
|
|
ab.innerHTML='<span data-title="'+ab.text+'">'+ab.innerHTML+"</span>";}}}}function D(){d.wrapper.classList.add("overview");var Y=Array.prototype.slice.call(document.querySelectorAll(j));
|
|
for(var ad=0,ab=Y.length;ad<ab;ad++){var aa=Y[ad],ah="translateZ(-2500px) translate("+((ad-k)*105)+"%, 0%)";aa.setAttribute("data-index-h",ad);aa.style.display="block";
|
|
aa.style.WebkitTransform=ah;aa.style.MozTransform=ah;aa.style.msTransform=ah;aa.style.OTransform=ah;aa.style.transform=ah;if(!aa.classList.contains("stack")){aa.addEventListener("click",z,true);
|
|
}var ag=Array.prototype.slice.call(aa.querySelectorAll("section"));for(var ac=0,Z=ag.length;ac<Z;ac++){var af=ag[ac],ae="translate(0%, "+((ac-c)*105)+"%)";
|
|
af.setAttribute("data-index-h",ad);af.setAttribute("data-index-v",ac);af.style.display="block";af.style.WebkitTransform=ae;af.style.MozTransform=ae;af.style.msTransform=ae;
|
|
af.style.OTransform=ae;af.style.transform=ae;af.addEventListener("click",z,true);}}}function T(){d.wrapper.classList.remove("overview");var ab=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section"));
|
|
for(var aa=0,Y=ab.length;aa<Y;aa++){var Z=ab[aa];Z.style.WebkitTransform="";Z.style.MozTransform="";Z.style.msTransform="";Z.style.OTransform="";Z.style.transform="";
|
|
Z.removeEventListener("click",z);}b();}function R(){return d.wrapper.classList.contains("overview");}function z(Y){if(R()){Y.preventDefault();T();k=this.getAttribute("data-index-h");
|
|
c=this.getAttribute("data-index-v");b();}}function X(Z,ab){var ad=Array.prototype.slice.call(document.querySelectorAll(Z)),ae=ad.length;if(ae){if(K.loop){ab%=ae;
|
|
if(ab<0){ab=ae+ab;}}ab=Math.max(Math.min(ab,ae-1),0);for(var ac=0;ac<ae;ac++){var Y=ad[ac];if(R()===false){var af=Math.abs((ab-ac)%(ae-3))||0;Y.style.display=af>3?"none":"block";
|
|
}ad[ac].classList.remove("past");ad[ac].classList.remove("present");ad[ac].classList.remove("future");if(ac<ab){ad[ac].classList.add("past");}else{if(ac>ab){ad[ac].classList.add("future");
|
|
}}if(Y.querySelector("section")){ad[ac].classList.add("stack");}}ad[ab].classList.add("present");var aa=ad[ab].getAttribute("data-state");if(aa){W=W.concat(aa.split(" "));
|
|
}}else{ab=0;}return ab;}function b(ae,ai){v=C;var ab=W.concat();W.length=0;var ah=k,Z=c;k=X(j,ae===undefined?k:ae);c=X(a,ai===undefined?c:ai);stateLoop:for(var ac=0,af=W.length;
|
|
ac<af;ac++){for(var aa=0;aa<ab.length;aa++){if(ab[aa]===W[ac]){ab.splice(aa,1);continue stateLoop;}}document.documentElement.classList.add(W[ac]);o(W[ac]);
|
|
}while(ab.length){document.documentElement.classList.remove(ab.pop());}if(K.progress&&d.progress){d.progressbar.style.width=(k/(document.querySelectorAll(j).length-1))*window.innerWidth+"px";
|
|
}if(R()){D();}p();clearTimeout(writeURLTimeout);writeURLTimeout=setTimeout(g,1500);var Y=document.querySelectorAll(j);var ag=Y[k],ad=ag.querySelectorAll("section");
|
|
C=ad[c]||ag;if(k!==ah||c!==Z){o("slidechanged",{indexh:k,indexv:c,previousSlide:v,currentSlide:C});}else{v=null;}if(v){v.classList.remove("present");}}function p(){if(!K.controls||!d.controls){return;
|
|
}var Y=f();[d.controlsLeft,d.controlsRight,d.controlsUp,d.controlsDown].forEach(function(Z){Z.classList.remove("enabled");});if(Y.left){d.controlsLeft.classList.add("enabled");
|
|
}if(Y.right){d.controlsRight.classList.add("enabled");}if(Y.up){d.controlsUp.classList.add("enabled");}if(Y.down){d.controlsDown.classList.add("enabled");
|
|
}}function f(){var Y=document.querySelectorAll(j);var Z=document.querySelectorAll(a);return{left:k>0,right:k<Y.length-1,up:c>0,down:c<Z.length-1};}function E(){var aa=window.location.hash.slice(2).split("/");
|
|
var Z=parseInt(aa[0])||0;var Y=parseInt(aa[1])||0;I(Z,Y);}function g(){if(K.history){var Y="/";if(k>0||c>0){Y+=k;}if(c>0){Y+="/"+c;}window.location.hash=Y;
|
|
}}function o(Z,Y){var aa=document.createEvent("HTMLEvents",1,2);aa.initEvent(Z,true,true);q(aa,Y);d.wrapper.dispatchEvent(aa);}function s(){if(document.querySelector(a+".present")){var Z=document.querySelectorAll(a+".present .fragment:not(.visible)");
|
|
if(Z.length){Z[0].classList.add("visible");o("fragmentshown",{fragment:Z[0]});return true;}}else{var Y=document.querySelectorAll(j+".present .fragment:not(.visible)");
|
|
if(Y.length){Y[0].classList.add("visible");o("fragmentshown",{fragment:Y[0]});return true;}}return false;}function J(){if(document.querySelector(a+".present")){var Z=document.querySelectorAll(a+".present .fragment.visible");
|
|
if(Z.length){Z[Z.length-1].classList.remove("visible");o("fragmenthidden",{fragment:Z[Z.length-1]});return true;}}else{var Y=document.querySelectorAll(j+".present .fragment.visible");
|
|
if(Y.length){Y[Y.length-1].classList.remove("visible");o("fragmenthidden",{fragment:Y[Y.length-1]});return true;}}return false;}function H(){clearTimeout(autoSlideTimeout);
|
|
if(K.autoSlide){autoSlideTimeout=setTimeout(u,K.autoSlide);}}function I(Z,Y){b(Z,Y);}function x(){if(R()||J()===false){b(k-1,0);}}function i(){if(R()||s()===false){b(k+1,0);
|
|
}}function r(){if(R()||J()===false){b(k,c-1);}}function B(){if(R()||s()===false){b(k,c+1);}}function Q(){if(J()===false){if(f().up){r();}else{var Y=document.querySelector(".reveal .slides>section.past:nth-child("+k+")");
|
|
if(Y){c=(Y.querySelectorAll("section").length+1)||0;k--;b();}}}}function u(){if(s()===false){f().down?B():i();}H();}function P(){if(R()){T();}else{D();
|
|
}}return{initialize:h,navigateTo:I,navigateLeft:x,navigateRight:i,navigateUp:r,navigateDown:B,navigatePrev:Q,navigateNext:u,toggleOverview:P,addEventListeners:A,removeEventListeners:N,getIndices:function(){return{h:k,v:c};
|
|
},getPreviousSlide:function(){return v;},getCurrentSlide:function(){return C;},getQueryHash:function(){var Y={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(Z){Y[Z.split("=").shift()]=Z.split("=").pop();
|
|
});return Y;},addEventListener:function(Z,aa,Y){if("addEventListener" in window){(d.wrapper||document.querySelector(".reveal")).addEventListener(Z,aa,Y);
|
|
}},removeEventListener:function(Z,aa,Y){if("addEventListener" in window){(d.wrapper||document.querySelector(".reveal")).removeEventListener(Z,aa,Y);}}};
|
|
})(); |