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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
26175e44
Commit
26175e44
authored
Oct 28, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8127 from cirosantilli/user-select-js-only-needed
Run user select Js only where needed
parents
45d94469
2d187976
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
35 deletions
+43
-35
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+6
-0
app/assets/javascripts/project_users_select.js.coffee
app/assets/javascripts/project_users_select.js.coffee
+9
-10
app/assets/javascripts/users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+28
-25
No files found.
app/assets/javascripts/dispatcher.js.coffee
View file @
26175e44
...
...
@@ -62,6 +62,7 @@ class Dispatcher
new
TeamMembers
()
when
'groups:members'
new
GroupMembers
()
new
UsersSelect
()
when
'groups:new'
,
'groups:edit'
,
'admin:groups:edit'
new
GroupAvatar
()
when
'projects:tree:show'
...
...
@@ -83,6 +84,8 @@ class Dispatcher
when
'admin'
new
Admin
()
switch
path
[
1
]
when
'groups'
new
UsersSelect
()
when
'projects'
new
NamespaceSelect
()
when
'dashboard'
...
...
@@ -99,6 +102,8 @@ class Dispatcher
new
ProjectNew
()
when
'show'
new
ProjectShow
()
when
'issues'
,
'merge_requests'
new
ProjectUsersSelect
()
when
'wikis'
new
Wikis
()
shortcut_handler
=
new
ShortcutsNavigation
()
...
...
@@ -107,6 +112,7 @@ class Dispatcher
shortcut_handler
=
new
ShortcutsNavigation
()
when
'team_members'
,
'deploy_keys'
,
'hooks'
,
'services'
,
'protected_branches'
shortcut_handler
=
new
ShortcutsNavigation
()
new
UsersSelect
()
# If we haven't installed a custom shortcut handler, install the default one
...
...
app/assets/javascripts/project_users_select.js.coffee
View file @
26175e44
@
projectUsersSelect
=
init
:
->
$
(
'.ajax-project-users-select'
).
each
(
i
,
select
)
-
>
class
@
ProjectUsersSelect
constructor
:
->
$
(
'.ajax-project-users-select'
).
each
(
i
,
select
)
=
>
project_id
=
$
(
select
).
data
(
'project-id'
)
||
$
(
'body'
).
data
(
'project-id'
)
$
(
select
).
select2
...
...
@@ -28,14 +28,16 @@
Api
.
user
(
id
,
callback
)
formatResult
:
projectUsersSelect
.
projectUserFormatResult
formatSelection
:
projectUsersSelect
.
projectUserFormatSelection
formatResult
:
(
args
...)
=>
@
formatResult
(
args
...)
formatSelection
:
(
args
...)
=>
@
formatSelection
(
args
...)
dropdownCssClass
:
"ajax-project-users-dropdown"
dropdownAutoWidth
:
true
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
m
projectUserF
ormatResult
:
(
user
)
->
f
ormatResult
:
(
user
)
->
if
user
.
avatar_url
avatar
=
user
.
avatar_url
else
...
...
@@ -52,8 +54,5 @@
<div class='user-username'>
#{
user
.
username
}
</div>
</div>"
projectUserF
ormatSelection
:
(
user
)
->
f
ormatSelection
:
(
user
)
->
user
.
name
$
->
projectUsersSelect
.
init
()
app/assets/javascripts/users_select.js.coffee
View file @
26175e44
$
->
userFormatResult
=
(
user
)
->
if
user
.
avatar_url
avatar
=
user
.
avatar_url
else
avatar
=
gon
.
default_avatar_url
"<div class='user-result'>
<div class='user-image'><img class='avatar s24' src='
#{
avatar
}
'></div>
<div class='user-name'>
#{
user
.
name
}
</div>
<div class='user-username'>
#{
user
.
username
}
</div>
</div>"
userFormatSelection
=
(
user
)
->
user
.
name
$
(
'.ajax-users-select'
).
each
(
i
,
select
)
->
class
@
UsersSelect
constructor
:
->
$
(
'.ajax-users-select'
).
each
(
i
,
select
)
=>
$
(
select
).
select2
placeholder
:
"Search for a user"
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
...
...
@@ -30,8 +16,25 @@ $ ->
Api
.
user
(
id
,
callback
)
formatResult
:
userFormatResult
formatSelection
:
userFormatSelection
formatResult
:
(
args
...)
=>
@
formatResult
(
args
...)
formatSelection
:
(
args
...)
=>
@
formatSelection
(
args
...)
dropdownCssClass
:
"ajax-users-dropdown"
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
m
formatResult
:
(
user
)
->
if
user
.
avatar_url
avatar
=
user
.
avatar_url
else
avatar
=
gon
.
default_avatar_url
"<div class='user-result'>
<div class='user-image'><img class='avatar s24' src='
#{
avatar
}
'></div>
<div class='user-name'>
#{
user
.
name
}
</div>
<div class='user-username'>
#{
user
.
username
}
</div>
</div>"
formatSelection
:
(
user
)
->
user
.
name
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