mirror of
https://github.com/clagnut/webtypography.git
synced 2025-09-03 01:52:48 +02:00
Added key navigation functionality
This commit is contained in:
4
item.php
4
item.php
@@ -58,10 +58,10 @@ if (isset($keys[array_search($item_num, $keys)-1])) {
|
|||||||
<ul id="nextprev">
|
<ul id="nextprev">
|
||||||
<?php
|
<?php
|
||||||
if ($next_num) {
|
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) {
|
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>
|
</ul>
|
||||||
|
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