Make table selection a little more robust.

This commit is contained in:
Oliver Jowett 2016-07-02 18:10:37 +01:00
parent 5cf512cf63
commit 54dc91adc5

View file

@ -89,8 +89,15 @@ function processReceiverUpdate(data) {
$('img', plane.tr.cells[1]).css('display', 'none'); $('img', plane.tr.cells[1]).css('display', 'none');
} }
plane.tr.addEventListener('click', selectPlaneByHex.bind(undefined,hex,false)); plane.tr.addEventListener('click', function(h, evt) {
plane.tr.addEventListener('dblclick', selectPlaneByHex.bind(undefined,hex,true)); selectPlaneByHex(h, false);
evt.preventDefault();
}.bind(undefined, hex));
plane.tr.addEventListener('dblclick', function(h, evt) {
selectPlaneByHex(h, true);
evt.preventDefault();
}.bind(undefined, hex));
Planes[hex] = plane; Planes[hex] = plane;
PlanesOrdered.push(plane); PlanesOrdered.push(plane);
@ -813,8 +820,9 @@ function selectPlaneByHex(hex,autofollow) {
$(Planes[SelectedPlane].tr).removeClass("selected"); $(Planes[SelectedPlane].tr).removeClass("selected");
} }
// If we are clicking the same plane, we are deselected it. // If we are clicking the same plane, we are deselecting it.
if (SelectedPlane === hex) { // (unless it was a doubleclick..)
if (SelectedPlane === hex && !autofollow) {
hex = null; hex = null;
} }