Skip to content

Commit 4956766

Browse files
authored
Merge pull request #15 from wshito/accessibility
added the page navigation shortcuts and the accessibility labels #14
2 parents 6caa3a7 + 3952053 commit 4956766

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Generates chunked (multi-page) HTML from Asciidoctor's single HTML file with the
88

99
## News
1010

11+
- 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.
1112
- 2021/6/25 [Ver 1.0.3](https://github.com/wshito/asciidoctor-chunker/releases) Fixed the security vulnerabilities in the dependencies.
1213
- 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)).
1314
- 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).

dist/asciidoctor-chunker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asciidoctor-chunker",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"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.",
55
"author": "Wataru Shito (https://github.com/wshito)",
66
"bin": {

src/DOM.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,15 @@ const createNav = (prev, next) => `
650650
<nav>
651651
${prev ?
652652
`<a rel="prev" href="${prev}" class="nav nav-prev"
653+
title="Previous page"
654+
aria-label="Previous page"
653655
aria-keyshortcuts="Left">
654656
<i class="fa fa-angle-left"></i>
655657
</a>` : ''}
656658
${next ?
657659
`<a rel="next" href="${next}" class="nav nav-next"
660+
title="Next page"
661+
aria-label="Next page"
658662
aria-keyshortcuts="Right">
659663
<i class="fa fa-angle-right"></i>
660664
</a>` : ''}
@@ -767,6 +771,25 @@ const insertScript = (rootNode) => {
767771
behavior: 'smooth'
768772
});
769773
}
774+
775+
/* For page navigation */
776+
function gotoPage(selector) {
777+
const button = document.querySelector(selector);
778+
if (button)
779+
window.location.href = button.href;
780+
}
781+
document.addEventListener('keydown', e => {
782+
switch (e.key) {
783+
case 'ArrowRight':
784+
e.preventDefault();
785+
gotoPage('.nav-next');
786+
break;
787+
case 'ArrowLeft':
788+
e.preventDefault();
789+
gotoPage('.nav-prev');
790+
break;
791+
}
792+
});
770793
</script>
771794
`);
772795
return rootNode;

0 commit comments

Comments
 (0)