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
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
Hide 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 @@
...
@@ -50,11 +50,10 @@
# </div>
# </div>
#
#
class
@
UserTabs
class
@
UserTabs
actions
:
[
'activity'
,
'groups'
,
'contributed'
,
'projects'
],
defaultAction
:
'activity'
,
constructor
:
(
opts
)
->
constructor
:
(
opts
)
->
{
{
@
action
=
'activity'
@
action
=
'activity'
@
defaultAction
=
'activity'
@
parentEl
=
$
(
document
)
@
parentEl
=
$
(
document
)
}
=
opts
}
=
opts
...
@@ -63,16 +62,21 @@ class @UserTabs
...
@@ -63,16 +62,21 @@ class @UserTabs
# Store the `location` object, allowing for easier stubbing in tests
# Store the `location` object, allowing for easier stubbing in tests
@
_location
=
location
@
_location
=
location
# Set tab states
@
loaded
=
{}
@
loaded
=
{}
for
item
in
@
parentEl
.
find
(
'.nav-links a'
)
@
loaded
[
$
(
item
).
attr
'data-action'
]
=
false
@
bindEvents
()
# Actions
@
tabStateInit
()
@
actions
=
Object
.
keys
@
loaded
currAction
=
@
defaultAction
if
@
action
is
'show'
@
bindEvents
()
# Set active tab
# Set active tab
source
=
$
(
".
#{
currAction
}
-tab a"
).
attr
(
'href'
)
@
action
=
@
defaultAction
if
@
action
is
'show'
@
activateTab
(
currAction
)
source
=
$
(
".
#{
@
action
}
-tab a"
).
attr
(
'href'
)
@
activateTab
(
@
action
)
bindEvents
:
->
bindEvents
:
->
# Turn off existing event listeners
# Turn off existing event listeners
...
@@ -81,10 +85,6 @@ class @UserTabs
...
@@ -81,10 +85,6 @@ class @UserTabs
# Set event listeners
# Set event listeners
@
parentEl
.
on
'shown.bs.tab'
,
'.nav-links a[data-toggle="tab"]'
,
@
tabShown
@
parentEl
.
on
'shown.bs.tab'
,
'.nav-links a[data-toggle="tab"]'
,
@
tabShown
tabStateInit
:
->
for
action
in
@
actions
@
loaded
[
action
]
=
false
tabShown
:
(
event
)
=>
tabShown
:
(
event
)
=>
$target
=
$
(
event
.
target
)
$target
=
$
(
event
.
target
)
action
=
$target
.
data
(
'action'
)
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