Skip to content
Snippets Groups Projects
Commit 910ce392 authored by Zhou Fang's avatar Zhou Fang
Browse files

#292 Converted jQuery to vanilla JS

parent 4adeb372
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
* SPDX-License-Identifier: EPL-2.0 * SPDX-License-Identifier: EPL-2.0
*/ */
import $ from 'jquery';
import 'jquery-match-height';
import displayErrMsg from '../utils/displayErrMsg'; import displayErrMsg from '../utils/displayErrMsg';
import template from './templates/explore-working-groups/working-group-list.mustache'; import template from './templates/explore-working-groups/working-group-list.mustache';
...@@ -29,6 +27,7 @@ const EclipseFdnWGsList = (async () => { ...@@ -29,6 +27,7 @@ const EclipseFdnWGsList = (async () => {
try { try {
wgsData = await (await fetch(url)).json(); wgsData = await (await fetch(url)).json();
wgsData = wgsData.sort((a, b) => a.alias.localeCompare(b.alias)); wgsData = wgsData.sort((a, b) => a.alias.localeCompare(b.alias));
} catch (error) { } catch (error) {
displayErrMsg(element, error); displayErrMsg(element, error);
return; return;
...@@ -88,36 +87,43 @@ const EclipseFdnWGsList = (async () => { ...@@ -88,36 +87,43 @@ const EclipseFdnWGsList = (async () => {
anchoredWG && document.getElementById(anchoredWG).scrollIntoView({ behavior: 'smooth' }); anchoredWG && document.getElementById(anchoredWG).scrollIntoView({ behavior: 'smooth' });
// Filter logic // Filter logic
$(function () { let currentSelectedStatus = 'wg-item';
$('.wg-links a').click(function () { const allFilterBtns = document.querySelectorAll('.wg-btn');
let wg_item = $(this).attr('data-wg'); allFilterBtns[0].classList.add('active');
if (wg_item === 'wg-all-item') {
$('.wg-item') const fadeOutAndIn = ({ target }) => {
.fadeOut('300') const newSelectedStatus = target.getAttribute('data-wg');
.promise() if (newSelectedStatus === currentSelectedStatus) {
.done(function () { // No need to do filtering if the status doesn't change
$('.wg-item').fadeIn('300'); return;
$('.wg-item').matchHeight({ remove: true }); }
$('.wg-item:visible').matchHeight();
}); // Fade out current wg items
} else { document.querySelectorAll(`.${currentSelectedStatus}`).forEach((item) => {
$('.wg-item') item.classList.add('fade');
.fadeOut('300') setTimeout(() => {
.promise() item.classList.add('hide');
.done(function () {
$('.' + wg_item).fadeIn('300'); // Fade in selected wg items
$('.wg-item').matchHeight({ remove: true }); document.querySelectorAll(`.${newSelectedStatus}`).forEach((item) => {
$('.wg-item:visible').matchHeight(); item.classList.remove('hide');
}); item.classList.remove('fade');
} });
}, 150);
}); });
$('.wg-all-item').click(function () { allFilterBtns.forEach((btn) => {
$('.wg-item').fadeIn('300'); if (btn.getAttribute('data-wg') === currentSelectedStatus) {
$('.wg-item').matchHeight({ remove: true }); btn.classList.remove('active');
$('.wg-item:visible').matchHeight(); }
}); });
}); target.classList.add('active');
currentSelectedStatus = newSelectedStatus;
};
allFilterBtns.forEach((wgBtn) => {
wgBtn.addEventListener('click', fadeOutAndIn);
});
})(); })();
export default EclipseFdnWGsList; export default EclipseFdnWGsList;
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter Working Groups <button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">Filter Working Groups
<span class="caret"></span></button> <span class="caret"></span></button>
<ul class="dropdown-menu wg-links"> <ul class="dropdown-menu wg-links">
<li><a style="width:150px;" class="wg-btn" data-wg="wg-all-item" role="button">All</a></li> <li><a class="wg-btn" data-wg="wg-item" role="button">All</a></li>
{{#shouldShowFilterOptions.active}} {{#shouldShowFilterOptions.active}}
<li><a style="width:150px;" class="wg-btn" data-wg="wg-active-item" role="button">Active</a></li> <li><a class="wg-btn" data-wg="wg-active-item" role="button">Active</a></li>
{{/shouldShowFilterOptions.active}} {{/shouldShowFilterOptions.active}}
{{#shouldShowFilterOptions.incubating}} {{#shouldShowFilterOptions.incubating}}
<li><a style="width:150px;" class="wg-btn" data-wg="wg-incubating-item" role="button">Incubating</a></li> <li><a class="wg-btn" data-wg="wg-incubating-item" role="button">Incubating</a></li>
{{/shouldShowFilterOptions.incubating}} {{/shouldShowFilterOptions.incubating}}
{{#shouldShowFilterOptions.proposed}} {{#shouldShowFilterOptions.proposed}}
<li><a style="width:150px;" class="wg-btn" data-wg="wg-proposed-item" role="button">Proposed</a></li> <li><a class="wg-btn" data-wg="wg-proposed-item" role="button">Proposed</a></li>
{{/shouldShowFilterOptions.proposed}} {{/shouldShowFilterOptions.proposed}}
</ul> </ul>
</div> </div>
......
...@@ -125,4 +125,14 @@ img.desaturate { ...@@ -125,4 +125,14 @@ img.desaturate {
} }
.solstice-loading > i.fa { .solstice-loading > i.fa {
font-size: @solstice-loading-size; font-size: @solstice-loading-size;
} }
\ No newline at end of file
.dropdown-menu li a {
background-color: #fff;
&:hover{
background-color: #efefef;
}
&.active {
background-color: #efefef;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment