Skip to content

Commit

Permalink
Fix navigation between confirmation inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilesoft committed Dec 21, 2024
1 parent 01f6a19 commit 46d5808
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
17 changes: 6 additions & 11 deletions web/media/keyhandler.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
function checkForEnter(event) {
switch (event.keyCode) {
// up arrow
case 40:
switch (event.originalEvent.key) {
case "ArrowUp":
$(this)
.parent()
.parent()
.next()
.prev()
.children("td")
.children("input[class=" + $(this).attr("class") + "]")
.focus()
.select();
break;

// down arrow
case 38:
case "ArrowDown":
$(this)
.parent()
.parent()
.prev()
.next()
.children("td")
.children("input[class=" + $(this).attr("class") + "]")
.focus()
.select();
break;

// Enter key
case 13:
case "Enter":
$(this)
.parent()
.parent()
Expand All @@ -35,7 +32,5 @@ function checkForEnter(event) {
.focus()
.select();
event.preventDefault();
return false;
break;
}
}
6 changes: 1 addition & 5 deletions web/templates/tupa/syota_tehtava.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
$(document).ready(function(){
$("#taulukko").stickyTableHeaders();

if ($.browser.mozilla) {
$("input").keypress(checkForEnter);
} else {
$("input").keydown(checkForEnter);
}
$("input").keydown(checkForEnter);

jQuery(function($){
$.mask.definitions['~']='[he0123456789]'; /* hylätty, ei syötetty, numeroarvot*/
Expand Down
5 changes: 5 additions & 0 deletions web/tupa/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ def syotaTehtava(request, kisa_nimi, tehtava_id, talletettu=None, tarkistus=None
else:
formi.fields["arvo"].widget.attrs["class"] += " col" + str(colnum)

if "class" not in formi.fields["tarkistus"].widget.attrs.keys():
formi.fields["tarkistus"].widget.attrs["class"] = "col" + str(colnum)
else:
formi.fields["tarkistus"].widget.attrs["class"] += " col" + str(colnum)

if formi.is_valid(): # Talletetaan syöte
formi.save()
else:
Expand Down

0 comments on commit 46d5808

Please sign in to comment.