-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0364437
commit 7624f99
Showing
28 changed files
with
299 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
$.fn.raty.defaults.half = false; | ||
$.fn.raty.defaults.halfShow = true; | ||
$.fn.raty.defaults.path = "/assets"; | ||
$.fn.raty.defaults.cancel = false; | ||
|
||
$(function(){ | ||
$(".star").each(function() { | ||
var $readonly = ($(this).attr('data-readonly') == 'true'); | ||
var $half = ($(this).attr('data-enable-half') == 'true'); | ||
var $halfShow = ($(this).attr('data-half-show') == 'true'); | ||
var $single = ($(this).attr('data-single') == 'true'); | ||
$(this).raty({ | ||
score: function() { | ||
return $(this).attr('data-rating') | ||
}, | ||
number: function() { | ||
return $(this).attr('data-star-count') | ||
}, | ||
half: $half, | ||
halfShow: $halfShow, | ||
single: $single, | ||
path: $(this).attr('data-star-path'), | ||
starOn: $(this).attr('data-star-on'), | ||
starOff: $(this).attr('data-star-off'), | ||
starHalf: $(this).attr('data-star-half'), | ||
cancel: $(this).attr('data-cancel'), | ||
cancelPlace: $(this).attr('data-cancel-place'), | ||
cancelHint: $(this).attr('data-cancel-hint'), | ||
cancelOn: $(this).attr('data-cancel-on'), | ||
cancelOff: $(this).attr('data-cancel-off'), | ||
noRatedMsg: $(this).attr('data-no-rated-message'), | ||
round: $(this).attr('data-round'), | ||
space: $(this).attr('data-space'), | ||
target: $(this).attr('data-target'), | ||
targetText: $(this).attr('data-target-text'), | ||
targetType: $(this).attr('data-target-type'), | ||
targetFormat: $(this).attr('data-target-format'), | ||
targetScoret: $(this).attr('data-target-score'), | ||
readOnly: $readonly, | ||
click: function(score, evt) { | ||
var _this = this; | ||
if (score == null) { score = 0; } | ||
$.post('<%= Rails.application.class.routes.url_helpers.rate_path %>', | ||
{ | ||
score: score, | ||
dimension: $(this).attr('data-dimension'), | ||
id: $(this).attr('data-id'), | ||
klass: $(this).attr('data-classname') | ||
}, | ||
function(data) { | ||
if(data) { | ||
// success code goes here ... | ||
|
||
if ($(_this).attr('data-disable-after-rate') == 'true') { | ||
$(_this).raty('set', { readOnly: true, score: score }); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class RaterController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
def create | ||
if user_signed_in? | ||
obj = params[:klass].classify.constantize.find(params[:id]) | ||
obj.rate params[:score].to_f, current_user, params[:dimension] | ||
|
||
render :json => true | ||
else | ||
render :json => false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class AverageCache < ActiveRecord::Base | ||
belongs_to :rater, :class_name => "User" | ||
belongs_to :rateable, :polymorphic => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class OverallAverage < ActiveRecord::Base | ||
belongs_to :rateable, :polymorphic => true | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Rate < ActiveRecord::Base | ||
belongs_to :rater, :class_name => "User" | ||
belongs_to :rateable, :polymorphic => true | ||
|
||
#attr_accessible :rate, :dimension | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class RatingCache < ActiveRecord::Base | ||
belongs_to :cacheable, :polymorphic => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.