Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
721b22a1
Commit
721b22a1
authored
Dec 12, 2018
by
Sli
Committed by
Skia
Dec 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forum: improve search bar UX behavior
parent
e421a2b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+24
-2
No files found.
forum/templates/forum/macros.jinja
View file @
721b22a1
...
...
@@ -157,9 +157,31 @@
{%
macro
display_search_bar
()
%}
<form
class=
"search_bar"
action=
"
{{
url
(
'forum:search'
)
}}
"
method=
"GET"
>
<input
type=
"text"
placeholder=
"
{%
trans
%}
Search
{%
endtrans
%}
"
name=
"query"
/>
<input
type=
"checkbox"
class=
"sreach_check"
name=
"order"
value=
"date"
checked
>
{%
trans
%}
Order by date
{%
endtrans
%}
<br>
<input
type=
"text"
id=
"forum_search_input"
placeholder=
"
{%
trans
%}
Search
{%
endtrans
%}
"
name=
"query"
/>
<input
type=
"checkbox"
id=
"forum_search_order_date"
class=
"sreach_check"
name=
"order"
value=
"date"
checked
>
{%
trans
%}
Order by date
{%
endtrans
%}
<br>
<input
type=
"submit"
class=
"search_bouton"
value=
"
{%
trans
%}
Search
{%
endtrans
%}
"
/>
<script
type=
"text/javascript"
>
// Uncheck the order by date checkbox if previously unchecked
const
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
);
var
waitForJQuery
=
setInterval
(
function
()
{
if
(
typeof
$
!=
'
undefined
'
){
fillSearchBar
();
clearInterval
(
waitForJQuery
);
}
},
10
);
function
fillSearchBar
()
{
if
(
searchParams
.
has
(
'
query
'
)){
$
(
'
#forum_search_input
'
).
val
(
searchParams
.
get
(
'
query
'
));
}
if
(
(
!
searchParams
.
has
(
'
order
'
)
&&
searchParams
.
has
(
'
query
'
)
)
||
(
searchParams
.
has
(
'
order
'
)
&&
searchParams
.
get
(
'
order
'
)
!=
'
date
'
)
)
{
$
(
'
#forum_search_order_date
'
).
removeAttr
(
'
checked
'
);
clearInterval
(
waitForJQuery
);
}
}
</script>
</form>
{%
endmacro
%}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment