Fixed a bug where the combatant modal would close after clicking OK / pressing enter even though the input didn't validate
This commit is contained in:
parent
63341abe08
commit
332050526d
@ -1,6 +1,9 @@
|
|||||||
$fg: deeppink; // #ff1493
|
/*$fg: deeppink; // #ff1493
|
||||||
$fg-bright: lightpink; // #ffb6c1
|
$fg-bright: lightpink; // #ffb6c1
|
||||||
$fg-dark: #b3005f;
|
$fg-dark: #b3005f;*/
|
||||||
|
$fg: gold;
|
||||||
|
$fg-bright: yellow;
|
||||||
|
$fg-dark: orange;
|
||||||
|
|
||||||
$bg: cyan; // #00ffff
|
$bg: cyan; // #00ffff
|
||||||
$bg-bright: lightcyan; // #e0ffff
|
$bg-bright: lightcyan; // #e0ffff
|
||||||
@ -249,6 +252,7 @@ header.navbar {
|
|||||||
|
|
||||||
.badge.bg-warning {
|
.badge.bg-warning {
|
||||||
background: radial-gradient(circle at center, $bg, $bg-dark);
|
background: radial-gradient(circle at center, $bg, $bg-dark);
|
||||||
|
color: black;
|
||||||
bottom: -4px;
|
bottom: -4px;
|
||||||
left: 12px;
|
left: 12px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
@ -256,6 +260,7 @@ header.navbar {
|
|||||||
|
|
||||||
.badge.bg-danger {
|
.badge.bg-danger {
|
||||||
background: radial-gradient(circle at center, $fg, $fg-dark);
|
background: radial-gradient(circle at center, $fg, $fg-dark);
|
||||||
|
color: black;
|
||||||
left: 12px;
|
left: 12px;
|
||||||
top: 12px;
|
top: 12px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
@ -370,7 +375,7 @@ footer {
|
|||||||
user-select: auto;
|
user-select: auto;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: $bg-bright;
|
color: $fg;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<link type="text/css" rel="stylesheet" href="../node_modules/augmented-ui/augmented-ui.css">
|
<link type="text/css" rel="stylesheet" href="../node_modules/augmented-ui/augmented-ui.css">
|
||||||
<link type="text/css" rel="stylesheet" href="css/sr2ini.scss">
|
<link type="text/css" rel="stylesheet" href="css/sr2ini.scss">
|
||||||
|
|
||||||
<script type="module" src="js/sr2ini.js" defer></script>
|
<script type="module" src="js/sr2ini.js"></script>
|
||||||
<script type="module" src="../node_modules/@iconfu/svg-inject/dist/svg-inject.js"></script>
|
<script type="module" src="../node_modules/@iconfu/svg-inject/dist/svg-inject.js"></script>
|
||||||
|
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
|
||||||
@ -63,8 +63,7 @@
|
|||||||
|
|
||||||
<div class="footer-container">
|
<div class="footer-container">
|
||||||
<footer data-augmented-ui="tl-2-clip-x tr-2-clip-x both">
|
<footer data-augmented-ui="tl-2-clip-x tr-2-clip-x both">
|
||||||
<p>code & design by <a href="https://tobias-radloff.de/" tabindex="-1" title="Eclipse">Eclipse</a> | Shadowrun trademarked by <a href="https://www.topps.com/" tabindex="-1" title="Topps">Topps</a><br>
|
<p>code & design by <a href="#" tabindex="-1" title="Eclipse">Eclipse</a> | background by <a href="https://www.deviantart.com/xxaries1970xx" tabindex="-1" title="xxAries1970xx on DeviantArt">xxAries1970xx</a></p>
|
||||||
icons by <a href="https://www.freepik.com" tabindex="-1" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" tabindex="-1" title="Flaticon">www.flaticon.com</a> | background by <a href="https://www.deviantart.com/xxaries1970xx" tabindex="-1" title="xxAries1970xx on DeviantArt">xxAries1970xx</a></p>
|
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -102,7 +101,7 @@
|
|||||||
<div class="input-group input-group-sm my-2">
|
<div class="input-group input-group-sm my-2">
|
||||||
<input type="number" min="1" max="5" class="form-control form-control-sm" id="combatant-modal-dice" form="combatant-form" placeholder="Dice">
|
<input type="number" min="1" max="5" class="form-control form-control-sm" id="combatant-modal-dice" form="combatant-form" placeholder="Dice">
|
||||||
<span class="input-group-text">D+</span>
|
<span class="input-group-text">D+</span>
|
||||||
<input type="number" min="1" max="25" class="form-control form-control-sm" id="combatant-modal-rea" form="combatant-form" placeholder="REA">
|
<input type="number" min="0" max="30" class="form-control form-control-sm" id="combatant-modal-rea" form="combatant-form" placeholder="REA">
|
||||||
<span class="input-group-text"> </span>
|
<span class="input-group-text"> </span>
|
||||||
<input type="number" min="0" max="55" class="form-control form-control-sm" id="combatant-modal-ini" form="combatant-form" placeholder="Ini">
|
<input type="number" min="0" max="55" class="form-control form-control-sm" id="combatant-modal-ini" form="combatant-form" placeholder="Ini">
|
||||||
|
|
||||||
@ -123,8 +122,8 @@
|
|||||||
<div class="modal-footer" data-augmented-ui="inlay">
|
<div class="modal-footer" data-augmented-ui="inlay">
|
||||||
<button type="button" class="sr2-button" id="combatant-modal-cancel-button" data-bs-dismiss="modal">Cancel</button>
|
<button type="button" class="sr2-button" id="combatant-modal-cancel-button" data-bs-dismiss="modal">Cancel</button>
|
||||||
<button type="submit" class="sr2-button" id="combatant-modal-add-apply-button">Apply</button>
|
<button type="submit" class="sr2-button" id="combatant-modal-add-apply-button">Apply</button>
|
||||||
<button type="submit" class="sr2-button" id="combatant-modal-add-ok-button" data-bs-dismiss="modal">OK</button>
|
<button type="submit" class="sr2-button" id="combatant-modal-add-ok-button" >OK</button>
|
||||||
<button type="submit" class="sr2-button d-none" id="combatant-modal-edit-ok-button" data-bs-dismiss="modal">OK</button>
|
<button type="submit" class="sr2-button d-none" id="combatant-modal-edit-ok-button" >OK</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -230,6 +230,7 @@ function handleMoreActionsButtonClick(e) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// click handler for new round button
|
||||||
function handleNewRoundButton(e) {
|
function handleNewRoundButton(e) {
|
||||||
// restyle modal
|
// restyle modal
|
||||||
$("#confirm-modal .modal-title").text("Start new Round");
|
$("#confirm-modal .modal-title").text("Start new Round");
|
||||||
@ -259,6 +260,10 @@ function addCombatant(e) {
|
|||||||
if (!validateCombatant()) {
|
if (!validateCombatant()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// hide modal if OK was pressed, but not on Apply
|
||||||
|
if (e.target.id != "combatant-modal-add-apply-button") {
|
||||||
|
bs.getInstance($("#combatant-modal")).hide();
|
||||||
|
}
|
||||||
// roll for initiative if necessary
|
// roll for initiative if necessary
|
||||||
let ini = $("#combatant-modal-ini").val().trim();
|
let ini = $("#combatant-modal-ini").val().trim();
|
||||||
ini = (ini != "") ? ini : rollForInitiative($("#combatant-modal-dice").val(), $("#combatant-modal-rea").val());
|
ini = (ini != "") ? ini : rollForInitiative($("#combatant-modal-dice").val(), $("#combatant-modal-rea").val());
|
||||||
@ -316,6 +321,8 @@ console.log("editing combatant …")
|
|||||||
if (!validateCombatant()) {
|
if (!validateCombatant()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// hide modal
|
||||||
|
bs.getInstance($("#combatant-modal")).hide();
|
||||||
// get values
|
// get values
|
||||||
let name = $("#combatant-modal-name").val().trim();
|
let name = $("#combatant-modal-name").val().trim();
|
||||||
let ini = $("#combatant-modal-ini").val().trim();
|
let ini = $("#combatant-modal-ini").val().trim();
|
||||||
@ -508,7 +515,7 @@ $(document).ready(function () {
|
|||||||
$(".actions-menu.seen").removeClass("seen");
|
$(".actions-menu.seen").removeClass("seen");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addTestCombatant();
|
// addTestCombatant();
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = { rollForInitiative, validateCombatant, whoGoesFirst, getEffectiveIni };
|
module.exports = { rollForInitiative, validateCombatant, whoGoesFirst, getEffectiveIni };
|
||||||
Loading…
Reference in New Issue
Block a user