Tightened up the "ask" dialog.

master
Pacman Ghost 4 years ago
parent 68faee1fab
commit d0f1ff7cc6
  1. 6
      vasl_templates/webapp/static/main.js
  2. 13
      vasl_templates/webapp/static/scenario-upload.js
  3. 4
      vasl_templates/webapp/static/simple_notes.js
  4. 8
      vasl_templates/webapp/static/snippets.js
  5. 3
      vasl_templates/webapp/static/sortable.js
  6. 44
      vasl_templates/webapp/static/utils.js
  7. 2
      vasl_templates/webapp/static/vassal.js
  8. 3
      vasl_templates/webapp/static/vo.js

@ -689,11 +689,9 @@ function on_player_change_with_confirm( player_no )
} else {
// yup - make it so
ask( "Change player nationality",
"<p>Do you want to change this player's nationality?<p>You will lose changes made to their OB.", {
"<p> Do you want to change this player's nationality? <p> You will lose changes made to their OB.", {
ok: function() { on_player_change( player_no ) ; },
cancel: function() {
$select.val( $select.data("prev-val") ).trigger( "change" ) ;
},
cancel: function() { $select.val( $select.data("prev-val") ).trigger( "change" ) ; },
} ) ;
}
}

@ -44,8 +44,10 @@ window.uploadScenario = function() {
if ( vsavDataDecoded.length <= 1024*maxBytes )
doSelectVsavData( fname, vsavData ) ;
else {
ask( "VASL scenario", "VASL scenario files should be less than " + maxBytes + " KB.", {
ask( "ASL Scenario Archive upload",
"VASL scenario files should be less than " + maxBytes + " KB.", {
ok: function() { doSelectVsavData( fname, vsavData ) ; },
ok_caption: "Continue",
} ) ;
}
}
@ -88,8 +90,10 @@ window.uploadScenario = function() {
if ( imageDataDecoded.length <= 1024*maxBytes )
doSelectScreenshotFile() ;
else {
ask( "VASL screenshot", "Screenshots should be less than " + maxBytes + " KB.", {
ok: doSelectScreenshotFile
ask( "ASL Scenario Archive upload",
"Screenshots should be less than " + maxBytes + " KB.", {
ok: doSelectScreenshotFile,
ok_caption: "Continue",
} ) ;
}
}
@ -236,9 +240,10 @@ function uploadFiles( asaScenarioId )
doUploadFiles() ;
} else {
// nope - confirm with the user first
ask( "Incomplete upload", warningMsg, {
ask( "ASL Scenario Archive upload", warningMsg, {
width: width,
ok: doUploadFiles,
ok_caption: "Continue",
} ) ;
}

@ -41,9 +41,9 @@ function _do_edit_simple_note( $sortable2, $entry, default_width )
},
open: function() {
// initialize
on_dialog_open( $(this) ) ;
add_flag_to_dialog_titlebar( $(this), get_player_no_for_element($sortable2) ) ;
$caption = $(this).children( "textarea" ) ;
on_dialog_open( $(this), $caption ) ;
add_flag_to_dialog_titlebar( $(this), get_player_no_for_element($sortable2) ) ;
var $btn_pane = $(".ui-dialog.edit-simple_note .ui-dialog-buttonpane") ;
$width = $btn_pane.children( "input[name='width']" ) ;
if ( $width.length === 0 ) {

@ -1481,10 +1481,10 @@ function on_load_scenario()
do_on_load_scenario() ;
else {
// yup - confirm the operation
ask( "Load scenario", "<p>This scenario has been changed.<p>Do you want load another scenario, and lose your changes?", {
ask( "Load scenario",
"<p> This scenario has been changed. <p> Do you want to load another scenario, and lose your changes?", {
width: 470,
ok: do_on_load_scenario,
cancel: function() {},
} ) ;
}
@ -1897,9 +1897,9 @@ function on_new_scenario()
do_on_new_scenario( true ) ;
else {
// yup - confirm the operation
ask( "New scenario", "<p>This scenario has been changed.<p>Do you want to reset it, and lose your changes?", {
ask( "New scenario",
"<p> This scenario has been changed. <p> Do you want to reset it, and lose your changes?", {
ok: function() { do_on_new_scenario( true ) ; },
cancel: function() {},
} ) ;
}
}

@ -172,7 +172,8 @@ $.fn.sortable2 = function( action, args )
caption,
"</div>"
] ;
ask( "Delete "+display_name[0], buf.join(""), {
ask( "Delete " + display_name[0],
buf.join(""), {
width: 350,
ok: do_delete_entry,
close: function() { set_entry_colors( $entry, false ) ; },

@ -209,7 +209,7 @@ function init_dialog( $dlg, ok_button_text, auto_dismiss )
}
}
function on_dialog_open( $dlg )
function on_dialog_open( $dlg, $focus )
{
// initialize the dialog
var ok_button_text = $dlg.data( "ok-button-text" ) ;
@ -217,8 +217,11 @@ function on_dialog_open( $dlg )
$( ".ui-dialog-buttonpane button:contains(Cancel)" ).addClass( "cancel" ) ;
// set initial focus
var $cancel = $( ".ui-dialog-buttonpane button:contains(Cancel)" ) ;
$cancel.focus() ;
if ( ! $focus )
$focus = $( ".ui-dialog-buttonpane button:contains(Cancel)" ) ;
setTimeout( function() {
$focus.focus() ;
}, 20 ) ;
}
function auto_dismiss_dialog( $dlg, evt, btn_text )
@ -242,10 +245,23 @@ function click_dialog_button( $dlg, btn_text )
function ask( title, msg, args )
{
// initialize
var $dlg = $( "#ask" ) ;
buttons = {} ;
var ok_caption = args.ok_caption || "OK" ;
buttons[ ok_caption ] = function() {
$dlg.dialog( "close" ) ;
if ( "ok" in args )
args.ok() ;
} ;
buttons.Cancel = function() {
$dlg.dialog( "close" ) ;
if ( "cancel" in args )
args.cancel() ;
} ;
// ask a question
var $dlg = $("#ask") ;
$dlg.html( msg ) ;
$dlg.dialog( {
$dlg.html( msg ).dialog( {
dialogClass: "ask",
modal: true,
closeOnEscape: false, // nb: handle_escape() has a special case for this dialog
@ -253,6 +269,7 @@ function ask( title, msg, args )
width: args.width || 400,
minWidth: 250,
maxHeight: window.innerHeight,
buttons: buttons,
create: function() {
init_dialog( $(this), "OK", false ) ;
// we handle ESCAPE ourself, to make it the same as clicking Cancel, not just closing the dialog
@ -264,27 +281,14 @@ function ask( title, msg, args )
} ) ;
},
open: function() {
$(this).data( "ok-button-text", ok_caption ) ;
on_dialog_open( $(this) ) ;
},
buttons: {
OK: function() {
$(this).dialog( "close" ) ;
if ( "ok" in args )
args.ok() ;
},
Cancel: function() {
$(this).dialog( "close" ) ;
if ( "cancel" in args )
args.cancel() ;
},
},
close: function() {
if ( "close" in args )
args.close() ;
},
} ) ;
return false ;
}
function showMsgDialog( title, msg, width )

@ -312,7 +312,7 @@ function on_analyze_vsav()
if ( voDefined1 || voDefined2 ) {
// yup - confirm the operation
ask( "Analyze VASL scenario",
"<p>There are some vehicles/ordnance already configured. <p>They will be <i>replaced</i> with those found in the analyzed VASL scenario.", {
"<p> There are some vehicles/ordnance already configured. <p> They will be <i>replaced</i> with those found in the analyzed VASL scenario.", {
width: 520,
ok: function() { _load_and_process_vsav( _do_analyze_vsav ) ; },
} ) ;

@ -134,7 +134,8 @@ function add_vo( vo_type, player_no )
}
if ( usedVoIds.indexOf( sel_entry.id ) !== -1 ) {
var vo_type2 = SORTABLE_DISPLAY_NAMES[ "ob_" + vo_type ][0] ;
ask( "Add "+vo_type2, "<p>This "+vo_type2+" is already in the OB<p>Do you want to add it again?", {
ask( "Add " + vo_type2,
"<p> This " + vo_type2 + " is already in the OB. <p >Do you want to add it again?", {
width: 300,
ok: add_sel_entry,
} ) ;

Loading…
Cancel
Save