Permalink
Browse files

Include comic-navigation keys in the default template

  • Loading branch information...
1 parent 528d205 commit a7c1a57eeddc9698fce4d0f5fd08af6db73c95b2 @kemayo committed Apr 14, 2016
Showing with 30 additions and 2 deletions.
  1. +2 −0 index.php
  2. +2 −2 template/default/comicnav.php
  3. +26 −0 template/default/nav.js
View
@@ -39,6 +39,8 @@
$page->title = config('title');
// $page->add_css("template/{config('template')}/style.css");
$page->add_css(template_path('style.css'));
+// $page->add_js('https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js');
+$page->add_js(template_path('nav.js'));
$page->set_start_time($start_time);
switch($request[0]) {
@@ -24,13 +24,13 @@
}
if($prev) {
- echo '<li><a href="', url('comic/'.$prev), '">Prev</a></li>';
+ echo '<li><a href="', url('comic/'.$prev), '" rel="prev">Prev</a></li>';
} else {
echo '<li>Prev</li>';
}
if($next) {
- echo '<li><a href="', url('comic/'.$next), '">Next</a></li>';
+ echo '<li><a href="', url('comic/'.$next), '" rel="next">Next</a></li>';
} else {
echo '<li>Next</li>';
}
@@ -0,0 +1,26 @@
+(function() {
+ var link;
+
+ if (!(document.body.addEventListener && document.querySelector)) {
+ return;
+ }
+ document.body.addEventListener('keydown', function(e) {
+ switch (e.which) {
+ case 37: // left
+ e.preventDefault();
+ link = document.querySelector('.comic .nav [rel="prev"]');
+ if (link) {
+ link.click();
+ }
+ break;
+ case 39: // right
+ e.preventDefault();
+ link = document.querySelector('.comic .nav [rel="next"]');
+ if (link) {
+ link.click();
+ }
+ break;
+ }
+ });
+
+})();

0 comments on commit a7c1a57

Please sign in to comment.