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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d941aee4
Commit
d941aee4
authored
Feb 29, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create user_tabs.js.coffee
parent
99d75a27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
app/assets/javascripts/user_tabs.js.coffee
app/assets/javascripts/user_tabs.js.coffee
+58
-0
No files found.
app/assets/javascripts/user_tabs.js.coffee
0 → 100644
View file @
d941aee4
class
@
UserTabs
actions
:
[
'activity'
,
'groups'
,
'contributed'
,
'personal'
],
defaultAction
:
'activity'
,
constructor
:
->
# Store the `location` object, allowing for easier stubbing in tests
@
_location
=
location
@
bindEvents
()
bindEvents
:
->
$
(
document
).
on
'shown.bs.tab'
,
'.nav-links a[data-toggle="tab"]'
,
@
tabShown
tabShown
:
(
event
)
=>
$target
=
$
(
event
.
target
)
action
=
$target
.
data
(
'action'
)
source
=
$target
.
attr
(
'href'
)
@
loadTab
(
source
,
action
)
@
setCurrentAction
(
action
)
loadTab
:
(
source
,
action
)
->
@
_get
url
:
"
#{
source
}
.json"
success
:
(
data
)
=>
tabSelector
=
'div#'
+
action
document
.
querySelector
(
tabSelector
).
innerHTML
=
data
.
html
toggleLoading
:
(
status
)
->
$
(
'.loading-status .loading'
).
toggle
(
status
)
_get
:
(
options
)
->
defaults
=
{
beforeSend
:
=>
@
toggleLoading
(
true
)
complete
:
=>
@
toggleLoading
(
false
)
dataType
:
'json'
type
:
'GET'
}
options
=
$
.
extend
({},
defaults
,
options
)
$
.
ajax
(
options
)
setCurrentAction
:
(
action
)
->
# Remove possible actions from URL
regExp
=
new
RegExp
(
'
\/
('
+
@
actions
.
join
(
'|'
)
+
')(
\.
html)?
\/
?$'
)
new_state
=
@
_location
.
pathname
.
replace
(
regExp
,
''
)
# Append the new action if we're on a tab other than 'activity'
unless
action
==
@
defaultAction
new_state
+=
"/
#{
action
}
"
# Ensure parameters and hash come along for the ride
new_state
+=
@
_location
.
search
+
@
_location
.
hash
history
.
replaceState
{
turbolinks
:
true
,
url
:
new_state
},
document
.
title
,
new_state
new_state
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