Skip to content

Commit ba9f42c

Browse files
Progress Bar Options Display Toggle
- If user has progress bar is enabled checked it will display more options else it will be hidden
1 parent 1ef849a commit ba9f42c

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/optionsHandler.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,25 @@ async function optionsListeners(){
1616
const progressBarMinute_el = document.getElementById('progressBarMinute');
1717
const saveOptionsButton_el = document.getElementById('saveOptionsButton');
1818
const progressbarIsEnabled_el = document.getElementById('progressbarIsEnabled');
19-
19+
const progressBarInputsDiv_el = document.getElementById('progressBarInputsDiv');
20+
2021
progressbarIsEnabled_el.checked = optionsValues.progressBarSettings.isEnabled;
2122
progressBarSelect_el.value = optionsValues.progressBarSettings.interval;
2223
progressBarHour_el.value = optionsValues.progressBarSettings.hour;
2324
progressBarMinute_el.value = optionsValues.progressBarSettings.minute;
2425

26+
toggleProgressBarOptions(progressbarIsEnabled_el, progressBarInputsDiv_el)
27+
2528
const required = [progressBarHour_el, progressBarMinute_el];
2629

2730
optionsCloseButton_el.addEventListener('click', () => {
2831
overlayContainer_el.style.display = 'none';
2932
});
3033

34+
progressbarIsEnabled_el.addEventListener('click', () => {
35+
toggleProgressBarOptions(progressbarIsEnabled_el, progressBarInputsDiv_el)
36+
});
37+
3138
for (const input of required){
3239
input.addEventListener('input', () => {
3340
if (input.value < 0){
@@ -65,6 +72,14 @@ async function optionsListeners(){
6572
});
6673
}
6774

75+
function toggleProgressBarOptions(checkbox, div){
76+
if (checkbox.checked){
77+
div.style.display = 'grid';
78+
} else {
79+
div.style.display = 'none';
80+
}
81+
}
82+
6883
document.addEventListener('DOMContentLoaded', async () => {
6984
optionsValues = await api.optionsHandler({request: 'View'});
7085
await progressBar();

src/overlays.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h4>Progress Bar</h4>
5757
<input id="progressbarIsEnabled" type="checkbox">
5858
<h5>Is Enabled</h5>
5959
</div>
60-
<div style="display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 5px;">
60+
<div id="progressBarInputsDiv" style="display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 5px;">
6161
<h5>Interval</h5>
6262
<h5>Hours</h5>
6363
<h5>Minutes</h5>

0 commit comments

Comments
 (0)