keyboard controls
authorEugene Crosser <crosser@average.org>
Mon, 1 Sep 2008 15:10:33 +0000 (15:10 +0000)
committerEugene Crosser <crosser@average.org>
Mon, 1 Sep 2008 15:10:33 +0000 (15:10 +0000)
include/gallery.js
include/show.js

index 1bc4ece8dc3ff309835b5eebe59a1286b41945be..a870a03eb3d138aa4693df1c8a00beb305061d63 100644 (file)
@@ -91,6 +91,20 @@ function init_gallery() {
        };
        var show = new Show(vimgs,showwin,ctl,showparms);
 
+       document.addEvent('keypress', function(ev){
+               if (ev.key == 'esc') {
+                       show.exit();
+               } else if (ev.key == 'left') {
+                       show.prev();
+               } else if (ev.key == 'right') {
+                       show.next();
+               } else if (ev.key == 'space') {
+                       show.toggleplay();
+               } else {
+                       /* alert('keypress: '+ev.key); */
+               }
+       });
+
        /* Update HTML */
 
        $$('.conceal').each(function(el){
index 52452329e72abf6892c54603a2bdc5943615ee45..1a40c569c7ad911bbb4d159e6de28fe7e8f8cd8a 100644 (file)
@@ -96,7 +96,7 @@ var Show = new Class({
                if (this.currentid > 0) {
                        this.show(this.currentid-1);
                } else {
-                       alert('show.prev called beyond first element');
+                       /* alert('show.prev called beyond first element'); */
                }
        },
 
@@ -113,11 +113,16 @@ var Show = new Class({
                this.controls.running(1);
        },
 
+       toggleplay: function(){
+               if (this.isplaying) { this.stop(); }
+               else { this.play(); }
+       },
+
        next: function(){
                if (this.currentid < this.vimgs.length-1) {
                        this.show(this.currentid+1);
                } else {
-                       alert('show.next called beyond last element');
+                       /* alert('show.next called beyond last element'); */
                }
        },