diff --git a/picturelicious/media/shortcuts.js.php b/picturelicious/media/shortcuts.js.php old mode 100644 new mode 100755 index f4377f1..7eab7ff --- a/picturelicious/media/shortcuts.js.php +++ b/picturelicious/media/shortcuts.js.php @@ -3,15 +3,99 @@ header( 'Content-type: text/javascript; charset=utf-8' ); ?> document.onkeydown=function(e){ - var keyCode = e.keyCode || e.which; - var arrow = {left: 37, up: 38, right: 39, down: 40 }; + var pressedKey = e.keyCode || e.which; + var keyCodes = { left: 37, // navigate forward + up: 38, // + right: 39, // navigate back + down: 40, // + one: 49, // vote 1* // TODO + two: 50, // vote 2* // TODO + three: 51, // vote 3* // TODO + four: 52, // vote 4* // TODO + five: 53, // vote 5* // TODO + num1: 97, // vote 1* // TODO + num2: 98, // vote 2* // TODO + num3: 99, // vote 3* // TODO + num4: 100, // vote 4* // TODO + num5: 101, // vote 5* // TODO + plus: 107, // toggle image display size + minus: 109, // toggle image display size + c: 67, // focus cursor into comments field + f: 70, // toggle image display size + h: 72, // navigate to main page + l: 76, // login + r: 82, // load random image // TODO + s: 83, // focus cursor into search field + u: 85 // navigate to upload form + }; - switch(keyCode){ - case arrow.left: - document.getElementById('prevBar').click(); - break; - case arrow.right: - document.getElementById('nextBar').click(); - break; + var focusedElement = document.activeElement; + console.log("focused: " + focusedElement.id); + + if( focusedElement.id != "commentContent" && focusedElement.id != "q" ) + { + switch(pressedKey){ + case keyCodes.left: + document.getElementById('prevBar').click(); + return false; + break; + case keyCodes.right: + document.getElementById('nextBar').click(); + return false; + break; + case keyCodes.one: + case keyCodes.num1: + return false; + break; + case keyCodes.two: + case keyCodes.num2: + return false; + break; + case keyCodes.three: + case keyCodes.num3: + return false; + break; + case keyCodes.four: + case keyCodes.num4: + return false; + break; + case keyCodes.five: + case keyCodes.num5: + return false; + break; + case keyCodes.plus: + case keyCodes.minus: + case keyCodes.f: + swap(document.getElementById('image'), 'scaled', 'full') + return false; + break; + case keyCodes.c: + document.getElementById('commentContent').focus(); + return false; + break; + case keyCodes.h: + document.getElementById('logo').click(); + return false; + break; + case keyCodes.l: + document.getElementById('login').click(); + return false; + break; + case keyCodes.r: + // TODO + break; + case keyCodes.s: + document.getElementById('q').focus(); + return false; + break; + case keyCodes.u: + document.getElementById('upload').click(); + return false; + break; + } + } + else + { + return true; } } diff --git a/picturelicious/templates/header.tpl.php b/picturelicious/templates/header.tpl.php old mode 100644 new mode 100755 index 1920dd4..03bd204 --- a/picturelicious/templates/header.tpl.php +++ b/picturelicious/templates/header.tpl.php @@ -31,7 +31,7 @@