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
Kazuhiko Shiozaki
gitlab-ce
Commits
bb1eb4b5
Commit
bb1eb4b5
authored
Mar 02, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set actions dinamically and offer defaultAction as a optional parameter
parent
3c9e860f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
app/assets/javascripts/user_tabs.js.coffee
app/assets/javascripts/user_tabs.js.coffee
+11
-11
No files found.
app/assets/javascripts/user_tabs.js.coffee
View file @
bb1eb4b5
...
...
@@ -50,11 +50,10 @@
# </div>
#
class
@
UserTabs
actions
:
[
'activity'
,
'groups'
,
'contributed'
,
'projects'
],
defaultAction
:
'activity'
,
constructor
:
(
opts
)
->
{
@
action
=
'activity'
@
defaultAction
=
'activity'
@
parentEl
=
$
(
document
)
}
=
opts
...
...
@@ -63,16 +62,21 @@ class @UserTabs
# Store the `location` object, allowing for easier stubbing in tests
@
_location
=
location
# Set tab states
@
loaded
=
{}
for
item
in
@
parentEl
.
find
(
'.nav-links a'
)
@
loaded
[
$
(
item
).
attr
'data-action'
]
=
false
@
bindEvents
()
@
tabStateInit
()
# Actions
@
actions
=
Object
.
keys
@
loaded
currAction
=
@
defaultAction
if
@
action
is
'show'
@
bindEvents
()
# Set active tab
source
=
$
(
".
#{
currAction
}
-tab a"
).
attr
(
'href'
)
@
activateTab
(
currAction
)
@
action
=
@
defaultAction
if
@
action
is
'show'
source
=
$
(
".
#{
@
action
}
-tab a"
).
attr
(
'href'
)
@
activateTab
(
@
action
)
bindEvents
:
->
# Turn off existing event listeners
...
...
@@ -81,10 +85,6 @@ class @UserTabs
# Set event listeners
@
parentEl
.
on
'shown.bs.tab'
,
'.nav-links a[data-toggle="tab"]'
,
@
tabShown
tabStateInit
:
->
for
action
in
@
actions
@
loaded
[
action
]
=
false
tabShown
:
(
event
)
=>
$target
=
$
(
event
.
target
)
action
=
$target
.
data
(
'action'
)
...
...
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