Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Merge requests
!204
Resolve "Global search"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Global search"
208-global-search
into
master
Overview
4
Commits
21
Pipelines
12
Changes
3
Merged
Nik | Klampfradler
requested to merge
208-global-search
into
master
5 years ago
Overview
4
Commits
21
Pipelines
12
Changes
3
Expand
Closes
#208 (closed)
Edited
4 years ago
by
Tom Teichler
0
0
Merge request reports
Viewing commit
39aa8aed
Prev
Next
Show latest version
3 files
+
37
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
39aa8aed
Resize search results and auto-hide them using JS
· 39aa8aed
Julian
authored
4 years ago
aleksis/core/static/js/search.js
+
24
−
0
Options
@@ -20,11 +20,35 @@ Autocomplete.prototype.setup = function() {
this
.
form_elem
=
$
(
this
.
form_selector
);
this
.
query_box
=
this
.
form_elem
.
find
(
'
input[name=q]
'
);
// Trigger the "keyup" event if input gets focused
this
.
query_box
.
focus
(
function
()
{
self
.
query_box
.
trigger
(
"
keyup
"
);
});
// Remove search results if input field isn't focused anymore
$
(
'
body
'
).
click
(
function
(
evt
)
{
if
(
evt
.
target
.
id
in
[
"
search
"
,
"
search-results
"
])
return
;
//For descendants of search-results being clicked, remove this check if you do not want to put constraint on descendants.
let
distance
=
$
(
evt
.
target
).
closest
(
'
#search-results
'
).
length
;
console
.
log
(
distance
);
if
(
0
<
distance
&&
distance
<=
2
)
{
console
.
log
(
"
clicked on a search result
"
);
return
;
}
//Do processing of click event here for every element except with id search-results
$
(
'
#search-results
'
).
remove
();
});
// Watch the input box.
this
.
query_box
.
on
(
'
keyup
'
,
function
()
{
var
query
=
self
.
query_box
.
val
();
if
(
query
.
length
<
self
.
minimum_length
)
{
$
(
"
#search-results
"
).
remove
();
return
false
;
}
Loading