diff --git a/web/media/keyhandler.js b/web/media/keyhandler.js index 0ca27d3..d8b5676 100644 --- a/web/media/keyhandler.js +++ b/web/media/keyhandler.js @@ -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() @@ -35,7 +32,5 @@ function checkForEnter(event) { .focus() .select(); event.preventDefault(); - return false; - break; } } diff --git a/web/templates/tupa/syota_tehtava.html b/web/templates/tupa/syota_tehtava.html index 2d28175..283f353 100755 --- a/web/templates/tupa/syota_tehtava.html +++ b/web/templates/tupa/syota_tehtava.html @@ -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*/ diff --git a/web/tupa/views.py b/web/tupa/views.py index 397b41a..cb0f346 100644 --- a/web/tupa/views.py +++ b/web/tupa/views.py @@ -534,6 +534,15 @@ 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: