Permalink
Browse files

Added support for control via mouse

  • Loading branch information...
rtuin committed Sep 19, 2011
1 parent 71e4956 commit 3825f245d181e306422c9960858b5a6c549a2edd
Showing with 43 additions and 21 deletions.
  1. +43 −21 js/webpresent.js
@@ -3,6 +3,7 @@
// webpresent.js may be freely distributed, altered, used and abused under the who-needs-a license
(function($) {
$(document).ready(function() {
$(this).bind('contextmenu', function() { return false; });
$('section:first-child').addClass('current');
var zIndex = 500;
$('section:not(.current)').each(function() {
@@ -15,31 +16,52 @@
switch (event.keyCode) {
case 39: // next
case 34: // next
var current = $('section.current');
var items = current.find('.item.hidden');
if (items.length) {
items.first().removeClass('hidden');
break;
}

if (!current.next('section').length) return;
current.next('section').removeClass('next').addClass('current');
current.addClass('previous').removeClass('current');
next();
break;
case 37: // previous
case 33: // previous
var current = $('section.current');

var items = current.find('.item:not(.hidden)');
if (items.length) {
items.last().addClass('hidden');
break;
}

if (!current.prev('section').length) return;
current.prev('section').removeClass('previous').addClass('current');
current.addClass('next').removeClass('current');
previous();
break;
}
});
$(document).mousedown(function(event) {
switch(event.which) {
case 1:
next();
break;
case 3:
{
console.log('??');
previous();
break;
}
}
});

function next() {
var current = $('section.current');
var items = current.find('.item.hidden');
if (items.length) {
items.first().removeClass('hidden');
return;
}

if (!current.next('section').length) return;
current.next('section').removeClass('next').addClass('current');
current.addClass('previous').removeClass('current');
}

function previous() {
var current = $('section.current');

var items = current.find('.item:not(.hidden)');
if (items.length) {
items.last().addClass('hidden');
return;
}

if (!current.prev('section').length) return;
current.prev('section').removeClass('previous').addClass('current');
current.addClass('next').removeClass('current');
}
})(jQuery);

0 comments on commit 3825f24

Please sign in to comment.