add option for disabling overview mode (closes #145)

This commit is contained in:
Hakim El Hattab 2012-09-21 08:58:21 -04:00
parent 6779f4aecb
commit c904cef864
4 changed files with 107 additions and 53 deletions

View File

@ -70,6 +70,9 @@ Reveal.initialize({
// Enable keyboard shortcuts for navigation // Enable keyboard shortcuts for navigation
keyboard: true, keyboard: true,
// Enable the slide overview mode
overview: true,
// Loop the presentation // Loop the presentation
loop: false, loop: false,

View File

@ -333,5 +333,43 @@ function linkify( selector ) {
</script> </script>
<!-- Everything below this point is unrelated to the slideshow -->
<div class="share-reveal" style="position: absolute; bottom: 10px; left: 50%; margin-left: -160px">
<a href="http://twitter.com/share" class="twitter-share-button" data-text="reveal.js - an HTML presentation framework from @hakimel." data-url="http://lab.hakim.se/reveal-js" data-count="small" data-related="hakimel"></a>
<iframe id="facebook-button" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fapp.hakim.se%2Freveal-js%2F&layout=button_count&show_faces=false&width=93&action=like&font=arial&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:24px; position: relative; top: 4px;" allowTransparency="true"></iframe>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
(function() {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
t.parentNode.insertBefore(s, t);
})();
/* ]]> */
</script>
<a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="http://lab.hakim.se/reveal-js"></a>
<noscript><a href="http://flattr.com/thing/447435/Reveal-js" target="_blank">
<img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a></noscript>
</div>
<a class="fork-reveal" href="https://github.com/hakimel/reveal.js"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub"></a>
<script>
var _gaq = [['_setAccount', 'UA-15240703-1'], ['_trackPageview']];
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.async = true;
g.src = ('https:' == location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
s.parentNode.insertBefore(g, s);
})(document, 'script');
</script>
</body> </body>
</html> </html>

View File

@ -26,6 +26,9 @@ var Reveal = (function(){
// Enable keyboard shortcuts for navigation // Enable keyboard shortcuts for navigation
keyboard: true, keyboard: true,
// Enable the slide overview mode
overview: true,
// Loop the presentation // Loop the presentation
loop: false, loop: false,
@ -531,48 +534,53 @@ var Reveal = (function(){
* can't be improved. * can't be improved.
*/ */
function activateOverview() { function activateOverview() {
if( config.overview ) {
dom.wrapper.classList.add( 'overview' ); dom.wrapper.classList.add( 'overview' );
var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) { for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
var hslide = horizontalSlides[i], var hslide = horizontalSlides[i],
htransform = 'translateZ(-2500px) translate(' + ( ( i - indexh ) * 105 ) + '%, 0%)'; htransform = 'translateZ(-2500px) translate(' + ( ( i - indexh ) * 105 ) + '%, 0%)';
hslide.setAttribute( 'data-index-h', i );
hslide.style.display = 'block';
hslide.style.WebkitTransform = htransform;
hslide.style.MozTransform = htransform;
hslide.style.msTransform = htransform;
hslide.style.OTransform = htransform;
hslide.style.transform = htransform;
hslide.setAttribute( 'data-index-h', i ); if( !hslide.classList.contains( 'stack' ) ) {
hslide.style.display = 'block'; // Navigate to this slide on click
hslide.style.WebkitTransform = htransform; hslide.addEventListener( 'click', onOverviewSlideClicked, true );
hslide.style.MozTransform = htransform; }
hslide.style.msTransform = htransform;
hslide.style.OTransform = htransform;
hslide.style.transform = htransform;
if( !hslide.classList.contains( 'stack' ) ) { var verticalSlides = Array.prototype.slice.call( hslide.querySelectorAll( 'section' ) );
// Navigate to this slide on click
hslide.addEventListener( 'click', onOverviewSlideClicked, true ); for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
var vslide = verticalSlides[j],
vtransform = 'translate(0%, ' + ( ( j - ( i === indexh ? indexv : 0 ) ) * 105 ) + '%)';
vslide.setAttribute( 'data-index-h', i );
vslide.setAttribute( 'data-index-v', j );
vslide.style.display = 'block';
vslide.style.WebkitTransform = vtransform;
vslide.style.MozTransform = vtransform;
vslide.style.msTransform = vtransform;
vslide.style.OTransform = vtransform;
vslide.style.transform = vtransform;
// Navigate to this slide on click
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
}
} }
var verticalSlides = Array.prototype.slice.call( hslide.querySelectorAll( 'section' ) );
for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
var vslide = verticalSlides[j],
vtransform = 'translate(0%, ' + ( ( j - ( i === indexh ? indexv : 0 ) ) * 105 ) + '%)';
vslide.setAttribute( 'data-index-h', i );
vslide.setAttribute( 'data-index-v', j );
vslide.style.display = 'block';
vslide.style.WebkitTransform = vtransform;
vslide.style.MozTransform = vtransform;
vslide.style.msTransform = vtransform;
vslide.style.OTransform = vtransform;
vslide.style.transform = vtransform;
// Navigate to this slide on click
vslide.addEventListener( 'click', onOverviewSlideClicked, true );
}
} }
} }
/** /**
@ -580,24 +588,29 @@ var Reveal = (function(){
* active slide. * active slide.
*/ */
function deactivateOverview() { function deactivateOverview() {
dom.wrapper.classList.remove( 'overview' );
if( config.overview ) {
var slides = Array.prototype.slice.call( document.querySelectorAll( '.reveal .slides section' ) ); dom.wrapper.classList.remove( 'overview' );
for( var i = 0, len = slides.length; i < len; i++ ) { var slides = Array.prototype.slice.call( document.querySelectorAll( '.reveal .slides section' ) );
var element = slides[i];
// Resets all transforms to use the external styles for( var i = 0, len = slides.length; i < len; i++ ) {
element.style.WebkitTransform = ''; var element = slides[i];
element.style.MozTransform = '';
element.style.msTransform = '';
element.style.OTransform = '';
element.style.transform = '';
element.removeEventListener( 'click', onOverviewSlideClicked ); // Resets all transforms to use the external styles
element.style.WebkitTransform = '';
element.style.MozTransform = '';
element.style.msTransform = '';
element.style.OTransform = '';
element.style.transform = '';
element.removeEventListener( 'click', onOverviewSlideClicked );
}
slide();
} }
slide();
} }
/** /**

12
js/reveal.min.js vendored
View File

@ -5,7 +5,7 @@
* *
* Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
*/ */
var Reveal=(function(){var j=".reveal .slides>section",b=".reveal .slides>section.present>section",M={controls:true,progress:true,history:false,keyboard:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:"default",transition:"default",dependencies:[]},k=0,c=0,v,D,ab=[],d={},O="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,w=0,i=0,A=0,V={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:40}; var Reveal=(function(){var j=".reveal .slides>section",b=".reveal .slides>section.present>section",M={controls:true,progress:true,history:false,keyboard:true,overview:true,loop:false,autoSlide:0,mouseWheel:true,rollingLinks:true,theme:"default",transition:"default",dependencies:[]},k=0,c=0,v,D,ab=[],d={},O="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,w=0,i=0,A=0,V={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:40};
function g(ac){if((!l&&!O)){document.body.setAttribute("class","no-transforms");return;}q(M,ac);d.theme=document.querySelector("#theme");d.wrapper=document.querySelector(".reveal"); function g(ac){if((!l&&!O)){document.body.setAttribute("class","no-transforms");return;}q(M,ac);d.theme=document.querySelector("#theme");d.wrapper=document.querySelector(".reveal");
d.progress=document.querySelector(".reveal .progress");d.progressbar=document.querySelector(".reveal .progress span");if(M.controls){d.controls=document.querySelector(".reveal .controls"); d.progress=document.querySelector(".reveal .progress");d.progressbar=document.querySelector(".reveal .progress span");if(M.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.controlsLeft=document.querySelector(".reveal .controls .left");d.controlsRight=document.querySelector(".reveal .controls .right");d.controlsUp=document.querySelector(".reveal .controls .up");
@ -34,15 +34,15 @@ if(ad>V.threshold&&Math.abs(ad)>Math.abs(ac)){V.handled=true;y();}else{if(ad<-V.
r();}else{if(ac<-V.threshold){V.handled=true;C();}}}}}}ah.preventDefault();}}function R(ac){V.handled=false;}function m(ac){clearTimeout(w);w=setTimeout(function(){var ad=ac.detail||-ac.wheelDelta; r();}else{if(ac<-V.threshold){V.handled=true;C();}}}}}}ah.preventDefault();}}function R(ac){V.handled=false;}function m(ac){clearTimeout(w);w=setTimeout(function(){var ad=ac.detail||-ac.wheelDelta;
if(ad>0){u();}else{T();}},100);}function t(ac){G();}function I(){if(O&&!("msPerspective" in document.body.style)){var ad=document.querySelectorAll(".reveal .slides section a:not(.image)"); if(ad>0){u();}else{T();}},100);}function t(ac){G();}function I(){if(O&&!("msPerspective" in document.body.style)){var ad=document.querySelectorAll(".reveal .slides section a:not(.image)");
for(var ae=0,ac=ad.length;ae<ac;ae++){var af=ad[ae];if(af.textContent&&!af.querySelector("img")&&(!af.className||!af.classList.contains(af,"roll"))){af.classList.add("roll"); for(var ae=0,ac=ad.length;ae<ac;ae++){var af=ad[ae];if(af.textContent&&!af.querySelector("img")&&(!af.className||!af.classList.contains(af,"roll"))){af.classList.add("roll");
af.innerHTML='<span data-title="'+af.text+'">'+af.innerHTML+"</span>";}}}}function F(){d.wrapper.classList.add("overview");var ac=Array.prototype.slice.call(document.querySelectorAll(j)); af.innerHTML='<span data-title="'+af.text+'">'+af.innerHTML+"</span>";}}}}function F(){if(M.overview){d.wrapper.classList.add("overview");var ac=Array.prototype.slice.call(document.querySelectorAll(j));
for(var ah=0,af=ac.length;ah<af;ah++){var ae=ac[ah],al="translateZ(-2500px) translate("+((ah-k)*105)+"%, 0%)";ae.setAttribute("data-index-h",ah);ae.style.display="block"; for(var ah=0,af=ac.length;ah<af;ah++){var ae=ac[ah],al="translateZ(-2500px) translate("+((ah-k)*105)+"%, 0%)";ae.setAttribute("data-index-h",ah);ae.style.display="block";
ae.style.WebkitTransform=al;ae.style.MozTransform=al;ae.style.msTransform=al;ae.style.OTransform=al;ae.style.transform=al;if(!ae.classList.contains("stack")){ae.addEventListener("click",z,true); ae.style.WebkitTransform=al;ae.style.MozTransform=al;ae.style.msTransform=al;ae.style.OTransform=al;ae.style.transform=al;if(!ae.classList.contains("stack")){ae.addEventListener("click",z,true);
}var ak=Array.prototype.slice.call(ae.querySelectorAll("section"));for(var ag=0,ad=ak.length;ag<ad;ag++){var aj=ak[ag],ai="translate(0%, "+((ag-(ah===k?c:0))*105)+"%)"; }var ak=Array.prototype.slice.call(ae.querySelectorAll("section"));for(var ag=0,ad=ak.length;ag<ad;ag++){var aj=ak[ag],ai="translate(0%, "+((ag-(ah===k?c:0))*105)+"%)";
aj.setAttribute("data-index-h",ah);aj.setAttribute("data-index-v",ag);aj.style.display="block";aj.style.WebkitTransform=ai;aj.style.MozTransform=ai;aj.style.msTransform=ai; aj.setAttribute("data-index-h",ah);aj.setAttribute("data-index-v",ag);aj.style.display="block";aj.style.WebkitTransform=ai;aj.style.MozTransform=ai;aj.style.msTransform=ai;
aj.style.OTransform=ai;aj.style.transform=ai;aj.addEventListener("click",z,true);}}}function X(){d.wrapper.classList.remove("overview");var af=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section")); aj.style.OTransform=ai;aj.style.transform=ai;aj.addEventListener("click",z,true);}}}}function X(){if(M.overview){d.wrapper.classList.remove("overview");
for(var ae=0,ac=af.length;ae<ac;ae++){var ad=af[ae];ad.style.WebkitTransform="";ad.style.MozTransform="";ad.style.msTransform="";ad.style.OTransform=""; var af=Array.prototype.slice.call(document.querySelectorAll(".reveal .slides section"));for(var ae=0,ac=af.length;ae<ac;ae++){var ad=af[ae];ad.style.WebkitTransform="";
ad.style.transform="";ad.removeEventListener("click",z);}a();}function U(){return d.wrapper.classList.contains("overview");}function z(ac){if(U()){ac.preventDefault(); ad.style.MozTransform="";ad.style.msTransform="";ad.style.OTransform="";ad.style.transform="";ad.removeEventListener("click",z);}a();}}function U(){return d.wrapper.classList.contains("overview");
X();k=this.getAttribute("data-index-h");c=this.getAttribute("data-index-v");a();}}function aa(ad,af){var ah=Array.prototype.slice.call(document.querySelectorAll(ad)),ai=ah.length; }function z(ac){if(U()){ac.preventDefault();X();k=this.getAttribute("data-index-h");c=this.getAttribute("data-index-v");a();}}function aa(ad,af){var ah=Array.prototype.slice.call(document.querySelectorAll(ad)),ai=ah.length;
if(ai){if(M.loop){af%=ai;if(af<0){af=ai+af;}}af=Math.max(Math.min(af,ai-1),0);for(var ag=0;ag<ai;ag++){var ac=ah[ag];if(U()===false){var aj=Math.abs((af-ag)%(ai-3))||0; if(ai){if(M.loop){af%=ai;if(af<0){af=ai+af;}}af=Math.max(Math.min(af,ai-1),0);for(var ag=0;ag<ai;ag++){var ac=ah[ag];if(U()===false){var aj=Math.abs((af-ag)%(ai-3))||0;
ac.style.display=aj>3?"none":"block";}ah[ag].classList.remove("past");ah[ag].classList.remove("present");ah[ag].classList.remove("future");if(ag<af){ah[ag].classList.add("past"); ac.style.display=aj>3?"none":"block";}ah[ag].classList.remove("past");ah[ag].classList.remove("present");ah[ag].classList.remove("future");if(ag<af){ah[ag].classList.add("past");
}else{if(ag>af){ah[ag].classList.add("future");}}if(ac.querySelector("section")){ah[ag].classList.add("stack");}}ah[af].classList.add("present");var ae=ah[af].getAttribute("data-state"); }else{if(ag>af){ah[ag].classList.add("future");}}if(ac.querySelector("section")){ah[ag].classList.add("stack");}}ah[af].classList.add("present");var ae=ah[af].getAttribute("data-state");