diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-10-05 12:00:21 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-10-05 12:00:21 +0200 |
commit | 02f95f4de6f7913943a69b4144ed1cf8d20e1537 (patch) | |
tree | 92c930e6420a0c7e270478219599179d6f22bf2f /js | |
parent | 7e99626b142b334d2563660d260ffa96ccf34fcf (diff) | |
download | fosdem-2018-presentation-02f95f4de6f7913943a69b4144ed1cf8d20e1537.tar fosdem-2018-presentation-02f95f4de6f7913943a69b4144ed1cf8d20e1537.tar.gz |
code format tweaks
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/js/reveal.js b/js/reveal.js index e78cb8f..c749bfe 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -554,21 +554,36 @@ } - function getStatusText(node) { - var text = ""; - if(node.nodeType === 3) { //text node + /** + * Converts the given HTML element into a string of text + * that can be announced to a screen reader. Hidden + * elements are excluded. + */ + function getStatusText( node ) { + + var text = ''; + + // Text node + if( node.nodeType === 3 ) { text += node.textContent; - }else if (node.nodeType === 1) { //element node - var isAriaHidden = node.getAttribute('aria-hidden'); - var isDisplayHidden = window.getComputedStyle(node)['display'] === 'none'; - if (isAriaHidden !== 'true' && !isDisplayHidden) { - var children = node.childNodes; - for (var i = 0;i < children.length; i++) { - text += getStatusText(children[i]); - } + } + // Element node + else if( node.nodeType === 1 ) { + + var isAriaHidden = node.getAttribute( 'aria-hidden' ); + var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none'; + if( isAriaHidden !== 'true' && !isDisplayHidden ) { + + toArray( node.childNodes ).forEach( function( child ) { + text += getStatusText( child ); + } ); + } + } + return text; + } /** @@ -2273,7 +2288,7 @@ } // Announce the current slide contents, for screen readers - dom.statusDiv.textContent = getStatusText(currentSlide); + dom.statusDiv.textContent = getStatusText( currentSlide ); updateControls(); updateProgress(); @@ -3686,7 +3701,7 @@ element.classList.remove( 'current-fragment' ); // Announce the fragments one by one to the Screen Reader - dom.statusDiv.textContent = getStatusText(element); + dom.statusDiv.textContent = getStatusText( element ); if( i === index ) { element.classList.add( 'current-fragment' ); |