Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit ffb98afb authored by David Barchiesi's avatar David Barchiesi

During application search try to also match application description and hide...

During application search try to also match application description and hide empty subcategory titles (i.e. Applications/Addons).
parent 6ebd056a
Pipeline #23373 passed with stage
in 8 minutes and 30 seconds
......@@ -29,7 +29,10 @@ if (search) {
const apps = document.querySelectorAll('.app');
const regex = new RegExp(e.target.value, 'i');
apps.forEach(function(app) {
if (app.querySelector('img').title.search(regex) !== -1) {
const imgTitleContainsRegex = app.querySelector('img').title.search(regex) !== -1;
const descriptionContainsRegex = app.querySelector('p').innerText.search(regex) !== -1;
if (imgTitleContainsRegex || descriptionContainsRegex) {
// app name is in search
if (app.classList.contains('d-none')) {
app.classList.remove('d-none');
......@@ -41,9 +44,30 @@ if (search) {
const categories = document.querySelectorAll('.category');
categories.forEach(function(category) {
if (category.querySelectorAll('.app:not(.d-none)').length > 0 && category.classList.contains('d-none')) {
const hasVisibleApps = category.querySelectorAll('.applications .app:not(.d-none)').length > 0;
const hasVisibleAddons = category.querySelectorAll('.addons .app:not(.d-none)').length > 0;
const appsTitle = category.querySelector('.applications-title');
if (appsTitle) {
if (hasVisibleApps && appsTitle.classList.contains('d-none')) {
appsTitle.classList.remove('d-none');
} else if (!hasVisibleApps && !appsTitle.classList.contains('d-none')) {
appsTitle.classList.add('d-none');
}
}
const addonsTitle = category.querySelector('.addons-title');
if (addonsTitle) {
if (addonsTitle && hasVisibleAddons && addonsTitle.classList.contains('d-none')) {
addonsTitle.classList.remove('d-none');
} else if (addonsTitle && !hasVisibleAddons && !addonsTitle.classList.contains('d-none')) {
addonsTitle.classList.add('d-none');
}
}
if ((hasVisibleApps || hasVisibleAddons) && category.classList.contains('d-none')) {
category.classList.remove('d-none');
} else if (category.querySelectorAll('.app:not(.d-none)').length === 0 && !category.classList.contains('d-none')) {
} else if (!(hasVisibleApps || hasVisibleAddons) && !category.classList.contains('d-none')) {
category.classList.add('d-none');
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment