Commit c82691b7 authored by Jacob Schatz's avatar Jacob Schatz

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

parent 70eff78d
......@@ -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;
}
}
}
}
......
......@@ -171,7 +171,7 @@ class ProjectsController < ApplicationController
@project.reload
render json: {
html: view_to_html_string("projects/buttons/_star")
star_count: @project.star_count
}
end
......
- 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');
......
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