Skip to content

Commit

Permalink
Merge pull request #6 from hft-app/ljans
Browse files Browse the repository at this point in the history
Improve course selection
  • Loading branch information
ljans committed Nov 11, 2023
2 parents fd9cec1 + 46e8fed commit d5cb431
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
15 changes: 14 additions & 1 deletion scripts/client/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ $('.subjects .item').map(item => {
$('.header a', item).on('click', () => item.classList.toggle('active'));
});

// Set reset button state depending on total number of checked inputs
const updateResetButtonVisiblity = function() {
let count = 0;
$('.subjects input').map(test => test.checked ? count++ : null);
document.querySelector('nav a.reset').classList.toggle('active', count > 0);
};
updateResetButtonVisiblity();
$('.subjects input').on('change', updateResetButtonVisiblity);

// Save course selection
$('nav .save').on('click', function(){
this.classList.add('active');
Expand All @@ -43,5 +52,9 @@ $('nav .save').on('click', function(){

// Clear course selection
$('nav .reset').on('click', e => {
$('.subjects input').map(input => input.checked = false);
$('.subjects input').map(input => {
input.checked = false;
input.indeterminate = false;
});
updateResetButtonVisiblity();
});
2 changes: 1 addition & 1 deletion styles/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,27 @@ nav {
a {
padding: 8px 0;
color: $primary;


.icon {
margin-right: 3px;
}

&.save {
&::after { content: attr(data-idle); }
.status-active { display: none; }

&.active {
color: $secondary;

&::after { content: attr(data-active); }
.status-idle { display: none; }
.status-active { display: inline-block; }
}
}

&.reset {
color: $secondary;

&.active {
color: $primary;
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions templates/_courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

<nav>
<div class="bar container">
<a class="reset">Alle abwählen</a>
<a class="save" data-idle="Speichern" data-active="Speichert..."></a>
<a class="reset">
<span class="icon fa-regular fa-trash-can"></span>
<span>Zurücksetzen</span>
</a>
<a class="save">
<span class="status-active icon fa-solid fa-spin fa-circle-notch"></span>
<span class="status-idle icon fa-regular fa-floppy-disk"></span>
<span>Speichern</span>
</a>
</div>
</nav>

Expand Down

0 comments on commit d5cb431

Please sign in to comment.