mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Theme: implement search_on_category_select as a preference
The implementation is change to work without javascript: When enabled, the HTML page contains buttons instead of checkboxes. * Related to https://github.com/searxng/searxng/issues/769#issuecomment-1132481995 * Fix https://github.com/searxng/searxng/issues/854
This commit is contained in:
parent
69a6d994e1
commit
3de28b283a
9 changed files with 87 additions and 55 deletions
|
|
@ -73,24 +73,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
// vanilla js version of search_on_category_select.js
|
||||
if (qinput !== null && d.querySelector('.help') != null && searxng.settings.search_on_category_select) {
|
||||
d.querySelector('.help').className = 'invisible';
|
||||
|
||||
searxng.on('#categories input', 'change', function () {
|
||||
var i, categories = d.querySelectorAll('#categories input[type="checkbox"]');
|
||||
for (i = 0; i < categories.length; i++) {
|
||||
if (categories[i] !== this && categories[i].checked) {
|
||||
categories[i].click();
|
||||
}
|
||||
}
|
||||
if (! this.checked) {
|
||||
this.click();
|
||||
}
|
||||
submitIfQuery();
|
||||
return false;
|
||||
});
|
||||
|
||||
// when search_on_category_select is enabled, autosubmit the query when the user
|
||||
// change the filters (safesearch, time_range, language)
|
||||
if (qinput !== null && searxng.settings.search_on_category_select) {
|
||||
searxng.on(d.getElementById('safesearch'), 'change', submitIfQuery);
|
||||
searxng.on(d.getElementById('time_range'), 'change', submitIfQuery);
|
||||
searxng.on(d.getElementById('language'), 'change', submitIfQuery);
|
||||
|
|
|
|||
|
|
@ -23,12 +23,15 @@
|
|||
"spacer categories";
|
||||
}
|
||||
|
||||
.category {
|
||||
.category_checkbox,
|
||||
.category_button {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
.ltr-margin-right(1rem);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.category_checkbox {
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -57,6 +60,33 @@
|
|||
}
|
||||
}
|
||||
|
||||
button.category_button {
|
||||
background-color: inherit;
|
||||
color: var(--color-base-font);
|
||||
cursor: pointer;
|
||||
padding: 0.2rem 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
text-transform: capitalize;
|
||||
font-size: 0.9em;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
|
||||
svg {
|
||||
padding-right: 0.2rem;
|
||||
}
|
||||
|
||||
&:focus-within {
|
||||
outline: 2px solid blue;
|
||||
}
|
||||
|
||||
&.selected,
|
||||
&:active {
|
||||
color: var(--color-categories-item-selected-font);
|
||||
border-bottom: 2px solid var(--color-categories-item-border-selected);
|
||||
}
|
||||
}
|
||||
|
||||
#search_logo {
|
||||
grid-area: logo;
|
||||
display: flex;
|
||||
|
|
@ -205,11 +235,6 @@ html.no-js #clear_search.hide_if_nojs {
|
|||
#categories {
|
||||
font-size: 90%;
|
||||
clear: both;
|
||||
|
||||
.checkbox_container {
|
||||
margin: auto;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +244,7 @@ html.no-js #clear_search.hide_if_nojs {
|
|||
#categories_container {
|
||||
width: max-content;
|
||||
|
||||
.category {
|
||||
.category_checkbox {
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
}
|
||||
|
|
@ -271,16 +296,23 @@ html.no-js #clear_search.hide_if_nojs {
|
|||
width: auto;
|
||||
margin: 0;
|
||||
|
||||
svg {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.category_checkbox {
|
||||
label {
|
||||
padding: 1rem !important;
|
||||
margin: 0 !important;
|
||||
|
||||
svg {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category_button {
|
||||
padding: 1rem !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
#search_view:focus-within {
|
||||
display: block;
|
||||
background-color: var(--color-search-background);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue