Skip to content

Commit

Permalink
Merge pull request #15 from wshito/accessibility
Browse files Browse the repository at this point in the history
added the page navigation shortcuts and the accessibility labels #14
  • Loading branch information
wshito authored Aug 3, 2021
2 parents 6caa3a7 + 3952053 commit 4956766
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Generates chunked (multi-page) HTML from Asciidoctor's single HTML file with the

## News

- 2021/8/3 [Ver 1.0.4](https://github.com/wshito/asciidoctor-chunker/releases) Added the keyboard shotcuts for the page navigation with arrow keys. Added the accessibility labels on the page navigation for screen readers.
- 2021/6/25 [Ver 1.0.3](https://github.com/wshito/asciidoctor-chunker/releases) Fixed the security vulnerabilities in the dependencies.
- 2021/5/9 [Ver 1.0.2](https://github.com/wshito/asciidoctor-chunker/releases) The toc item for the titlepage can be configured with `--titlePage` option (thanks to [@johnthad](https://github.com/johnthad)).
- 2021/3/17 [Ver 1.0.1](https://github.com/wshito/asciidoctor-chunker/releases) The script contains shebang and can be invoked directly. Published on [npm](https://www.npmjs.com/package/asciidoctor-chunker). You can install via npm. See [Installation](#installation).
Expand Down
2 changes: 1 addition & 1 deletion dist/asciidoctor-chunker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asciidoctor-chunker",
"version": "1.0.3",
"version": "1.0.4",
"description": "Creates chunked (multi-page) HTML from Asciidoctor's single HTML file with supporting the fine-tuned splits in chapters, sections and any depth of subsections.",
"author": "Wataru Shito (https://github.com/wshito)",
"bin": {
Expand Down
23 changes: 23 additions & 0 deletions src/DOM.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,15 @@ const createNav = (prev, next) => `
<nav>
${prev ?
`<a rel="prev" href="${prev}" class="nav nav-prev"
title="Previous page"
aria-label="Previous page"
aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>` : ''}
${next ?
`<a rel="next" href="${next}" class="nav nav-next"
title="Next page"
aria-label="Next page"
aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>` : ''}
Expand Down Expand Up @@ -767,6 +771,25 @@ const insertScript = (rootNode) => {
behavior: 'smooth'
});
}
/* For page navigation */
function gotoPage(selector) {
const button = document.querySelector(selector);
if (button)
window.location.href = button.href;
}
document.addEventListener('keydown', e => {
switch (e.key) {
case 'ArrowRight':
e.preventDefault();
gotoPage('.nav-next');
break;
case 'ArrowLeft':
e.preventDefault();
gotoPage('.nav-prev');
break;
}
});
</script>
`);
return rootNode;
Expand Down

0 comments on commit 4956766

Please sign in to comment.