Skip to content

Commit c3180fa

Browse files
committed
Make entire groups visible or hidden
1 parent 5e4c2cd commit c3180fa

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

amd/build/filtercontroller.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/filtercontroller.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/filtercontroller.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,38 @@ export function init() {
4646
let letterfilter = letter.classList.contains('ts_letterfilter_approved');
4747

4848
// If all filters approve the letter, show the letter.
49-
if (coursefilter && timefilter && letterfilter) {
50-
letter.style.display = 'block';
51-
} else {
52-
letter.style.display = 'none';
53-
}
49+
letter.style.display = (coursefilter && timefilter && letterfilter) ? 'block' : 'none';
50+
51+
// Check if the letters group should be visible or not.
52+
updatelettergroup(letter);
5453
}
5554
});
5655
});
5756

5857
observer.observe(letter, {attributes: true});
5958
});
6059
}
60+
61+
/**
62+
* Helper function that checks if a letter group should still be visible. Is used if a filter is applied
63+
* that could change the visibility of one letter and therefore the letters group.
64+
* @param {HTMLElement} letter
65+
*/
66+
function updatelettergroup(letter) {
67+
// Get the letters group.
68+
const group = letter.closest('.ts-lettergroup');
69+
if (!group) {
70+
return;
71+
}
72+
73+
// Check every group letters visibility.
74+
const letters = group.querySelectorAll('.ts-letter-box > *');
75+
const anyVisible = Array.from(letters).some(el =>
76+
el.classList.contains('ts_coursefilter_approved') &&
77+
el.classList.contains('ts_timefilter_approved') &&
78+
el.classList.contains('ts_letterfilter_approved')
79+
);
80+
81+
// Group only gets shown if at least one element is visible.
82+
group.style.display = anyVisible ? 'block' : 'none';
83+
}

styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/blockcontent.mustache

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,26 @@
8888
<div class=" col-md-9 townsquare_content">
8989
<div class="townsquare_letters">
9090
{{#content}}
91-
{{> block_townsquare/orientationmarker}}
92-
{{#letters}}
93-
{{#isbasic}}
94-
{{> block_townsquare/basicletter}}
95-
{{/isbasic}}
96-
{{#isactivitycompletion}}
97-
{{> block_townsquare/activitycompletionletter}}
98-
{{/isactivitycompletion}}
99-
{{#ispost}}
100-
{{> block_townsquare/postletter}}
101-
{{/ispost}}
102-
{{/letters}}
91+
<div class="ts-lettergroup" id="ts-lettergroup-{{day}}">
92+
<div class="orientationmarker">
93+
<span class="orientationmarker_date">{{day}}</span>
94+
<span class="orientationmarker_line" aria-hidden="true"></span>
95+
<i class="orientationmarker_arrow fa fa-chevron-down ml-3 mr-2"></i>
96+
</div>
97+
<div class="ts-letter-box" id="ts-letters-{{day}}">
98+
{{#letters}}
99+
{{#isbasic}}
100+
{{> block_townsquare/basicletter}}
101+
{{/isbasic}}
102+
{{#isactivitycompletion}}
103+
{{> block_townsquare/activitycompletionletter}}
104+
{{/isactivitycompletion}}
105+
{{#ispost}}
106+
{{> block_townsquare/postletter}}
107+
{{/ispost}}
108+
{{/letters}}
109+
</div>
110+
</div>
103111
{{/content}}
104112
</div>
105113
</div>

0 commit comments

Comments
 (0)