Permalink
Browse files

only handle return events when fields are visible

  • Loading branch information...
1 parent aadca25 commit 51402d40294a3ad7166dac4ccfd0ef901ebf6a40 @despo committed Jun 30, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 views/gorillas.coffee
View
@@ -494,6 +494,9 @@ window.clear_fields = (player) ->
$('#'+player+'_angle').val('')
$('#'+player+'_velocity').val('')
+window.is_field_visible = (player, field) ->
+ $('#'+player+'_'+field).is(":visible")
+
jQuery = $
$(document).ready ->
@@ -506,10 +509,13 @@ $(document).ready ->
window.show_player_field 'player_1', 'velocity'
$('#player_1_velocity').bind "keydown", (event) ->
- if event.keyCode == 13
+ if event.keyCode == 13 && window.is_field_visible 'player_1', 'angle'
+
+ console.log "----------"
window.hide_player_field 'player_1', 'angle'
window.hide_player_field 'player_1', 'velocity'
+
parameters = window.read_angle_and_velocity('player_1')
parameters.velocity = 0 unless parameters.velocity > 0
parameters.angle = 0 unless parameters.angle > 0
@@ -522,7 +528,7 @@ $(document).ready ->
window.show_player_field 'player_2', 'velocity'
$('#player_2_velocity').bind "keydown", (event) ->
- if event.keyCode == 13
+ if event.keyCode == 13 and window.is_field_visible 'player_2', 'angle'
window.hide_player_field 'player_2', 'angle'
window.hide_player_field 'player_2', 'velocity'

0 comments on commit 51402d4

Please sign in to comment.