From df4e1fd346558adafc6decc96ec9366d720d6896 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sat, 10 Nov 2012 10:39:59 -0500 Subject: [PATCH] write named links, rather than h/v index, to hash when available (closes #224) --- js/reveal.js | 15 ++++++++++----- js/reveal.min.js | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 564c863a..2507b226 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; } diff --git a/js/reveal.min.js b/js/reveal.min.js index 31676651..74627ea8 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.2 r38 + * reveal.js 2.2 r39 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -57,9 +57,9 @@ if(aw<0){aw=av+aw;}}aw=Math.max(Math.min(aw,av-1),0);for(var at=0;at0,right:n0,down:e0||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); +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(H&&typeof H.getAttribute("id")==="string"){an="/"+H.getAttribute("id"); +}else{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");