Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
05f403cf
Commit
05f403cf
authored
Sep 13, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move search autocomplete from dispatcher to main.js
parent
dc2b81c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
13 deletions
+10
-13
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+0
-10
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+3
-0
app/assets/javascripts/search_autocomplete.js
app/assets/javascripts/search_autocomplete.js
+5
-1
spec/javascripts/search_autocomplete_spec.js
spec/javascripts/search_autocomplete_spec.js
+2
-2
No files found.
app/assets/javascripts/dispatcher.js
View file @
05f403cf
...
@@ -4,16 +4,8 @@ import $ from 'jquery';
...
@@ -4,16 +4,8 @@ import $ from 'jquery';
import
GfmAutoComplete
from
'
./gfm_auto_complete
'
;
import
GfmAutoComplete
from
'
./gfm_auto_complete
'
;
import
{
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
import
{
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
import
Shortcuts
from
'
./shortcuts
'
;
import
Shortcuts
from
'
./shortcuts
'
;
import
SearchAutocomplete
from
'
./search_autocomplete
'
;
import
performanceBar
from
'
./performance_bar
'
;
import
performanceBar
from
'
./performance_bar
'
;
function
initSearch
()
{
// Only when search form is present
if
(
$
(
'
.search
'
).
length
)
{
return
new
SearchAutocomplete
();
}
}
function
initPageShortcuts
(
page
)
{
function
initPageShortcuts
(
page
)
{
const
pagesWithCustomShortcuts
=
[
const
pagesWithCustomShortcuts
=
[
'
projects:activity
'
,
'
projects:activity
'
,
...
@@ -70,8 +62,6 @@ function initPerformanceBar() {
...
@@ -70,8 +62,6 @@ function initPerformanceBar() {
}
}
export
default
()
=>
{
export
default
()
=>
{
initSearch
();
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
if
(
page
)
{
if
(
page
)
{
initPageShortcuts
(
page
);
initPageShortcuts
(
page
);
...
...
app/assets/javascripts/main.js
View file @
05f403cf
...
@@ -28,6 +28,7 @@ import './frequent_items';
...
@@ -28,6 +28,7 @@ import './frequent_items';
import
initBreadcrumbs
from
'
./breadcrumb
'
;
import
initBreadcrumbs
from
'
./breadcrumb
'
;
import
initDispatcher
from
'
./dispatcher
'
;
import
initDispatcher
from
'
./dispatcher
'
;
import
initUsagePingConsent
from
'
./usage_ping_consent
'
;
import
initUsagePingConsent
from
'
./usage_ping_consent
'
;
import
initSearchAutocomplete
from
'
./search_autocomplete
'
;
import
GlFieldErrors
from
'
./gl_field_errors
'
;
import
GlFieldErrors
from
'
./gl_field_errors
'
;
// expose jQuery as global (TODO: remove these)
// expose jQuery as global (TODO: remove these)
...
@@ -78,6 +79,8 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -78,6 +79,8 @@ document.addEventListener('DOMContentLoaded', () => {
initLogoAnimation
();
initLogoAnimation
();
initUsagePingConsent
();
initUsagePingConsent
();
if
(
document
.
querySelector
(
'
.search
'
))
initSearchAutocomplete
();
// Set the default path for all cookies to GitLab's root directory
// Set the default path for all cookies to GitLab's root directory
Cookies
.
defaults
.
path
=
gon
.
relative_url_root
||
'
/
'
;
Cookies
.
defaults
.
path
=
gon
.
relative_url_root
||
'
/
'
;
...
...
app/assets/javascripts/search_autocomplete.js
View file @
05f403cf
...
@@ -68,7 +68,7 @@ function setSearchOptions() {
...
@@ -68,7 +68,7 @@ function setSearchOptions() {
}
}
}
}
export
default
class
SearchAutocomplete
{
export
class
SearchAutocomplete
{
constructor
({
wrap
,
optsEl
,
autocompletePath
,
projectId
,
projectRef
}
=
{})
{
constructor
({
wrap
,
optsEl
,
autocompletePath
,
projectId
,
projectRef
}
=
{})
{
setSearchOptions
();
setSearchOptions
();
this
.
bindEventContext
();
this
.
bindEventContext
();
...
@@ -499,3 +499,7 @@ export default class SearchAutocomplete {
...
@@ -499,3 +499,7 @@ export default class SearchAutocomplete {
this
.
dropdownMenu
.
toggleClass
(
'
fade-out
'
,
!
this
.
isScrolledUp
());
this
.
dropdownMenu
.
toggleClass
(
'
fade-out
'
,
!
this
.
isScrolledUp
());
}
}
}
}
export
default
function
initSearchAutocomplete
(
opts
)
{
return
new
SearchAutocomplete
(
opts
);
}
spec/javascripts/search_autocomplete_spec.js
View file @
05f403cf
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
'
~/gl_dropdown
'
;
import
'
~/gl_dropdown
'
;
import
SearchAutocomplete
from
'
~/search_autocomplete
'
;
import
init
SearchAutocomplete
from
'
~/search_autocomplete
'
;
import
'
~/lib/utils/common_utils
'
;
import
'
~/lib/utils/common_utils
'
;
describe
(
'
Search autocomplete dropdown
'
,
()
=>
{
describe
(
'
Search autocomplete dropdown
'
,
()
=>
{
...
@@ -132,7 +132,7 @@ describe('Search autocomplete dropdown', () => {
...
@@ -132,7 +132,7 @@ describe('Search autocomplete dropdown', () => {
window
.
gon
.
current_user_id
=
userId
;
window
.
gon
.
current_user_id
=
userId
;
window
.
gon
.
current_username
=
userName
;
window
.
gon
.
current_username
=
userName
;
return
(
widget
=
new
SearchAutocomplete
());
return
(
widget
=
init
SearchAutocomplete
());
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
...
...
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