diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index 095ade9..9ff55d1 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -177,19 +177,6 @@ $(document).ready( function () { edit: function( $sortable2, $entry ) { edit_ob_ordnance( $entry, 2 ) ; }, } ) ; - // handle ENTER and double-clicks in the "select vehicle/ordnance" dialog - function auto_select_vo( evt ) { - if ( $("#select-vo select").val() ) { - $(".ui-dialog.select-vo button:contains('OK')").click() ; - evt.preventDefault() ; - } - } - $("#select-vo").keydown( function(evt) { - if ( evt.keyCode == 13 ) - auto_select_vo( evt ) ; - } ) ; - $("#select-vo").dblclick( function(evt) { auto_select_vo(evt) ; } ) ; - // initialize the player droplists function on_player_droplist_open( $sel ) { // remember the current selection diff --git a/vasl_templates/webapp/static/roar.js b/vasl_templates/webapp/static/roar.js index 70f0e55..5dd171b 100644 --- a/vasl_templates/webapp/static/roar.js +++ b/vasl_templates/webapp/static/roar.js @@ -101,14 +101,14 @@ function do_search_roar( on_ok ) create: function() { // initialize the dialog init_dialog( $(this), "OK", false ) ; - // handle ENTER and double-click + // handle ENTER, ESCAPE and double-click function auto_select_scenario( evt ) { if ( $sel.val() ) { $( ".ui-dialog.select-roar-scenario button:contains('OK')" ).click() ; evt.preventDefault() ; } } - $("#select-roar-scenario").keydown( function(evt) { + $(this).keydown( function(evt) { if ( evt.keyCode == $.ui.keyCode.ENTER ) auto_select_scenario( evt ) ; else if ( evt.keyCode == $.ui.keyCode.ESCAPE ) diff --git a/vasl_templates/webapp/static/utils.js b/vasl_templates/webapp/static/utils.js index 111ced8..3d32a64 100644 --- a/vasl_templates/webapp/static/utils.js +++ b/vasl_templates/webapp/static/utils.js @@ -191,7 +191,7 @@ function on_dialog_open( $dlg ) function auto_dismiss_dialog( $dlg, evt, btn_text ) { // check if the user pressed Ctrl-Enter - if ( evt.keyCode == 13 && evt.ctrlKey ) { + if ( evt.keyCode == $.ui.keyCode.ENTER && evt.ctrlKey ) { // yup - locate the target button and click it click_dialog_button( $dlg, btn_text ) ; evt.preventDefault() ; diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js index ed6cbcb..b50e0d1 100644 --- a/vasl_templates/webapp/static/vo.js +++ b/vasl_templates/webapp/static/vo.js @@ -71,10 +71,20 @@ function add_vo( vo_type, player_no ) minHeight: 350, create: function() { init_dialog( $(this), "OK", false ) ; - // handle ESCAPE + // handle ENTER, ESCAPE and double-click + function auto_select_vo( evt ) { + if ( $( "#select-vo select" ).val() ) { + $( ".ui-dialog.select-vo button:contains('OK')" ).click() ; + evt.preventDefault() ; + } + } $(this).keydown( function(evt) { - if ( evt.keyCode == $.ui.keyCode.ESCAPE ) + if ( evt.keyCode == $.ui.keyCode.ENTER ) + auto_select_vo( evt ) ; + else if ( evt.keyCode == $.ui.keyCode.ESCAPE ) $(this).dialog( "close" ) ; + } ).dblclick( function(evt) { + auto_select_vo( evt ) ; } ) ; }, open: function() {