mirror of
https://github.com/restoreddev/phpapprentice.git
synced 2025-08-03 05:18:11 +02:00
Added ability to navigate with arrow keys
This commit is contained in:
@@ -41,18 +41,26 @@ var onLoad = function () {
|
|||||||
document.onkeydown = function (e) {
|
document.onkeydown = function (e) {
|
||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
|
|
||||||
var isEscape = false;
|
switch (e.key) {
|
||||||
if ("key" in e) {
|
case 'Esc':
|
||||||
isEscape = (e.key == "Escape" || e.key == "Esc");
|
case 'Escape':
|
||||||
} else {
|
|
||||||
isEscape = (e.keyCode == 27);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEscape) {
|
|
||||||
var modal = document.querySelector('.modal');
|
var modal = document.querySelector('.modal');
|
||||||
if (modal && !modal.classList.contains('closed')) {
|
if (modal && !modal.classList.contains('closed')) {
|
||||||
modal.classList.add('closed');
|
modal.classList.add('closed');
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 'ArrowRight':
|
||||||
|
var link = document.querySelector('#next-link');
|
||||||
|
if (link) {
|
||||||
|
window.location.href = link.href;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ArrowLeft':
|
||||||
|
var link = document.querySelector('#prev-link');
|
||||||
|
if (link) {
|
||||||
|
window.location.href = link.href;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -10,13 +10,13 @@
|
|||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
<div class="navigate-links">
|
<div class="navigate-links">
|
||||||
<?php if (!empty($previous)): ?>
|
<?php if (!empty($previous)): ?>
|
||||||
<a href="<?= page_path($previous) ?>" title="Previous">
|
<a href="<?= page_path($previous) ?>" title="Previous" id="prev-link">
|
||||||
<div class="icon"><?= icon('cheveron-outline-left') ?></div>
|
<div class="icon"><?= icon('cheveron-outline-left') ?></div>
|
||||||
Previous
|
Previous
|
||||||
</a>
|
</a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if (!empty($next)): ?>
|
<?php if (!empty($next)): ?>
|
||||||
<a href="<?= page_path($next) ?>" title="Next">
|
<a href="<?= page_path($next) ?>" title="Next" id="next-link">
|
||||||
Next
|
Next
|
||||||
<div class="icon"><?= icon('cheveron-outline-right') ?></div>
|
<div class="icon"><?= icon('cheveron-outline-right') ?></div>
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user