Commit 011a7a32 authored by Jacob Schatz's avatar Jacob Schatz Committed by Jacob Schatz

adds starring and unstarring text to star button, also adds partial new styles

parent 7b50ab5c
...@@ -115,7 +115,6 @@ ...@@ -115,7 +115,6 @@
margin-left: 4px; margin-left: 4px;
.arrow { .arrow {
&:before { &:before {
content: ''; content: '';
display: inline-block; display: inline-block;
...@@ -165,6 +164,10 @@ ...@@ -165,6 +164,10 @@
background-image: none; background-image: none;
white-space: nowrap; white-space: nowrap;
margin: 0 11px 0px 4px; margin: 0 11px 0px 4px;
&:hover {
background: #FFF;
}
} }
} }
} }
......
...@@ -171,7 +171,7 @@ class ProjectsController < ApplicationController ...@@ -171,7 +171,7 @@ class ProjectsController < ApplicationController
@project.reload @project.reload
render json: { render json: {
html: view_to_html_string("projects/buttons/_star") star_count: @project.star_count
} }
end end
......
- if current_user - 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 = 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') = icon('star fw')
Star - if current_user.starred?(@project)
%span.starred Unstar
- else
%span Star
%div.count-with-arrow %div.count-with-arrow
%span.arrow %span.arrow
%span.count %span.count
...@@ -9,7 +12,19 @@ ...@@ -9,7 +12,19 @@
:javascript :javascript
$('.project-home-panel .toggle-star').on('ajax:success', function (e, data, status, xhr) { $('.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) { .on('ajax:error', function (e, xhr, status, error) {
new Flash('Star toggle failed. Try again later.', 'alert'); new Flash('Star toggle failed. Try again later.', 'alert');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment