fixed a bug where actions menus wouldn't close on clicking in an empty space

This commit is contained in:
Tobias 2023-08-30 11:28:36 +02:00
parent 0955e82336
commit 6185ba0865

View File

@ -28,7 +28,7 @@ const DAMAGE_PENALTY = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4];
const DAMAGE_NIVEAU = ["", "L", "M", "S", "D"];
const COMBATANT_TABLE_ROW = [
'<tr class="combatant-row" data-true-ini="" data-augmented-ui="tl-scoop bl-clip-y tr-clip-y br-scoop">\n', //TODO: add data-damage-* attributes with initial damage levels
'<tr class="combatant-row" data-true-ini="" data-augmented-ui="tl-scoop bl-clip-y tr-clip-y br-scoop">\n',
'<td class="combatant-name" title="Combatant\'s name" data-bs-toggle="modal" data-bs-target="#combatant-modal" data-augmented-ui="tl-scoop bl-clip-y both"></td>\n',
'<td class="combatant-ini" title="Effective initiative (w/ wound penalties)" data-bs-toggle="modal" data-bs-target="#combatant-modal" data-augmented-ui="both"></td>\n',
'<td class="combatant-dice-and-rea" title="Iniative dice and reaction" data-bs-toggle="modal" data-bs-target="#combatant-modal" data-augmented-ui="both"><span class="combatant-dice"></span>D+<span class="combatant-rea"></span></td>\n',
@ -499,11 +499,14 @@ $(document).ready(function () {
$('#combatant-modal').on('shown.bs.modal', () => $('#combatant-modal-name').focus());
// always empty input fields when combatant modal disappears
$("#combatant-modal").on('hidden.bs.modal', () => $("input[id*='combatant-modal']").val(""));
// Hide damage monitors after click somewhere else
// Hide damage monitors and actions menus after click somewhere else
$("html").on("click", (e) => {
if ($(e.target).parents(".damage-monitor").length == 0) {
$(".damage-monitor.seen").removeClass("seen");
}
if ($(e.target).parents(".actions-menu").length == 0) {
$(".actions-menu.seen").removeClass("seen");
}
});
addTestCombatant();
});