86 lines
15 KiB
JavaScript
86 lines
15 KiB
JavaScript
/*!
|
|
* reveal.js 2.2 r38
|
|
* http://lab.hakim.se/reveal-js
|
|
* MIT licensed
|
|
*
|
|
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
|
|
*/
|
|
var Reveal=(function(){var m=".reveal .slides>section",b=".reveal .slides>section.present>section",T={controls:true,progress:true,history:false,keyboard:true,overview:true,center:false,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:null,transition:"default",dependencies:[]},aa=T.autoSlide,n=0,e=0,z,H,am=[],f={},V="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,o="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,A=0,l=0,E=0,ae={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:80};
|
|
function j(an){if((!o&&!V)){document.body.setAttribute("class","no-transforms");return;}u(T,an);d();X();}function Q(){f.theme=document.querySelector("#theme");
|
|
f.wrapper=document.querySelector(".reveal");if(!f.wrapper.querySelector(".progress")&&T.progress){var aq=document.createElement("div");aq.classList.add("progress");
|
|
aq.innerHTML="<span></span>";f.wrapper.appendChild(aq);}if(!f.wrapper.querySelector(".controls")&&T.controls){var ap=document.createElement("aside");ap.classList.add("controls");
|
|
ap.innerHTML='<div class="left"></div><div class="right"></div><div class="up"></div><div class="down"></div>';f.wrapper.appendChild(ap);}if(!f.wrapper.querySelector(".state-background")){var ao=document.createElement("div");
|
|
ao.classList.add("state-background");f.wrapper.appendChild(ao);}if(!f.wrapper.querySelector(".pause-overlay")){var an=document.createElement("div");an.classList.add("pause-overlay");
|
|
f.wrapper.appendChild(an);}f.progress=document.querySelector(".reveal .progress");f.progressbar=document.querySelector(".reveal .progress span");if(T.controls){f.controls=document.querySelector(".reveal .controls");
|
|
f.controlsLeft=document.querySelector(".reveal .controls .left");f.controlsRight=document.querySelector(".reveal .controls .right");f.controlsUp=document.querySelector(".reveal .controls .up");
|
|
f.controlsDown=document.querySelector(".reveal .controls .down");}}function d(){if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll";
|
|
document.body.style.height="120%";window.addEventListener("load",af,false);window.addEventListener("orientationchange",af,false);}}function X(){var ao=[],at=[];
|
|
for(var ap=0,an=T.dependencies.length;ap<an;ap++){var aq=T.dependencies[ap];if(!aq.condition||aq.condition()){if(aq.async){at.push(aq.src);}else{ao.push(aq.src);
|
|
}if(typeof aq.callback==="function"){head.ready(aq.src.match(/([\w\d_\-]*)\.?[^\\\/]*$/i)[0],aq.callback);}}}function ar(){if(at.length){head.js.apply(null,at);
|
|
}I();}if(ao.length){head.ready(ar);head.js.apply(null,ao);}else{ar();}}function I(){Q();F();L();R();K();P();setTimeout(function(){s("ready",{indexh:n,indexv:e,currentSlide:H});
|
|
},1);}function L(){if(V===false){T.transition="linear";}if(T.controls&&f.controls){f.controls.style.display="block";}if(T.progress&&f.progress){f.progress.style.display="block";
|
|
}if(T.transition!=="default"){f.wrapper.classList.add(T.transition);}if(T.center){f.wrapper.classList.add("center");}if(T.mouseWheel){document.addEventListener("DOMMouseScroll",p,false);
|
|
document.addEventListener("mousewheel",p,false);}if(T.rollingLinks){O();}if(T.theme&&f.theme){var ap=f.theme.getAttribute("href");var an=/[^\/]*?(?=\.css)/;
|
|
var ao=ap.match(an)[0];if(T.theme!==ao){ap=ap.replace(an,T.theme);f.theme.setAttribute("href",ap);}}}function F(){document.addEventListener("touchstart",B,false);
|
|
document.addEventListener("touchmove",ah,false);document.addEventListener("touchend",Y,false);window.addEventListener("hashchange",x,false);window.addEventListener("resize",g,false);
|
|
if(T.keyboard){document.addEventListener("keydown",aj,false);}if(T.progress&&f.progress){f.progress.addEventListener("click",r(ak),false);}if(T.controls&&f.controls){f.controlsLeft.addEventListener("click",r(C),false);
|
|
f.controlsRight.addEventListener("click",r(k),false);f.controlsUp.addEventListener("click",r(v),false);f.controlsDown.addEventListener("click",r(G),false);
|
|
}}function W(){document.removeEventListener("keydown",aj,false);document.removeEventListener("touchstart",B,false);document.removeEventListener("touchmove",ah,false);
|
|
document.removeEventListener("touchend",Y,false);window.removeEventListener("hashchange",x,false);window.removeEventListener("resize",g,false);if(T.progress&&f.progress){f.progress.removeEventListener("click",r(ak),false);
|
|
}if(T.controls&&f.controls){f.controlsLeft.removeEventListener("click",r(C),false);f.controlsRight.removeEventListener("click",r(k),false);f.controlsUp.removeEventListener("click",r(v),false);
|
|
f.controlsDown.removeEventListener("click",r(G),false);}}function u(ao,an){for(var ap in an){ao[ap]=an[ap];}}function U(ap,an){var aq=ap.x-an.x,ao=ap.y-an.y;
|
|
return Math.sqrt(aq*aq+ao*ao);}function r(an){return function(ao){ao.preventDefault();an.call(null,ao);};}function af(){setTimeout(function(){window.scrollTo(0,1);
|
|
},0);}function s(ao,an){var ap=document.createEvent("HTMLEvents",1,2);ap.initEvent(ao,true,true);u(ap,an);f.wrapper.dispatchEvent(ap);}function O(){if(V&&!("msPerspective" in document.body.style)){var ao=document.querySelectorAll(".reveal .slides section a:not(.image)");
|
|
for(var ap=0,an=ao.length;ap<an;ap++){var aq=ao[ap];if(aq.textContent&&!aq.querySelector("img")&&(!aq.className||!aq.classList.contains(aq,"roll"))){aq.classList.add("roll");
|
|
aq.innerHTML='<span data-title="'+aq.text+'">'+aq.innerHTML+"</span>";}}}}function R(){if(T.center){var aq=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section"));
|
|
var ar=-f.wrapper.offsetHeight/2;for(var ap=0,ao=aq.length;ap<ao;ap++){var an=aq[ap];if(an.classList.contains("stack")){an.style.top=0;}else{an.style.top=Math.max(-(an.offsetHeight/2)-20,ar)+"px";
|
|
}}}}function J(){if(T.overview){f.wrapper.classList.add("overview");var an=document.querySelectorAll(m);for(var at=0,aq=an.length;at<aq;at++){var ap=an[at],ax="translateZ(-2500px) translate("+((at-n)*105)+"%, 0%)";
|
|
ap.setAttribute("data-index-h",at);ap.style.display="block";ap.style.WebkitTransform=ax;ap.style.MozTransform=ax;ap.style.msTransform=ax;ap.style.OTransform=ax;
|
|
ap.style.transform=ax;if(!ap.classList.contains("stack")){ap.addEventListener("click",D,true);}var aw=ap.querySelectorAll("section");for(var ar=0,ao=aw.length;
|
|
ar<ao;ar++){var av=aw[ar],au="translate(0%, "+((ar-(at===n?e:0))*105)+"%)";av.setAttribute("data-index-h",at);av.setAttribute("data-index-v",ar);av.style.display="block";
|
|
av.style.WebkitTransform=au;av.style.MozTransform=au;av.style.msTransform=au;av.style.OTransform=au;av.style.transform=au;av.addEventListener("click",D,true);
|
|
}}}}function ag(){if(T.overview){f.wrapper.classList.remove("overview");var aq=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section"));
|
|
for(var ap=0,an=aq.length;ap<an;ap++){var ao=aq[ap];ao.style.WebkitTransform="";ao.style.MozTransform="";ao.style.msTransform="";ao.style.OTransform="";
|
|
ao.style.transform="";ao.removeEventListener("click",D);}a();}}function Z(an){if(typeof an==="boolean"){an?J():ag();}else{M()?ag():J();}}function M(){return f.wrapper.classList.contains("overview");
|
|
}function ad(){var an=document.body;var ao=an.requestFullScreen||an.webkitRequestFullScreen||an.mozRequestFullScreen||an.msRequestFullScreen;if(ao){ao.apply(an);
|
|
}}function c(){f.wrapper.classList.add("paused");}function q(){f.wrapper.classList.remove("paused");}function ac(){if(ai()){q();}else{c();}}function ai(){return f.wrapper.classList.contains("paused");
|
|
}function a(au,ay){z=H;var aq=am.concat();am.length=0;var ax=n,ao=e;n=al(m,au===undefined?n:au);e=al(b,ay===undefined?e:ay);R();stateLoop:for(var ar=0,av=am.length;
|
|
ar<av;ar++){for(var ap=0;ap<aq.length;ap++){if(aq[ap]===am[ar]){aq.splice(ap,1);continue stateLoop;}}document.documentElement.classList.add(am[ar]);s(am[ar]);
|
|
}while(aq.length){document.documentElement.classList.remove(aq.pop());}if(T.progress&&f.progress){f.progressbar.style.width=(n/(document.querySelectorAll(m).length-1))*window.innerWidth+"px";
|
|
}if(M()){J();}t();clearTimeout(E);E=setTimeout(i,1500);var an=document.querySelectorAll(m);var aw=an[n],at=aw.querySelectorAll("section");H=at[e]||aw;if(n!==ax||e!==ao){s("slidechanged",{indexh:n,indexv:e,previousSlide:z,currentSlide:H});
|
|
}else{z=null;}if(z){z.classList.remove("present");}}function al(aq,aw){var ao=Array.prototype.slice.call(document.querySelectorAll(aq)),av=ao.length;if(av){if(T.loop){aw%=av;
|
|
if(aw<0){aw=av+aw;}}aw=Math.max(Math.min(aw,av-1),0);for(var at=0;at<av;at++){var au=ao[at];if(M()===false){var an=Math.abs((aw-at)%(av-3))||0;au.style.display=an>3?"none":"block";
|
|
}ao[at].classList.remove("past");ao[at].classList.remove("present");ao[at].classList.remove("future");if(at<aw){ao[at].classList.add("past");}else{if(at>aw){ao[at].classList.add("future");
|
|
}}if(au.querySelector("section")){ao[at].classList.add("stack");}}ao[aw].classList.add("present");var ap=ao[aw].getAttribute("data-state");if(ap){am=am.concat(ap.split(" "));
|
|
}var ar=ao[aw].getAttribute("data-autoslide");if(ar){aa=parseInt(ar);}else{aa=T.autoSlide;}}else{aw=0;}return aw;}function t(){if(T.controls&&f.controls){var an=h();
|
|
[f.controlsLeft,f.controlsRight,f.controlsUp,f.controlsDown].forEach(function(ao){ao.classList.remove("enabled");});if(an.left){f.controlsLeft.classList.add("enabled");
|
|
}if(an.right){f.controlsRight.classList.add("enabled");}if(an.up){f.controlsUp.classList.add("enabled");}if(an.down){f.controlsDown.classList.add("enabled");
|
|
}}}function h(){var an=document.querySelectorAll(m),ao=document.querySelectorAll(b);return{left:n>0,right:n<an.length-1,up:e>0,down:e<ao.length-1};}function K(){var at=window.location.hash;
|
|
var ar=at.slice(2).split("/"),ao=at.replace(/#|\//gi,"");if(isNaN(parseInt(ar[0],10))&&ao.length){var ap=document.querySelector("#"+ao);if(ap){var au=Reveal.getIndices(ap);
|
|
a(au.h,au.v);}else{a(n,e);}}else{var aq=parseInt(ar[0],10)||0,an=parseInt(ar[1],10)||0;a(aq,an);}}function i(){if(T.history){var an="/";if(n>0||e>0){an+=n;
|
|
}if(e>0){an+="/"+e;}window.location.hash=an;}}function N(an){var ar=n,ap=e;if(an){var at=!!an.parentNode.nodeName.match(/section/gi);var aq=at?an.parentNode:an;
|
|
var ao=Array.prototype.slice.call(document.querySelectorAll(m));ar=Math.max(ao.indexOf(aq),0);if(at){ap=Math.max(Array.prototype.slice.call(an.parentNode.children).indexOf(an),0);
|
|
}}return{h:ar,v:ap};}function w(){if(document.querySelector(b+".present")){var ao=document.querySelectorAll(b+".present .fragment:not(.visible)");if(ao.length){ao[0].classList.add("visible");
|
|
s("fragmentshown",{fragment:ao[0]});return true;}}else{var an=document.querySelectorAll(m+".present .fragment:not(.visible)");if(an.length){an[0].classList.add("visible");
|
|
s("fragmentshown",{fragment:an[0]});return true;}}return false;}function S(){if(document.querySelector(b+".present")){var ao=document.querySelectorAll(b+".present .fragment.visible");
|
|
if(ao.length){ao[ao.length-1].classList.remove("visible");s("fragmenthidden",{fragment:ao[ao.length-1]});return true;}}else{var an=document.querySelectorAll(m+".present .fragment.visible");
|
|
if(an.length){an[an.length-1].classList.remove("visible");s("fragmenthidden",{fragment:an[an.length-1]});return true;}}return false;}function P(){clearTimeout(l);
|
|
if(aa){l=setTimeout(y,aa);}}function C(){if(h().left&&(M()||S()===false)){a(n-1,0);}}function k(){if(h().right&&(M()||w()===false)){a(n+1,0);}}function v(){if(h().up&&(M()||S()===false)){a(n,e-1);
|
|
}}function G(){if(h().down&&(M()||w()===false)){a(n,e+1);}}function ab(){if(S()===false){if(h().up){v();}else{var an=document.querySelector(".reveal .slides>section.past:nth-child("+n+")");
|
|
if(an){e=(an.querySelectorAll("section").length+1)||0;n--;a();}}}}function y(){if(w()===false){h().down?G():k();}P();}function aj(ap){var ao=document.activeElement;
|
|
var aq=!!(document.activeElement&&(document.activeElement.type||document.activeElement.href||document.activeElement.contentEditable!=="inherit"));if(aq||ap.shiftKey||ap.altKey||ap.ctrlKey||ap.metaKey){return;
|
|
}var an=true;switch(ap.keyCode){case 80:case 33:ab();break;case 78:case 34:y();break;case 72:case 37:C();break;case 76:case 39:k();break;case 75:case 38:v();
|
|
break;case 74:case 40:G();break;case 36:a(0);break;case 35:a(Number.MAX_VALUE);break;case 32:M()?ag():y();break;case 13:M()?ag():an=false;break;case 66:case 190:ac();
|
|
break;case 70:ad();break;default:an=false;}if(an){ap.preventDefault();}else{if(ap.keyCode===27&&V){Z();ap.preventDefault();}}P();}function B(an){ae.startX=an.touches[0].clientX;
|
|
ae.startY=an.touches[0].clientY;ae.startCount=an.touches.length;if(an.touches.length===2&&T.overview){ae.startSpan=U({x:an.touches[1].clientX,y:an.touches[1].clientY},{x:ae.startX,y:ae.startY});
|
|
}}function ah(at){if(!ae.handled){var aq=at.touches[0].clientX;var ap=at.touches[0].clientY;if(at.touches.length===2&&ae.startCount===2&&T.overview){var ar=U({x:at.touches[1].clientX,y:at.touches[1].clientY},{x:ae.startX,y:ae.startY});
|
|
if(Math.abs(ae.startSpan-ar)>ae.threshold){ae.handled=true;if(ar<ae.startSpan){J();}else{ag();}}at.preventDefault();}else{if(at.touches.length===1&&ae.startCount!==2){var ao=aq-ae.startX,an=ap-ae.startY;
|
|
if(ao>ae.threshold&&Math.abs(ao)>Math.abs(an)){ae.handled=true;C();}else{if(ao<-ae.threshold&&Math.abs(ao)>Math.abs(an)){ae.handled=true;k();}else{if(an>ae.threshold){ae.handled=true;
|
|
v();}else{if(an<-ae.threshold){ae.handled=true;G();}}}}at.preventDefault();}}}else{if(navigator.userAgent.match(/android/gi)){at.preventDefault();}}}function Y(an){ae.handled=false;
|
|
}function p(an){clearTimeout(A);A=setTimeout(function(){var ao=an.detail||-an.wheelDelta;if(ao>0){y();}else{ab();}},100);}function ak(ao){var an=Array.prototype.slice.call(document.querySelectorAll(m)).length;
|
|
var ap=Math.floor((ao.clientX/f.wrapper.offsetWidth)*an);a(ap);}function x(an){K();}function g(an){R();}function D(an){if(M()){an.preventDefault();ag();
|
|
n=this.getAttribute("data-index-h");e=this.getAttribute("data-index-v");a();}}return{initialize:j,slide:a,left:C,right:k,up:v,down:G,prev:ab,next:y,prevFragment:S,nextFragment:w,navigateTo:a,navigateLeft:C,navigateRight:k,navigateUp:v,navigateDown:G,navigatePrev:ab,navigateNext:y,toggleOverview:Z,addEventListeners:F,removeEventListeners:W,getIndices:N,getPreviousSlide:function(){return z;
|
|
},getCurrentSlide:function(){return H;},getQueryHash:function(){var an={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(ao){an[ao.split("=").shift()]=ao.split("=").pop();
|
|
});return an;},addEventListener:function(ao,ap,an){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).addEventListener(ao,ap,an);
|
|
}},removeEventListener:function(ao,ap,an){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).removeEventListener(ao,ap,an);
|
|
}}};})(); |