From 4192bf965488e220f27437b7a5d592e75400187f Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 18 Oct 2018 05:21:09 +0000 Subject: [PATCH] Show flags in dialog titlebars. --- vasl_templates/webapp/static/css/main.css | 1 + vasl_templates/webapp/static/simple_notes.js | 1 + vasl_templates/webapp/static/utils.js | 25 +++++++++++++++++++- vasl_templates/webapp/static/vo.js | 1 + vasl_templates/webapp/static/vo2.js | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/vasl_templates/webapp/static/css/main.css b/vasl_templates/webapp/static/css/main.css index f40a5e4..bd0e77f 100644 --- a/vasl_templates/webapp/static/css/main.css +++ b/vasl_templates/webapp/static/css/main.css @@ -37,6 +37,7 @@ button.edit-template { height: 30px ; padding: 4px 10px ; } button.edit-template img { height: 18px ; vertical-align: middle ; margin-right: 0.25em ; } .ui-dialog-titlebar { padding: 0.2em 0.5em 0.2em 0.5em !important ; } +.ui-dialog-titlebar img.flag { height: 1em ; margin-right: 0.25em ; } .ui-dialog-titlebar-close { margin-top: -10px !important ; } .ui-dialog-content p { margin-bottom: 0.5em ; } .ui-dialog-buttonpane button.ok { background: #ddd ; } diff --git a/vasl_templates/webapp/static/simple_notes.js b/vasl_templates/webapp/static/simple_notes.js index 2c598bb..ea5882b 100644 --- a/vasl_templates/webapp/static/simple_notes.js +++ b/vasl_templates/webapp/static/simple_notes.js @@ -42,6 +42,7 @@ 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" ) ; var $btn_pane = $(".ui-dialog.edit-simple_note .ui-dialog-buttonpane") ; $width = $btn_pane.children( "input[name='width']" ) ; diff --git a/vasl_templates/webapp/static/utils.js b/vasl_templates/webapp/static/utils.js index 3d746ea..68e395a 100644 --- a/vasl_templates/webapp/static/utils.js +++ b/vasl_templates/webapp/static/utils.js @@ -7,10 +7,18 @@ function get_nationality_display_name( nat_id ) return gTemplatePack.nationalities[ nat_id ].display_name ; } +function get_player_nat( player_no ) +{ + // get the player's nationality + if ( player_no === null ) + return null ; + return $( "select[name='PLAYER_" + player_no + "']" ).val() ; +} + function get_player_colors( player_no ) { // get the colors for the specified player - var player_nat = $( "select[name='PLAYER_" + player_no + "']" ).val() ; + var player_nat = get_player_nat( player_no ) ; return gTemplatePack.nationalities[ player_nat ].ob_colors ; } @@ -286,6 +294,21 @@ function restrict_droplist_height( $sel ) // -------------------------------------------------------------------- +function add_flag_to_dialog_titlebar( $dlg, player_no ) +{ + // add a flag to the dialog's titlebar + var player_nat = get_player_nat( player_no ) ; + if ( ! player_nat ) + return ; + var $titlebar = $dlg.dialog( "instance" ).uiDialogTitlebar ; + var url = gImagesBaseUrl + "/flags/" + player_nat + ".png" ; + $titlebar.find( ".ui-dialog-title" ).prepend( + $( "" ) + ).css( { display: "flex", "align-items": "center" } ) ; +} + +// -------------------------------------------------------------------- + function getUrlParam( param ) { // look for the specified URL parameter diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js index b8b5cd5..97a8eb0 100644 --- a/vasl_templates/webapp/static/vo.js +++ b/vasl_templates/webapp/static/vo.js @@ -90,6 +90,7 @@ function add_vo( vo_type, player_no ) open: function() { // initialize on_dialog_open( $(this) ) ; + add_flag_to_dialog_titlebar( $(this), get_player_no_for_element($sortable2) ) ; $sel.select2( "open" ) ; // set the titlebar color var colors = get_player_colors_for_element( $sortable2 ) ; diff --git a/vasl_templates/webapp/static/vo2.js b/vasl_templates/webapp/static/vo2.js index fd146f9..ca1adb9 100644 --- a/vasl_templates/webapp/static/vo2.js +++ b/vasl_templates/webapp/static/vo2.js @@ -95,6 +95,7 @@ function _do_edit_ob_vo( $entry, player_no, vo_type ) open: function() { // initialize on_dialog_open( $(this) ) ; + add_flag_to_dialog_titlebar( $(this), player_no ) ; // set the titlebar color var colors = get_player_colors( player_no ) ; $( ".ui-dialog.edit-vo .ui-dialog-titlebar" ).css( {