write named links, rather than h/v index, to hash when available (closes #224)
authorHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 10 Nov 2012 15:39:59 +0000 (10:39 -0500)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 10 Nov 2012 15:39:59 +0000 (10:39 -0500)
js/reveal.js
js/reveal.min.js

index 564c863af23e06686c8537d6bba7f3a812a7d58c..2507b226ad7ed325839d3b8a8cd0363ba43ad0ae 100644 (file)
@@ -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;
                }
index 3167665153a282d219fc67d52e4f2e07baf90750..74627ea8f106f91e90ffd7b07538e5a9c7734417 100644 (file)
@@ -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;at<av;at++){va
 }if(an.right){f.controlsRight.classList.add("enabled");}if(an.up){f.controlsUp.classList.add("enabled");}if(an.down){f.controlsDown.classList.add("enabled");
 }}}function h(){var an=document.querySelectorAll(m),ao=document.querySelectorAll(b);return{left:n>0,right:n<an.length-1,up:e>0,down:e<ao.length-1};}function K(){var at=window.location.hash;
 var ar=at.slice(2).split("/"),ao=at.replace(/#|\//gi,"");if(isNaN(parseInt(ar[0],10))&&ao.length){var ap=document.querySelector("#"+ao);if(ap){var au=Reveal.getIndices(ap);
-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(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);
+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");