jrating
This commit is contained in:
parent
dd09c36a8f
commit
b4209b7cc5
1
Gemfile
1
Gemfile
|
@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
|
|||
gem 'rubyzip'
|
||||
gem 'zip-zip'
|
||||
end
|
||||
gem 'seems_rateable'
|
||||
gem "rails", "3.2.13"
|
||||
gem "jquery-rails", "~> 2.0.2"
|
||||
gem "i18n", "~> 0.6.0"
|
||||
|
|
|
@ -75,10 +75,13 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (>= 0.14.6, < 2.0)
|
||||
rake (10.0.4)
|
||||
rake (10.1.0)
|
||||
rdoc (3.12.2)
|
||||
json (~> 1.4)
|
||||
ruby-openid (2.1.8)
|
||||
seems_rateable (1.0.13)
|
||||
jquery-rails
|
||||
rails
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
|
@ -109,3 +112,4 @@ DEPENDENCIES
|
|||
rails (= 3.2.13)
|
||||
rdoc (>= 2.4.2)
|
||||
ruby-openid (~> 2.1.4)
|
||||
seems_rateable
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
require_dependency "seems_rateable/application_controller"
|
||||
|
||||
class RatingsController < ::ApplicationController
|
||||
def create
|
||||
raise NoCurrentUserInstanceError unless current_user
|
||||
|
||||
obj = params[:kls].classify.constantize.find(params[:idBox])
|
||||
begin
|
||||
obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
|
||||
render :json => true
|
||||
rescue Errors::AlreadyRatedError
|
||||
render :json => {:error => true}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
class Softapplication < ActiveRecord::Base
|
||||
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers
|
||||
acts_as_attachable
|
||||
seems_rateable :allow_update => true, :dimensions => :quality
|
||||
|
||||
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :contesting_softapplications, :dependent => :destroy
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
|
||||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
|
||||
<%= javascript_heads %>
|
||||
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
|
||||
<%= heads_for_theme %>
|
||||
<%= call_hook :view_layouts_base_html_head %>
|
||||
<!-- page specific tags -->
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
|
||||
<td>开发人员:<%= @softapplication.application_developers %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>平均评分: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
@ -64,7 +68,7 @@
|
|||
|
||||
<div style="height: 50px">
|
||||
<div style="font-size: 15px"><strong>软件评论:</strong></div>
|
||||
<div></div>
|
||||
<div>评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %></div>
|
||||
</div>
|
||||
|
||||
<!--提示登录后对应用进行评价-->
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
RedmineApp::Application.routes.draw do
|
||||
resources :ratings, :only => :create
|
||||
namespace :zipdown do
|
||||
match 'assort'
|
||||
end
|
||||
|
@ -506,18 +507,6 @@ RedmineApp::Application.routes.draw do
|
|||
match 'upload_avatar', :to => 'avatar#upload', :via => :post
|
||||
# Endof Tao's code
|
||||
get 'robots.txt', :to => 'welcome#robots'
|
||||
|
||||
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
|
||||
file = File.join(plugin_dir, "config/routes.rb")
|
||||
if File.exists?(file)
|
||||
begin
|
||||
instance_eval File.read(file)
|
||||
rescue Exception => e
|
||||
puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##############测试留言功能 fq
|
||||
post 'words/new', :to => 'words#new'
|
||||
|
@ -607,5 +596,16 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution'
|
||||
|
||||
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
|
||||
file = File.join(plugin_dir, "config/routes.rb")
|
||||
if File.exists?(file)
|
||||
begin
|
||||
instance_eval File.read(file)
|
||||
rescue Exception => e
|
||||
puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
get ':controller(/:action(/:id))'
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140417091429) do
|
||||
ActiveRecord::Schema.define(:version => 20140421044830) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
require_dependency "seems_rateable/application_controller"
|
||||
|
||||
module SeemsRateable
|
||||
class RatingsController < ::ApplicationController
|
||||
def create
|
||||
raise NoCurrentUserInstanceError unless current_user
|
||||
|
||||
obj = params[:kls].classify.constantize.find(params[:idBox])
|
||||
begin
|
||||
obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
|
||||
render :json => true
|
||||
rescue Errors::AlreadyRatedError
|
||||
render :json => {:error => true}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Binary file not shown.
After Width: | Height: | Size: 572 B |
Binary file not shown.
After Width: | Height: | Size: 427 B |
Binary file not shown.
After Width: | Height: | Size: 1018 B |
|
@ -12,13 +12,13 @@
|
|||
$.fn.jRating = function(op) {
|
||||
var defaults = {
|
||||
/** String vars **/
|
||||
bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png
|
||||
smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png
|
||||
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
|
||||
bigStarsPath : '/images/seems_rateable/stars.png', // path of the icon stars.png
|
||||
smallStarsPath : '/images/seems_rateable/small.png', // path of the icon small.png
|
||||
path : '/ratings',
|
||||
type : 'big', // can be set to 'small' or 'big'
|
||||
|
||||
/** Boolean vars **/
|
||||
step:false, // if true, mouseover binded star by star,
|
||||
step: true, // if true, mouseover binded star by star,
|
||||
isDisabled:false,
|
||||
showRateInfo: false,
|
||||
canRateAgain : false,
|
|
@ -11,7 +11,7 @@ $(document).ready(function(){
|
|||
//showRateInfo:false, //Rate info panel, set true to display
|
||||
//rateInfosX : 45, //In pixel - Absolute left position of the information box during mousemove.
|
||||
//rateInfosY : 5, //In pixel - Absolute top position of the information box during mousemove.
|
||||
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
|
||||
path : '/ratings',
|
||||
onSuccess : function(element, rate){
|
||||
//something like ->
|
||||
//alert('success');
|
||||
|
@ -21,5 +21,5 @@ $(document).ready(function(){
|
|||
$('<span class="text-error"><small style="display:inline-block;">You have already rated!</small></span>').insertAfter(element)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -5,6 +5,9 @@
|
|||
-moz-box-sizing: border-box;
|
||||
-box-sizing: border-box;
|
||||
}
|
||||
.div_inline{
|
||||
display: inline-block;
|
||||
}
|
||||
/*文字不换行*/
|
||||
.text_nowrap{
|
||||
word-break:keep-all;
|
||||
|
@ -65,7 +68,54 @@
|
|||
* {
|
||||
font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif;
|
||||
}
|
||||
/* 模态窗口
|
||||
*******************************************************************************/
|
||||
/** jRating CSS **/
|
||||
|
||||
/**Div containing the color of the stars */
|
||||
|
||||
|
||||
.jRatingAverage {
|
||||
background-color:#f62929;
|
||||
position:relative;
|
||||
top:0;
|
||||
left:0;
|
||||
z-index:2;
|
||||
height:100%;
|
||||
}
|
||||
.jRatingColor {
|
||||
background-color:#FFD400; /* bgcolor of the stars*/
|
||||
position:relative;
|
||||
top:0;
|
||||
left:0;
|
||||
z-index:2;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
/** Div containing the stars **/
|
||||
.jStar {
|
||||
position:relative;
|
||||
left:0;
|
||||
z-index:3;
|
||||
}
|
||||
|
||||
/** P containing the rate informations **/
|
||||
p.jRatingInfos {
|
||||
position: absolute;
|
||||
z-index:9999;
|
||||
background: transparent url('bg_jRatingInfos.png') no-repeat;
|
||||
color: #CACACA;
|
||||
display: none;
|
||||
width: 91px;
|
||||
height: 29px;
|
||||
font-size:16px;
|
||||
text-align:center;
|
||||
padding-top:5px;
|
||||
}
|
||||
p.jRatingInfos span.maxRate {
|
||||
color:#c9c9c9;
|
||||
font-size:14px;
|
||||
}
|
||||
/* 模态窗口
|
||||
*******************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue