From df4e1fd346558adafc6decc96ec9366d720d6896 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sat, 10 Nov 2012 10:39:59 -0500 Subject: write named links, rather than h/v index, to hash when available (closes #224) --- js/reveal.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'js/reveal.js') diff --git a/js/reveal.js b/js/reveal.js index 564c863..2507b22 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.2 r38 + * reveal.js 2.2 r39 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -938,10 +938,15 @@ var Reveal = (function(){ if( config.history ) { var url = '/'; - // Only include the minimum possible number of components in - // the URL - if( indexh > 0 || indexv > 0 ) url += indexh; - if( indexv > 0 ) url += '/' + indexv; + // If the current slide has an ID, use that as a named link + if( currentSlide && typeof currentSlide.getAttribute( 'id' ) === 'string' ) { + url = '/' + currentSlide.getAttribute( 'id' ); + } + // Otherwise use the /h/v index + else { + if( indexh > 0 || indexv > 0 ) url += indexh; + if( indexv > 0 ) url += '/' + indexv; + } window.location.hash = url; } -- cgit v1.2.3