Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
271ef6e56814
Commit
271ef6e5
authored
Dec 18, 2015
by
Jacob Schatz
Browse files
adds starring and unstarring text to star button, also adds partial new styles
parent
f3c487622c1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/assets/stylesheets/pages/projects.scss
View file @
271ef6e5
...
...
@@ -115,7 +115,6 @@
margin-left
:
4px
;
.arrow
{
&
:before
{
content
:
''
;
display
:
inline-block
;
...
...
@@ -165,6 +164,10 @@
background-image
:
none
;
white-space
:
nowrap
;
margin
:
0
11px
0px
4px
;
&
:hover
{
background
:
#FFF
;
}
}
}
}
...
...
app/controllers/projects_controller.rb
View file @
271ef6e5
...
...
@@ -171,7 +171,7 @@
@project
.
reload
render
json:
{
html:
view_to_html_string
(
"projects/buttons/_star"
)
star_count:
@project
.
star_count
}
end
...
...
app/views/projects/buttons/_star.html.haml
View file @
271ef6e5
-
if
current_user
=
link_to
toggle_star_namespace_project_path
(
@project
.
namespace
,
@project
),
class:
'btn star-btn toggle-star has_tooltip'
,
method: :post
,
remote:
true
,
title:
"Star project"
do
=
icon
(
'star fw'
)
Star
-
if
current_user
.
starred?
(
@project
)
%span
.starred
Unstar
-
else
%span
Star
%div
.count-with-arrow
%span
.arrow
%span
.count
...
...
@@ -9,7 +12,19 @@
:javascript
$
(
'
.project-home-panel .toggle-star
'
).
on
(
'
ajax:success
'
,
function
(
e
,
data
,
status
,
xhr
)
{
$
(
this
).
replaceWith
(
data
.
html
);
var
$this
=
$
(
this
);
var
$starSpan
=
$this
.
find
(
'
span
'
);
$this
.
parent
()
.
find
(
'
span.count
'
)
.
text
(
data
.
star_count
);
if
(
$starSpan
.
hasClass
(
'
starred
'
)){
$starSpan
.
removeClass
(
'
starred
'
);
$starSpan
.
text
(
'
Star
'
);
}
else
{
$starSpan
.
addClass
(
'
starred
'
);
$starSpan
.
text
(
'
Unstar
'
);
}
})
.
on
(
'
ajax:error
'
,
function
(
e
,
xhr
,
status
,
error
)
{
new
Flash
(
'
Star toggle failed. Try again later.
'
,
'
alert
'
);
...
...
Write
Preview
Supports
Markdown
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