Allowed Extras templates to set the width of their dropdown's.

master
Pacman Ghost 2 years ago
parent 071b6f587d
commit 941439a2ae
  1. 2
      vasl_templates/webapp/data/default-template-pack/extras/booby-traps.j2
  2. 2
      vasl_templates/webapp/data/default-template-pack/extras/count-remaining.j2
  3. 2
      vasl_templates/webapp/data/default-template-pack/extras/grid.j2
  4. 2
      vasl_templates/webapp/data/default-template-pack/extras/kakazu-ridge-cave-complexes.j2
  5. 2
      vasl_templates/webapp/data/default-template-pack/extras/victory-points.j2
  6. 7
      vasl_templates/webapp/static/css/tabs-extras.css
  7. 58
      vasl_templates/webapp/static/extras.js

@ -17,7 +17,7 @@ td.header { background: #f0f0f0 ; border-bottom: 1px solid #c0c0c0 ; padding: 2p
<tr> <tr>
<td class="header"> <td class="header">
Booby Traps (Level {{LEVEL:A::B::C|Level}}) Booby Traps (Level {{LEVEL:A::B::C/3|Level}})
<tr> <tr>
<td style="padding:2px 5px;"> <td style="padding:2px 5px;">

@ -41,7 +41,7 @@
</table> --> </table> -->
<!-- vasl-templates:comment We don't include common.css because it's not necessary, and we want to keep the generated snippet short. --> <!-- vasl-templates:comment We don't include common.css because it's not necessary, and we want to keep the generated snippet short. -->
<!-- vasl-templates:comment {{CAPTION:(none)::Panzerfaust::Tank-Hunter Heroes|Caption}} --> <!-- vasl-templates:comment {{CAPTION:(none)::Panzerfaust::Tank-Hunter Heroes/11|Caption}} -->
{# NOTE: We specify the font size in pixels, rather than as a percentage, since this label should be added to a counter. #} {# NOTE: We specify the font size in pixels, rather than as a percentage, since this label should be added to a counter. #}
<div style="font-size:12px;font-weight:bold;"> <div style="font-size:12px;font-weight:bold;">
{%if CAPTION != "(none)"%}{{CAPTION}}:{%endif%} {{COUNT:/2|Number}} {%if CAPTION != "(none)"%}{{CAPTION}}:{%endif%} {{COUNT:/2|Number}}

@ -6,7 +6,7 @@
<!-- caption = {{CAPTION*:/25|Caption}} --> <!-- caption = {{CAPTION*:/25|Caption}} -->
<!-- #cols = {{COLS:3/1|# columns}} ; #rows = {{ROWS:2/1|# rows}} --> <!-- #cols = {{COLS:3/1|# columns}} ; #rows = {{ROWS:2/1|# rows}} -->
<!-- cell size = {{CELL_WIDTH:180px/5|Cell width}} x {{CELL_HEIGHT:70px/5|Cell height}} --> <!-- cell size = {{CELL_WIDTH:180px/5|Cell width}} x {{CELL_HEIGHT:70px/5|Cell height}} -->
<!-- cell labels = {{CELL_LABELS:none::letters::numbers|Cell labels}} --> <!-- cell labels = {{CELL_LABELS:none::letters::numbers/6|Cell labels}} -->
<!-- color = {{PLAYER_COLOR_DROPLIST:|Border color}} ; border = {{BORDER_STYLE:solid::dotted::dashed::double::groove::ridge::inset::outset|Border style}} --> <!-- color = {{PLAYER_COLOR_DROPLIST:|Border color}} ; border = {{BORDER_STYLE:solid::dotted::dashed::double::groove::ridge::inset::outset|Border style}} -->
<head> <head>

@ -6,7 +6,7 @@
<head> <head>
<style> <style>
{{CSS:common}} {{CSS:common}}
/* {{CAVE_COMPLEX:Kakazu West::Kakazu Saddle::Kakazu Center::Kakazu Front::Kakazu Reverse::Kakazu East::Kakazu Village::(other)|Cave Complex}} */ /* {{CAVE_COMPLEX:Kakazu West::Kakazu Saddle::Kakazu Center::Kakazu Front::Kakazu Reverse::Kakazu East::Kakazu Village::(other)/10|Cave Complex}} */
.box { .box {
width: {{WIDTH:270px/5|Width}} ; width: {{WIDTH:270px/5|Width}} ;
height: {{HEIGHT:150px/5|Height}} ; height: {{HEIGHT:150px/5|Height}} ;

@ -6,4 +6,4 @@
<!-- vasl-templates:comment We don't include common.css because it's not necessary, and we want to keep the generated snippet short. --> <!-- vasl-templates:comment We don't include common.css because it's not necessary, and we want to keep the generated snippet short. -->
<div style="font-size:110%"> <div style="font-size:110%">
<b>{{TYPE:Victory Points::Casualty VP::Exit VP|Type}}:</b> 0 <b>{{TYPE:Victory Points::Casualty VP::Exit VP/9|Type}}:</b> 0

@ -32,10 +32,3 @@
padding: 0.2em 0.5em; border: 1px dotted #ccc ; padding: 0.2em 0.5em; border: 1px dotted #ccc ;
} }
#tabs-extras .right-panel .footer td.key { background: #f8f8f8 ; font-weight: bold ; } #tabs-extras .right-panel .footer td.key { background: #f8f8f8 ; font-weight: bold ; }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#tabs-extras .right-panel [name="extras/kakazu-ridge-cave-complexes"] .select2 { width: 10em !important ; }
#tabs-extras .right-panel [name="extras/victory-points"] .select2 { width: 9em !important ; }
#tabs-extras .right-panel [name="extras/count-remaining"] .select2 { width: 11em !important ; }
#tabs-extras .right-panel [name="extras/booby-traps"] .select2 { width: 2.5em !important ; }

@ -82,39 +82,43 @@ function _show_extra_template( template_id )
if ( template_info.params.length > 0 ) { if ( template_info.params.length > 0 ) {
buf.push( "<table name='" + template_info.template_id + "'>" ) ; buf.push( "<table name='" + template_info.template_id + "'>" ) ;
for ( var i=0 ; i < template_info.params.length ; ++i ) { for ( var i=0 ; i < template_info.params.length ; ++i ) {
var param = template_info.params[ i ] ;
buf.push( "<tr>" ) ; buf.push( "<tr>" ) ;
var display_name = template_info.params[i].caption || template_info.params[i].name ; var display_name = param.caption || param.name ;
buf.push( "<td class='caption'>", escapeHTML(display_name)+":" ) ; buf.push( "<td class='caption'>", escapeHTML(display_name)+":" ) ;
buf.push( "<td class='value'>" ) ; buf.push( "<td class='value'>" ) ;
if ( template_info.params[i].type === "input" ) { if ( param.type === "input" ) {
buf.push( "<input class='param' name='" + escapeHTML(template_info.params[i].name) + "' type='text'" ) ; buf.push( "<input class='param' name='" + escapeHTML(param.name) + "' type='text'" ) ;
if ( template_info.params[i].width ) if ( param.width )
buf.push( " size='" + escapeHTML(template_info.params[i].width) + "'" ) ; buf.push( " size='" + escapeHTML(param.width) + "'" ) ;
if ( template_info.params[i].default ) if ( param.default )
buf.push( " value='" + escapeHTML(template_info.params[i].default) + "'" ) ; buf.push( " value='" + escapeHTML(param.default) + "'" ) ;
if ( template_info.params[i].description ) if ( param.description )
buf.push( " title='" + escapeHTML(template_info.params[i].description) + "'" ) ; buf.push( " title='" + escapeHTML(param.description) + "'" ) ;
buf.push( ">" ) ; buf.push( ">" ) ;
} else if ( template_info.params[i].type == "html_textbox" ) { } else if ( param.type == "html_textbox" ) {
buf.push( "<div class='param html-textbox' name='" + escapeHTML(template_info.params[i].name) + "'" ) ; buf.push( "<div class='param html-textbox' name='" + escapeHTML(param.name) + "'" ) ;
if ( template_info.params[i].width ) if ( param.width )
buf.push( " style='width:" + (template_info.params[i].width * 0.75*gEmSize) + "px;'" ) ; buf.push( " style='width:" + (param.width * 0.75*gEmSize) + "px;'" ) ;
if ( template_info.params[i].description ) if ( param.description )
buf.push( " title='" + escapeHTML(template_info.params[i].description) + "'" ) ; buf.push( " title='" + escapeHTML(param.description) + "'" ) ;
buf.push( ">" ) ; buf.push( ">" ) ;
if ( template_info.params[i].default ) if ( param.default )
buf.push( sanitizeHTML( template_info.params[i].default ) ) ; buf.push( sanitizeHTML( param.default ) ) ;
buf.push( "</div>" ) ; buf.push( "</div>" ) ;
} else if ( template_info.params[i].type === "select" ) { } else if ( param.type === "select" ) {
buf.push( "<select class='param' name='" + escapeHTML(template_info.params[i].name) + "'>" ) ; buf.push( "<select class='param' name='" + escapeHTML(param.name) + "'" ) ;
for ( j=0 ; j < template_info.params[i].options.length ; ++j ) if ( param.width )
buf.push( "<option>", template_info.params[i].options[j], "</option>" ) ; buf.push( " data-width='" + param.width + "em'" ) ; // nb: select2 seems to be recognizing this
buf.push( ">" ) ;
for ( j=0 ; j < param.options.length ; ++j )
buf.push( "<option>", param.options[j], "</option>" ) ;
buf.push( "</select>" ) ; buf.push( "</select>" ) ;
} else if ( template_info.params[i].type === "player-droplist" ) { } else if ( param.type === "player-droplist" ) {
buf.push( "<select name='_PLAYER_DROPLIST_' style='width:11.5em;'>" ) ; buf.push( "<select name='_PLAYER_DROPLIST_' style='width:11.5em;'>" ) ;
add_player_nats( buf ) ; add_player_nats( buf ) ;
buf.push( "</select>" ) ; buf.push( "</select>" ) ;
} else if ( template_info.params[i].type === "player-color-droplist" ) { } else if ( param.type === "player-color-droplist" ) {
buf.push( "<select name='_PLAYER_DROPLIST_' style='width:11.5em;'>" ) ; buf.push( "<select name='_PLAYER_DROPLIST_' style='width:11.5em;'>" ) ;
buf.push( "<option value=':black:'>black</option>" ) ; buf.push( "<option value=':black:'>black</option>" ) ;
buf.push( "<option value=':gray:'>gray</option>" ) ; buf.push( "<option value=':gray:'>gray</option>" ) ;
@ -230,6 +234,14 @@ function _parse_extra_template( template_id, template )
// we have a <select> // we have a <select>
param.type = "select" ; param.type = "select" ;
param.options = val.split( "::" ) ; param.options = val.split( "::" ) ;
if ( param.options.length > 0 ) {
var lastOption = param.options[ param.options.length - 1 ] ;
var match = lastOption.match( /\/[0-9]+$/ ) ;
if ( match ) {
param.options[ param.options.length - 1 ] = lastOption.substring( 0, match.index ) ;
param.width = match[0].substr( 1 ) ;
}
}
} else if ( param.name === "PLAYER_DROPLIST" ) } else if ( param.name === "PLAYER_DROPLIST" )
param.type = "player-droplist" ; param.type = "player-droplist" ;
else if ( param.name === "PLAYER_COLOR_DROPLIST" ) else if ( param.name === "PLAYER_COLOR_DROPLIST" )

Loading…
Cancel
Save