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
Tatuya Kamada
gitlab-ce
Commits
eed8b179
Commit
eed8b179
authored
Feb 29, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle default tab
parent
c6b27550
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
15 deletions
+43
-15
app/assets/javascripts/user_tabs.js.coffee
app/assets/javascripts/user_tabs.js.coffee
+43
-15
No files found.
app/assets/javascripts/user_tabs.js.coffee
View file @
eed8b179
class
@
UserTabs
actions
:
[
'activity'
,
'groups'
,
'contributed'
,
'personal'
],
defaultAction
:
'activity'
,
tabButtonSelector
:
'.nav-links a[data-toggle="tab"]'
constructor
:
->
constructor
:
(
@
opts
=
{})
->
# Store the `location` object, allowing for easier stubbing in tests
@
_location
=
location
@
loaded
=
{}
@
bindEvents
()
@
setTabState
()
# Set default tab
source
=
$
(
".
#{
@
defaultAction
}
-tab a"
).
attr
(
'href'
)
@
setTab
(
source
,
@
defaultAction
)
bindEvents
:
->
$
(
document
).
on
'shown.bs.tab'
,
'.nav-links a[data-toggle="tab"]'
,
@
tabShown
$
(
document
).
on
'shown.bs.tab'
,
@
tabButtonSelector
,
@
tabShown
setTabState
:
->
for
action
in
@
actions
@
loaded
[
action
]
=
false
tabShown
:
(
event
)
=>
$target
=
$
(
event
.
target
)
action
=
$target
.
data
(
'action'
)
source
=
$target
.
attr
(
'href'
)
@
load
Tab
(
source
,
action
)
@
set
Tab
(
source
,
action
)
@
setCurrentAction
(
action
)
setTab
:
(
source
,
action
)
->
return
if
@
loaded
[
action
]
is
true
if
action
is
'activity'
@
loadActivities
(
source
)
if
action
is
'groups'
@
loadTab
(
source
,
action
)
if
action
is
'contributed'
@
loadTab
(
source
,
action
)
if
action
is
'personal'
@
loadTab
(
source
,
action
)
loadTab
:
(
source
,
action
)
->
@
_get
$
.
ajax
beforeSend
:
=>
@
toggleLoading
(
true
)
complete
:
=>
@
toggleLoading
(
false
)
dataType
:
'json'
type
:
'GET'
url
:
"
#{
source
}
.json"
success
:
(
data
)
=>
tabSelector
=
'div#'
+
action
document
.
querySelector
(
tabSelector
).
innerHTML
=
data
.
html
@
loaded
[
action
]
=
true
toggleLoading
:
(
status
)
->
$
(
'.loading-status .loading'
).
toggle
(
status
)
loadActivities
:
(
source
)
->
return
if
@
loaded
[
'activity'
]
is
true
_get
:
(
options
)
->
defaults
=
{
beforeSend
:
=>
@
toggleLoading
(
true
)
complete
:
=>
@
toggleLoading
(
false
)
dataType
:
'json'
type
:
'GET'
}
$calendarWrap
=
$
(
'.user-calendar'
)
$calendarWrap
.
load
(
$calendarWrap
.
data
(
'url'
))
options
=
$
.
extend
({},
defaults
,
options
)
new
Activities
()
@
loaded
[
'activity'
]
=
true
$
.
ajax
(
options
)
toggleLoading
:
(
status
)
->
$
(
'.loading-status .loading'
).
toggle
(
status
)
setCurrentAction
:
(
action
)
->
# Remove possible actions from URL
...
...
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