new keyboard shortcuts added

This commit is contained in:
Kurt 2013-09-05 14:14:50 +02:00
parent 3b89cea776
commit 467f2dbdad
3 changed files with 96 additions and 12 deletions

102
picturelicious/media/shortcuts.js.php Normal file → Executable file
View File

@ -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;
}
}

4
picturelicious/templates/header.tpl.php Normal file → Executable file
View File

@ -31,7 +31,7 @@
</div>
<div class="menuItems">
<a href="<?php echo Config::$absolutePath; ?>upload">Upload</a>
<a href="<?php echo Config::$absolutePath; ?>upload" id="upload">Upload</a>
<a href="<?php echo Config::$absolutePath; ?>users">Users</a>
<a href="<?php echo Config::$absolutePath; ?>quicktags">Quick-Tagging</a>
<a href="<?php echo Config::$absolutePath; ?>static/bookmarklet">Bookmarklet</a>
@ -48,7 +48,7 @@
<a href="<?php echo Config::$absolutePath; ?>logout">logout</a>)
<?php } else { ?>
Hello Anonymous
(<a href="<?php echo Config::$absolutePath; ?>login">login</a> /
(<a href="<?php echo Config::$absolutePath; ?>login" id="login">login</a> /
<a href="<?php echo Config::$absolutePath; ?>register">register</a>)
<?php } ?>
<?php if( $user->admin ) { ?>

2
picturelicious/templates/view.tpl.php Normal file → Executable file
View File

@ -124,7 +124,7 @@
<?php if( $user->id ) { ?>
<form method="post" class="addComment" action="<?php echo Config::$absolutePath.$iv->basePath.'view/'.$iv->image['keyword']; ?>">
<div>
<textarea name="content" rows="3" cols="60"></textarea>
<textarea name="content" rows="3" cols="60" id="commentContent"></textarea>
<input class="submit" type="submit" name="addComment" value="Submit Comment"/>
</div>
</form>