Use a fixed height for vehicle/ordnance sortable2 entries.

master
Pacman Ghost 6 years ago
parent 7b76cd52a1
commit ded0a1aa18
  1. 8
      vasl_templates/webapp/static/sortable.js
  2. 9
      vasl_templates/webapp/static/vo.js

@ -191,9 +191,13 @@ $.fn.sortable2 = function( action, args )
// NOTE: We can't get height for sortable2's that are not visible (i.e. not in the active tab),
// we update the heights dynamically as tabs are selected, and the window is resized.
var available_height = $sortable2.parent().height() ;
var max_height = Math.max( available_height/$entries.length, 2*gEmSize ) ;
var max_height = Math.ceil( Math.max( available_height/$entries.length, 2*gEmSize ) ) ;
$entries.each( function() {
$(this).css({ "max-height": Math.ceil(max_height)+"px", "overflow-y": "hidden" }) ;
var fixed_height = $(this).data( "sortable2-data" ).fixed_height ;
if ( fixed_height )
$(this).css( "height", fixed_height+"px" ) ;
else
$(this).css({ "max-height": max_height+"px", "overflow-y": "hidden" }) ;
// check for overflow
var entry_height = $(this).height() ;
var content_height = $(this).children("div").height() ;

@ -96,14 +96,19 @@ function add_vo( vo_type, player_no )
function do_add_vo( vo_type, player_no, entry )
{
// add the specified vehicle/ordnance
// NOTE: We set a fixed height for the sortable2 entries (based on the CSS settings in tabs-ob.css),
// so that the vehicle/ordnance images won't get truncated if there are a lot of them.
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
var div_tag = "<div" ;
if ( is_small_vasl_piece( entry ) )
var fixed_height = 3.25 * gEmSize ;
if ( is_small_vasl_piece( entry ) ) {
div_tag += " class='small-piece'" ;
fixed_height = 2.25 * gEmSize ;
}
div_tag += ">" ;
$sortable2.sortable2( "add", {
content: $( div_tag + "<img src='"+_get_vo_image_url(entry)+"'>" + entry.name + "</div>" ),
data: { caption: entry.name, vo_entry: entry },
data: { caption: entry.name, vo_entry: entry, fixed_height: fixed_height },
} ) ;
}

Loading…
Cancel
Save