48 lines
7.7 KiB
JavaScript
48 lines
7.7 KiB
JavaScript
|
/*!
|
||
|
* reveal.js 1.3
|
||
|
* http://lab.hakim.se/reveal-js
|
||
|
* MIT licensed
|
||
|
*
|
||
|
* Copyright (C) 2011 Hakim El Hattab, http://hakim.se
|
||
|
*/
|
||
|
var Reveal=(function(){var i="#reveal .slides>section",a="#reveal .slides>section.present>section",j=0,c=0,E={controls:false,progress:false,history:false,transition:"default",theme:"default",mouseWheel:true,rollingLinks:true},K=[],d={},F=document.body.style.perspectiveProperty!==undefined||document.body.style.WebkitPerspective!==undefined||document.body.style.MozPerspective!==undefined||document.body.style.msPerspective!==undefined,k=document.body.style.transformProperty!==undefined||document.body.style.WebkitTransform!==undefined||document.body.style.MozTransform!==undefined||document.body.style.msTransform!==undefined||document.body.style.OTransform!==undefined,t=0,w=0;
|
||
|
function g(M){if(!k&&!F){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");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");
|
||
|
document.addEventListener("keydown",J,false);document.addEventListener("touchstart",u,false);window.addEventListener("hashchange",r,false);d.controlsLeft.addEventListener("click",m(v),false);
|
||
|
d.controlsRight.addEventListener("click",m(h),false);d.controlsUp.addEventListener("click",m(p),false);d.controlsDown.addEventListener("click",m(y),false);
|
||
|
o(E,M);if(F===false){E.transition="linear";}if(E.controls){d.controls.style.display="block";}if(E.progress){d.progress.style.display="block";}if(E.transition!=="default"){d.wrapper.classList.add(E.transition);
|
||
|
}if(E.theme!=="default"){d.wrapper.classList.add(E.theme);}if(E.mouseWheel){document.addEventListener("DOMMouseScroll",l,false);document.addEventListener("mousewheel",l,false);
|
||
|
}if(E.rollingLinks){B();}A();}function o(N,M){for(var O in M){N[O]=M[O];}}function m(M){return function(N){N.preventDefault();M.call();};}function J(M){if(M.target.contentEditable==="inherit"){if(M.keyCode>=33&&M.keyCode<=40){switch(M.keyCode){case 33:G();
|
||
|
break;case 34:s();break;case 37:v();break;case 39:h();break;case 38:p();break;case 40:y();break;}M.preventDefault();}else{if(M.keyCode===32&&F){if(H()){I();
|
||
|
}else{z();}M.preventDefault();}}}}function u(P){if(P.touches.length===1){if(P.target.tagName.toLowerCase()==="a"||P.target.tagName.toLowerCase()==="img"){return;
|
||
|
}P.preventDefault();var N={x:P.touches[0].clientX,y:P.touches[0].clientY};var M=window.innerWidth*0.3;var O=window.innerHeight*0.3;if(N.x<M){v();}else{if(N.x>window.innerWidth-M){h();
|
||
|
}else{if(N.y<O){p();}else{if(N.y>window.innerHeight-O){y();}}}}b();}}function l(M){clearTimeout(t);t=setTimeout(function(){var N=M.detail||-M.wheelDelta;
|
||
|
if(N>0){s();}else{G();}},100);}function r(M){A();}function B(){if(F){var N=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var O=0,M=N.length;
|
||
|
O<M;O++){var P=N[O];if(P.textContent&&!P.querySelector("img")&&(!P.className||!P.classList.contains(P,"roll"))){P.classList.add("roll");P.innerHTML='<span data-title="'+P.text+'">'+P.innerHTML+"</span>";
|
||
|
}}}}function z(){d.wrapper.classList.add("overview");var M=Array.prototype.slice.call(document.querySelectorAll(i));for(var R=0,P=M.length;R<P;R++){var O=M[R],V="translateZ(-2500px) translate("+((R-j)*105)+"%, 0%)";
|
||
|
O.setAttribute("data-index-h",R);O.style.display="block";O.style.WebkitTransform=V;O.style.MozTransform=V;O.style.msTransform=V;O.style.OTransform=V;O.style.transform=V;
|
||
|
if(!O.classList.contains("stack")){O.addEventListener("click",x,true);}var U=Array.prototype.slice.call(O.querySelectorAll("section"));for(var Q=0,N=U.length;
|
||
|
Q<N;Q++){var T=U[Q],S="translate(0%, "+((Q-c)*105)+"%)";T.setAttribute("data-index-h",R);T.setAttribute("data-index-v",Q);T.style.display="block";T.style.WebkitTransform=S;
|
||
|
T.style.MozTransform=S;T.style.msTransform=S;T.style.OTransform=S;T.style.transform=S;T.addEventListener("click",x,true);}}}function I(){d.wrapper.classList.remove("overview");
|
||
|
var P=Array.prototype.slice.call(document.querySelectorAll("#reveal .slides section"));for(var O=0,M=P.length;O<M;O++){var N=P[O];N.style.WebkitTransform="";
|
||
|
N.style.MozTransform="";N.style.msTransform="";N.style.OTransform="";N.style.transform="";N.removeEventListener("click",x);}b();}function H(){return d.wrapper.classList.contains("overview");
|
||
|
}function x(M){if(H()){M.preventDefault();I();j=this.getAttribute("data-index-h");c=this.getAttribute("data-index-v");b();}}function L(N,P){var R=Array.prototype.slice.call(document.querySelectorAll(N));
|
||
|
if(R.length){P=Math.max(Math.min(P,R.length-1),0);for(var Q=0;Q<R.length;Q++){var M=R[Q];if(H()===false){M.style.display=Math.abs(P-Q)>3?"none":"block";
|
||
|
}R[Q].classList.remove("past");R[Q].classList.remove("present");R[Q].classList.remove("future");if(Q<P){R[Q].classList.add("past");}else{if(Q>P){R[Q].classList.add("future");
|
||
|
}}if(M.querySelector("section")){R[Q].classList.add("stack");}}R[P].classList.add("present");var O=R[P].dataset.state;if(O){K=K.concat(O.split(" "));}}else{P=0;
|
||
|
}return P;}function b(){var Q=K.concat();K.length=0;j=L(i,j);c=L(a,c);stateLoop:for(var O=0,M=K.length;O<M;O++){for(var N=0;N<Q.length;N++){if(Q[N]===K[O]){Q.splice(N,1);
|
||
|
continue stateLoop;}}document.documentElement.classList.add(K[O]);var P=document.createEvent("HTMLEvents");P.initEvent(K[O],true,true);document.dispatchEvent(P);
|
||
|
}while(Q.length){document.documentElement.classList.remove(Q.pop());}if(E.progress){d.progressbar.style.width=(j/(document.querySelectorAll(i).length-1))*window.innerWidth+"px";
|
||
|
}if(H()){z();}n();clearTimeout(w);w=setTimeout(f,1500);}function n(){var M=e();[d.controlsLeft,d.controlsRight,d.controlsUp,d.controlsDown].forEach(function(N){N.classList.remove("enabled");
|
||
|
});if(M.left){d.controlsLeft.classList.add("enabled");}if(M.right){d.controlsRight.classList.add("enabled");}if(M.up){d.controlsUp.classList.add("enabled");
|
||
|
}if(M.down){d.controlsDown.classList.add("enabled");}}function e(){var M=document.querySelectorAll(i);var N=document.querySelectorAll(a);return{left:j>0,right:j<M.length-1,up:c>0,down:c<N.length-1};
|
||
|
}function A(){var M=window.location.hash.slice(2).split("/");j=parseInt(M[0])||0;c=parseInt(M[1])||0;C(j,c);}function f(){if(E.history){var M="/";if(j>0||c>0){M+=j;
|
||
|
}if(c>0){M+="/"+c;}window.location.hash=M;}}function q(){if(document.querySelector(a+".present")){var N=document.querySelectorAll(a+".present .fragment:not(.visible)");
|
||
|
if(N.length){N[0].classList.add("visible");return true;}}else{var M=document.querySelectorAll(i+".present .fragment:not(.visible)");if(M.length){M[0].classList.add("visible");
|
||
|
return true;}}return false;}function D(){if(document.querySelector(a+".present")){var N=document.querySelectorAll(a+".present .fragment.visible");if(N.length){N[N.length-1].classList.remove("visible");
|
||
|
return true;}}else{var M=document.querySelectorAll(i+".present .fragment.visible");if(M.length){M[M.length-1].classList.remove("visible");return true;}}return false;
|
||
|
}function C(N,M){j=N===undefined?j:N;c=M===undefined?c:M;b();}function v(){if(H()||D()===false){j--;c=0;b();}}function h(){if(H()||q()===false){j++;c=0;
|
||
|
b();}}function p(){if(H()||D()===false){c--;b();}}function y(){if(H()||q()===false){c++;b();}}function G(){if(D()===false){if(e().up){p();}else{var M=document.querySelector("#reveal .slides>section.past:nth-child("+j+")");
|
||
|
if(M){c=(M.querySelectorAll("section").length+1)||0;j--;b();}}}}function s(){if(q()===false){e().down?y():h();}}return{initialize:g,navigateTo:C,navigateLeft:v,navigateRight:h,navigateUp:p,navigateDown:y};
|
||
|
})();
|