thrimbletrimmer: Explicit button to reset crop settings to defaults

instead of on switch of template, which didn't work properly anyway.
chrusher/bus_synthesizer
Mike Lang 4 days ago
parent b7c78568b1
commit a819f02601

@ -268,6 +268,9 @@
<button id="video-info-thumbnail-template-source-image-update"> <button id="video-info-thumbnail-template-source-image-update">
Update Source Images Update Source Images
</button> </button>
<button id="video-info-thumbnail-template-default-crop">
Reset Crop To Defaults
</button>
<br /> <br />
<div class="video-info-thumbnail-advanced-crop-flex-wrapper"> <div class="video-info-thumbnail-advanced-crop-flex-wrapper">

@ -239,7 +239,7 @@ window.addEventListener("DOMContentLoaded", async (event) => {
}); });
document document
.getElementById("video-info-thumbnail-template") .getElementById("video-info-thumbnail-template")
.addEventListener("change", thumbnailTemplateChanged); .addEventListener("change", handleFieldChange);
document document
.getElementById("video-info-thumbnail-mode") .getElementById("video-info-thumbnail-mode")
.addEventListener("change", updateThumbnailInputState); .addEventListener("change", updateThumbnailInputState);
@ -431,7 +431,7 @@ window.addEventListener("DOMContentLoaded", async (event) => {
} }
thumbnailTemplateSelection.appendChild(templateOption); thumbnailTemplateSelection.appendChild(templateOption);
} }
thumbnailTemplateChanged(); setDefaultCrop(false);
} else { } else {
addError("Failed to load thumbnail templates list"); addError("Failed to load thumbnail templates list");
} }
@ -451,6 +451,10 @@ window.addEventListener("DOMContentLoaded", async (event) => {
// Ensure that changing values on load doesn't set keep the page dirty. // Ensure that changing values on load doesn't set keep the page dirty.
globalPageState = PAGE_STATE.CLEAN; globalPageState = PAGE_STATE.CLEAN;
document.getElementById("video-info-thumbnail-template-default-crop").addEventListener("click", (_event) => {
setDefaultCrop(true);
});
document.getElementById("submit-button").addEventListener("click", (_event) => { document.getElementById("submit-button").addEventListener("click", (_event) => {
submitVideo(); submitVideo();
}); });
@ -1024,9 +1028,7 @@ function updateThumbnailInputState(event) {
} }
} }
function thumbnailTemplateChanged(event) { function setDefaultCrop(updateWidgets) {
handleFieldChange(event);
const newTemplate = document.getElementById("video-info-thumbnail-template").value; const newTemplate = document.getElementById("video-info-thumbnail-template").value;
for (const field of ["crop", "location"]) { for (const field of ["crop", "location"]) {
const newValue = thumbnailTemplates[newTemplate][field]; const newValue = thumbnailTemplates[newTemplate][field];
@ -1034,6 +1036,11 @@ function thumbnailTemplateChanged(event) {
document.getElementById(`video-info-thumbnail-${field}-${i}`).value = newValue[i]; document.getElementById(`video-info-thumbnail-${field}-${i}`).value = newValue[i];
} }
} }
if (updateWidgets) {
updateTemplateCropWidgets();
}
handleFieldChange();
} }
// Returns [crop, location], with either being null on error. // Returns [crop, location], with either being null on error.

Loading…
Cancel
Save