mirror of
https://github.com/clagnut/webtypography.git
synced 2025-09-02 17:42:46 +02:00
Merge pull request #20 from codegaze/navfeature
Guideline navigation with arrow keys
This commit is contained in:
5
item.php
5
item.php
@@ -58,10 +58,10 @@ if (isset($keys[array_search($item_num, $keys)-1])) {
|
||||
<ul id="nextprev">
|
||||
<?php
|
||||
if ($next_num) {
|
||||
echo "<li><span>→</span><a href='/$next_num' title='Read next guideline'>$next_item</a></li>";
|
||||
echo "<li><span>→</span><a href='/$next_num' title='Read next guideline' id='next_guideline'>$next_item</a></li>";
|
||||
}
|
||||
if ($prev_num) {
|
||||
echo "<li><span>←</span><a href='/$prev_num' title='Read previous guideline'>$prev_item</a></li>";
|
||||
echo "<li><span>←</span><a href='/$prev_num' title='Read previous guideline' id='previous_guideline'>$prev_item</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
@@ -74,5 +74,6 @@ include($dr . "book.inc.php");
|
||||
|
||||
|
||||
<?php include($dr . "footer.inc.php") ?>
|
||||
<script src="/js/global.js"></script>
|
||||
</body>
|
||||
</html>
|
19
js/global.js
19
js/global.js
@@ -1 +1,18 @@
|
||||
/* No JS required any more */
|
||||
/* No JS required any more */
|
||||
|
||||
document.onkeydown = function (e) {
|
||||
switch (e.keyCode) {
|
||||
case 37:
|
||||
if (document.getElementById('previous_guideline') !== null)
|
||||
window.location = document.getElementById('previous_guideline').href;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
if (document.getElementById('next_guideline') !== null)
|
||||
window.location = document.getElementById('next_guideline').href;
|
||||
break;
|
||||
|
||||
default:
|
||||
return; // Do nothing for the rest
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user