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
iv
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
...
@@ -62,6 +62,7 @@ class Dispatcher
new
TeamMembers
()
new
TeamMembers
()
when
'groups:members'
when
'groups:members'
new
GroupMembers
()
new
GroupMembers
()
new
UsersSelect
()
when
'groups:new'
,
'groups:edit'
,
'admin:groups:edit'
when
'groups:new'
,
'groups:edit'
,
'admin:groups:edit'
new
GroupAvatar
()
new
GroupAvatar
()
when
'projects:tree:show'
when
'projects:tree:show'
...
@@ -83,6 +84,8 @@ class Dispatcher
...
@@ -83,6 +84,8 @@ class Dispatcher
when
'admin'
when
'admin'
new
Admin
()
new
Admin
()
switch
path
[
1
]
switch
path
[
1
]
when
'groups'
new
UsersSelect
()
when
'projects'
when
'projects'
new
NamespaceSelect
()
new
NamespaceSelect
()
when
'dashboard'
when
'dashboard'
...
@@ -99,6 +102,8 @@ class Dispatcher
...
@@ -99,6 +102,8 @@ class Dispatcher
new
ProjectNew
()
new
ProjectNew
()
when
'show'
when
'show'
new
ProjectShow
()
new
ProjectShow
()
when
'issues'
,
'merge_requests'
new
ProjectUsersSelect
()
when
'wikis'
when
'wikis'
new
Wikis
()
new
Wikis
()
shortcut_handler
=
new
ShortcutsNavigation
()
shortcut_handler
=
new
ShortcutsNavigation
()
...
@@ -107,6 +112,7 @@ class Dispatcher
...
@@ -107,6 +112,7 @@ class Dispatcher
shortcut_handler
=
new
ShortcutsNavigation
()
shortcut_handler
=
new
ShortcutsNavigation
()
when
'team_members'
,
'deploy_keys'
,
'hooks'
,
'services'
,
'protected_branches'
when
'team_members'
,
'deploy_keys'
,
'hooks'
,
'services'
,
'protected_branches'
shortcut_handler
=
new
ShortcutsNavigation
()
shortcut_handler
=
new
ShortcutsNavigation
()
new
UsersSelect
()
# If we haven't installed a custom shortcut handler, install the default one
# 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
=
class
@
ProjectUsersSelect
init
:
->
constructor
:
->
$
(
'.ajax-project-users-select'
).
each
(
i
,
select
)
-
>
$
(
'.ajax-project-users-select'
).
each
(
i
,
select
)
=
>
project_id
=
$
(
select
).
data
(
'project-id'
)
||
$
(
'body'
).
data
(
'project-id'
)
project_id
=
$
(
select
).
data
(
'project-id'
)
||
$
(
'body'
).
data
(
'project-id'
)
$
(
select
).
select2
$
(
select
).
select2
...
@@ -28,14 +28,16 @@
...
@@ -28,14 +28,16 @@
Api
.
user
(
id
,
callback
)
Api
.
user
(
id
,
callback
)
formatResult
:
projectUsersSelect
.
projectUserFormatResult
formatResult
:
(
args
...)
=>
formatSelection
:
projectUsersSelect
.
projectUserFormatSelection
@
formatResult
(
args
...)
formatSelection
:
(
args
...)
=>
@
formatSelection
(
args
...)
dropdownCssClass
:
"ajax-project-users-dropdown"
dropdownCssClass
:
"ajax-project-users-dropdown"
dropdownAutoWidth
:
true
dropdownAutoWidth
:
true
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
m
m
projectUserF
ormatResult
:
(
user
)
->
f
ormatResult
:
(
user
)
->
if
user
.
avatar_url
if
user
.
avatar_url
avatar
=
user
.
avatar_url
avatar
=
user
.
avatar_url
else
else
...
@@ -52,8 +54,5 @@
...
@@ -52,8 +54,5 @@
<div class='user-username'>
#{
user
.
username
}
</div>
<div class='user-username'>
#{
user
.
username
}
</div>
</div>"
</div>"
projectUserF
ormatSelection
:
(
user
)
->
f
ormatSelection
:
(
user
)
->
user
.
name
user
.
name
$
->
projectUsersSelect
.
init
()
app/assets/javascripts/users_select.js.coffee
View file @
26175e44
$
->
class
@
UsersSelect
userFormatResult
=
(
user
)
->
constructor
:
->
if
user
.
avatar_url
$
(
'.ajax-users-select'
).
each
(
i
,
select
)
=>
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
)
->
$
(
select
).
select2
$
(
select
).
select2
placeholder
:
"Search for a user"
placeholder
:
"Search for a user"
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
multiple
:
$
(
select
).
hasClass
(
'multiselect'
)
...
@@ -30,8 +16,25 @@ $ ->
...
@@ -30,8 +16,25 @@ $ ->
Api
.
user
(
id
,
callback
)
Api
.
user
(
id
,
callback
)
formatResult
:
userFormatResult
formatResult
:
(
args
...)
=>
formatSelection
:
userFormatSelection
@
formatResult
(
args
...)
formatSelection
:
(
args
...)
=>
@
formatSelection
(
args
...)
dropdownCssClass
:
"ajax-users-dropdown"
dropdownCssClass
:
"ajax-users-dropdown"
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
escapeMarkup
:
(
m
)
->
# we do not want to escape markup since we are displaying html in results
m
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