mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-23 03:26:07 +10:00
Moves star code to a class
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
class @Star
|
||||
constructor: ->
|
||||
$('.project-home-panel .toggle-star').on('ajax:success', (e, data, status, xhr) ->
|
||||
$this = $(this)
|
||||
$starSpan = $this.find('span')
|
||||
$starIcon = $this.find('i')
|
||||
|
||||
toggleStar = (isStarred) ->
|
||||
$this.parent().find('span.count').text data.star_count
|
||||
if isStarred
|
||||
$starSpan.removeClass('starred').text 'Star'
|
||||
$starIcon.removeClass('fa-star').addClass 'fa-star-o'
|
||||
else
|
||||
$starSpan.addClass('starred').text 'Unstar'
|
||||
$starIcon.removeClass('fa-star-o').addClass 'fa-star'
|
||||
return
|
||||
|
||||
toggleStar $starSpan.hasClass('starred')
|
||||
return
|
||||
).on 'ajax:error', (e, xhr, status, error) ->
|
||||
new Flash('Star toggle failed. Try again later.', 'alert')
|
||||
return
|
||||
@@ -38,3 +38,6 @@
|
||||
= render 'projects/buttons/dropdown'
|
||||
|
||||
= render 'projects/buttons/notifications'
|
||||
|
||||
:coffeescript
|
||||
new Star()
|
||||
@@ -11,41 +11,6 @@
|
||||
%span.count.star-count
|
||||
= @project.star_count
|
||||
|
||||
:javascript
|
||||
$('.project-home-panel .toggle-star').on('ajax:success', function (e, data, status, xhr) {
|
||||
var $this = $(this);
|
||||
var $starSpan = $this.find('span');
|
||||
var $starIcon = $this.find('i');
|
||||
|
||||
var toggleStar = function(isStarred) {
|
||||
$this
|
||||
.parent()
|
||||
.find('span.count')
|
||||
.text(data.star_count);
|
||||
if(isStarred){
|
||||
$starSpan
|
||||
.removeClass('starred')
|
||||
.text('Star');
|
||||
$starIcon
|
||||
.removeClass('fa-star')
|
||||
.addClass('fa-star-o');
|
||||
|
||||
} else {
|
||||
$starSpan
|
||||
.addClass('starred')
|
||||
.text('Unstar');
|
||||
$starIcon
|
||||
.removeClass('fa-star-o')
|
||||
.addClass('fa-star');
|
||||
}
|
||||
};
|
||||
|
||||
toggleStar($starSpan.hasClass('starred'));
|
||||
})
|
||||
.on('ajax:error', function (e, xhr, status, error) {
|
||||
new Flash('Star toggle failed. Try again later.', 'alert');
|
||||
});
|
||||
|
||||
- else
|
||||
= link_to new_user_session_path, class: 'btn has_tooltip star-btn', title: 'You must sign in to star a project' do
|
||||
= icon('star fw')
|
||||
|
||||
@@ -31,7 +31,7 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
|
||||
end
|
||||
|
||||
step 'Remote url should update to http link' do
|
||||
expect(page).to have_content Project.last.http_url_to_repo
|
||||
expect(page).to have_content "git remote add origin #{Project.last.http_url_to_repo}"
|
||||
end
|
||||
|
||||
step 'If I click on SSH' do
|
||||
@@ -40,6 +40,6 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
|
||||
end
|
||||
|
||||
step 'Remote url should update to ssh link' do
|
||||
expect(page).to have_content Project.last.ssh_url_to_repo
|
||||
expect(page).to have_content "git remote add origin #{Project.last.url_to_repo}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user