browser history updates can now be disabled via config

edit
Hakim El Hattab 2011-12-30 22:33:19 -08:00
parent 73eb66bf71
commit 9856f57db5
2 changed files with 40 additions and 26 deletions

View File

@ -6,6 +6,9 @@
<title>reveal.js</title> <title>reveal.js</title>
<meta name="description" content="An easy to use CSS 3D slideshow tool for quickly creating good looking HTML presentations.">
<meta name="author" content="Hakim El Hattab">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/reset.css">
@ -219,6 +222,9 @@
// Display a presentation progress bar // Display a presentation progress bar
progress: true, progress: true,
// If true; each slide will be pushed to the browser history
history: false,
// Apply a 3D roll to links on hover // Apply a 3D roll to links on hover
rollingLinks: true, rollingLinks: true,
@ -226,7 +232,7 @@
theme: query.theme || 'default', // default/neon theme: query.theme || 'default', // default/neon
// Transition style // Transition style
transition: query.transition || 'default' // default/cube/page/concave/linear(2d), transition: query.transition || 'default' // default/cube/page/concave/linear(2d)
}); });
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();

View File

@ -72,6 +72,7 @@
* - Slides were moved one level deeper, into #reveal .slides * - Slides were moved one level deeper, into #reveal .slides
* - Controls and progress bar were moved into #reveal * - Controls and progress bar were moved into #reveal
* - All CSS is now much more explicit, rooted at #reveal, to prevent conflicts * - All CSS is now much more explicit, rooted at #reveal, to prevent conflicts
* - Config option for disabling updates to URL, defaults to true
* *
* *
* @author Hakim El Hattab | http://hakim.se * @author Hakim El Hattab | http://hakim.se
@ -86,13 +87,15 @@ var Reveal = (function(){
indexh = 0, indexh = 0,
indexv = 0, indexv = 0,
// Configurations options, including; // Configurations options, can be overridden at initialization time
// > {Boolean} controls config = {
// > {Boolean} progress controls: false,
// > {String} theme progress: false,
// > {String} transition history: false,
// > {Boolean} rollingLinks transition: 'default',
config = {}, theme: 'default',
rollingLinks: true
},
// Cached references to DOM elements // Cached references to DOM elements
dom = {}, dom = {},
@ -127,15 +130,8 @@ var Reveal = (function(){
dom.controlsUp.addEventListener('click', preventAndForward( navigateUp ), false); dom.controlsUp.addEventListener('click', preventAndForward( navigateUp ), false);
dom.controlsDown.addEventListener('click', preventAndForward( navigateDown ), false); dom.controlsDown.addEventListener('click', preventAndForward( navigateDown ), false);
// Fall back on default options // Copy options over to our config object
config.rollingLinks = options.rollingLinks === undefined ? true : options.rollingLinks; extend( config, options );
config.controls = options.controls === undefined ? false : options.controls;
config.progress = options.progress === undefined ? false : options.progress;
config.transition = options.transition === undefined ? 'default' : options.transition;
config.theme = options.theme === undefined ? 'default' : options.theme;
// Transition alias
if( config.transition === 'box' ) config.transition = 'cube';
// Fall back on the 2D transform theme 'linear' // Fall back on the 2D transform theme 'linear'
if( supports3DTransforms === false ) { if( supports3DTransforms === false ) {
@ -167,6 +163,16 @@ var Reveal = (function(){
readURL(); readURL();
} }
/**
* Extend object a with the properties of object b.
* If there's a conflict, object b takes precedence.
*/
function extend( a, b ) {
for( var i in b ) {
a[ i ] = b[ i ];
}
}
/** /**
* Prevents an events defaults behavior calls the * Prevents an events defaults behavior calls the
* specified delegate. * specified delegate.
@ -529,6 +535,7 @@ var Reveal = (function(){
* state. * state.
*/ */
function writeURL() { function writeURL() {
if( config.history ) {
var url = '/'; var url = '/';
// Only include the minimum possible number of components in // Only include the minimum possible number of components in
@ -538,6 +545,7 @@ var Reveal = (function(){
window.location.hash = url; window.location.hash = url;
} }
}
/** /**
* Navigate to the next slide fragment. * Navigate to the next slide fragment.