star voting system for proposals

This commit is contained in:
differentreality 2013-08-16 12:46:49 +03:00
parent 2314d943e1
commit 834362491e
17 changed files with 157 additions and 3 deletions

View file

@ -142,7 +142,10 @@
%td
= link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id),
:method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!"
.row-fluid
= link_to "Votes (#{@event.voters.length})", "#", :id => "votes-link"
#votes-div
= render :partial => 'voting'
.row-fluid
= link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link"
#comments-div
@ -156,4 +159,4 @@
%br
- @comments.each do |comment|
%div
= raw format_comments(comment)
= raw format_comments(comment)

View file

@ -0,0 +1,47 @@
%table#myeventratings{:style=>"width: 20%"}
%tr
%td
%b You voted:
%td
- @conference.call_for_papers.rating.times do |counter|
- voted = @event.voted?(@event, current_user.person)
- if voted && voted.rating == counter+1
= link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating", :voted => true
- else
= link_to "", vote_admin_conference_event_path(@conference.short_title, @event, :rating => counter+1), :remote => true, :id =>"label#{counter+1}", :class => "myrating"
%br
- if @ratings.length > 0
- @ratings.each do |rate|
- unless rate.person_id == current_user.person.id
%tr
%td
= rate.first_name
= rate.last_name
%td
- @conference.call_for_papers.rating.times do |counter|
- voted = @event.voted?(@event, rate.person)
- if voted && voted.rating == counter+1
= label_tag "label#{counter+1}", "", :class => "othersrating", :voted => true
= javascript_tag "$('label[voted=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label#{counter+1}", "", :class => "othersrating"
:javascript
$(function () {
var checkedId = $("a[voted='true']").attr('id');
$('a[id=' + checkedId + ']').prevAll().andSelf().addClass('bright');
});
$(".myrating").hover(
function() { // mouseover
$(this).prevAll().andSelf().addClass('glow');
},
function() { // mouseout
$(this).siblings().andSelf().removeClass('glow');
}
);
$(".myrating").click(function() {
$(this).siblings().removeClass("bright");
$(this).prevAll().andSelf().addClass("bright");
});

View file

@ -115,6 +115,18 @@
= event.id
%td
=link_to event.title, admin_conference_event_path(@conference.short_title, event)
- if event.average_rating.to_f > 0
Rating: (#{event.average_rating}/#{@conference.call_for_papers.rating})
- else
Rating: (0/#{@conference.call_for_papers.rating})
- @conference.call_for_papers.rating.times do |counter|
- if event.average_rating.to_f.round == counter+1
= label_tag "label_rating", "", :class => "avgrating", :avgrate => true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label_rating", "", :class => "avgrating"
- if event.submitter.registrations.count < 1
- bgcolor="#F7819F"
- else

View file

@ -0,0 +1 @@
$('table#myeventratings').replaceWith("<%= escape_javascript(render :partial => 'voting') %>");