rating_view_customize 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f6a008710ce0a8ea26a7bfd80b30028fa4bf0f9
4
- data.tar.gz: 577b75a95dc00c81d6ef49faf7d91236124a58dc
3
+ metadata.gz: 7c1b6647b093da706d63dd9f9437d21b9b11f926
4
+ data.tar.gz: 44127685d1bcf3c29d708359441801ce6b0dc845
5
5
  SHA512:
6
- metadata.gz: 682b8161acf7b4bcdd86055748e91efcff95d4efd042c9017203f5d83635dca26f7ac8ae3dad89bb420e6b5c747c2c7a696221dbc61f048a42a9033487160ecf
7
- data.tar.gz: 480830bee9baa9047c50b76b8345d685020ea594d6d19e585fcf0674d57f91591c273a85989a8a68242b215008ba5b05fdbec290f8f52296567684f21d8468d4
6
+ metadata.gz: bedda2d6e644d055c9d002eabf907d07a195ea0fdfab0906a05c71e07be8be1b2e2b9a1bd9e260d5eca9f53ad46ec2d8ce6d81d032739bb7a394641e9b747df2
7
+ data.tar.gz: 1aff6e9d4ec2024e02e025f6bc99a88f2a10fcf1a6afab5b6afd872dc1ff1c8858d19a9c751bc706136b6d4fe6a67d85eea5fdca61278133235e9a7ebeb484f3
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
  ## Installation
5
5
 
6
6
  Requires:
7
- Bootstrap 4
8
- jquery-rails
9
- font-awesome-rails
7
+ - Bootstrap 4
8
+ - jquery-rails
9
+ - font-awesome-rails
10
10
 
11
11
  Add this line to your application's Gemfile:
12
12
 
@@ -26,7 +26,8 @@ Or install it yourself as:
26
26
 
27
27
  Render view:
28
28
 
29
- ```<%= render "shared_rating/rating_partial", add_class_rating: "punctuality", default_checked: 3, show_half_star: false, disable_rating: false %>
29
+ ```ruby
30
+ <%= render "shared_rating/rating_partial", add_class_rating: "punctuality", default_checked: 3, show_half_star: false, disable_rating: false %>
30
31
  ```
31
32
  - add_class_rating: class of star
32
33
  - default_checked: default checked you want
@@ -0,0 +1,52 @@
1
+ // Use can customer font-size by
2
+ // .rating > label:before {
3
+ // margin: 5px;
4
+ // font-size: 1.6em;
5
+ // }
6
+
7
+ #custom_rating.not-active {
8
+ pointer-events: none;
9
+ cursor: default;
10
+ }
11
+ #custom_rating {
12
+ fieldset, label { margin: 0; padding: 0; }
13
+ body{ margin: 20px; }
14
+ h1 { font-size: 1.5em; margin: 10px; }
15
+
16
+ /****** Style Star Rating Widget *****/
17
+
18
+ .rating {
19
+ border: none;
20
+ float: left;
21
+ }
22
+
23
+ .rating > input { display: none; }
24
+ .rating > label:before {
25
+ margin: 5px;
26
+ font-size: 1.6em;
27
+ font-family: FontAwesome;
28
+ display: inline-block;
29
+ content: "\f005";
30
+ }
31
+
32
+ .rating > .half:before {
33
+ content: "\f089";
34
+ position: absolute;
35
+ }
36
+
37
+ .rating > label {
38
+ color: #ddd;
39
+ float: right;
40
+ }
41
+
42
+ /***** CSS Magic to Highlight Stars on Hover *****/
43
+
44
+ .rating > input:checked ~ label, /* show gold star when clicked */
45
+ .rating:not(:checked) > label:hover, /* hover current star */
46
+ .rating:not(:checked) > label:hover ~ label { color: #007676; } /* hover previous stars in list */
47
+
48
+ .rating > input:checked + label:hover, /* hover current star when changing rating */
49
+ .rating > input:checked ~ label:hover,
50
+ .rating > label:hover ~ input:checked ~ label, /* lighten current selection */
51
+ .rating > input:checked ~ label:hover ~ label { color: #006766; }
52
+ }
@@ -0,0 +1,48 @@
1
+ module RatingCustomizeHelper
2
+ def round_rating(number)
3
+ if number == 1
4
+ return number
5
+ elsif number > 1 && number < 2
6
+ return 1.5
7
+ elsif number == 2
8
+ return number
9
+ elsif number > 2 && number < 3
10
+ return 2.5
11
+ elsif number == 3
12
+ return number
13
+ elsif number > 3 && number < 4
14
+ return 3.5
15
+ elsif number == 4
16
+ return number
17
+ elsif number > 4 && number < 5
18
+ return 4.5
19
+ elsif number == 5
20
+ return number
21
+ else
22
+ return 0
23
+ end
24
+ end
25
+
26
+ def parse_id_rating(data)
27
+ case data
28
+ when 1
29
+ return "star1"
30
+ when 1.5
31
+ return "star1half"
32
+ when 2
33
+ return "star2"
34
+ when 2.5
35
+ return "star2half"
36
+ when 3
37
+ return "star3"
38
+ when 3.5
39
+ return "star3half"
40
+ when 4
41
+ return "star4"
42
+ when 4.5
43
+ return "star4half"
44
+ when 5
45
+ return "star5"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,44 @@
1
+ <div id="custom_rating" class="<%= 'not-active' if disable_rating == true%>">
2
+ <fieldset class="rating" style="margin-right: 5px;">
3
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star5" name="<%= add_class_rating.gsub(" ","") %>_rating" value="5">
4
+ <label class = "full" for="<%= add_class_rating.gsub(" ","") %>_star5" title="Awesome - 5 stars"></label>
5
+ <% if show_half_star == true %>
6
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star4half" name="<%= add_class_rating.gsub(" ","") %>_rating" value="4.5">
7
+ <label class="half" for="<%= add_class_rating.gsub(" ","") %>_star4half" title="Pretty good - 4.5 stars"></label>
8
+ <% end %>
9
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star4" name="<%= add_class_rating.gsub(" ","") %>_rating" value="4">
10
+ <label class = "full" for="<%= add_class_rating.gsub(" ","") %>_star4" title="Pretty good - 4 stars"></label>
11
+ <% if show_half_star == true %>
12
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star3half" name="<%= add_class_rating.gsub(" ","") %>_rating" value="3.5">
13
+ <label class="half" for="<%= add_class_rating.gsub(" ","") %>_star3half" title="Meh - 3.5 stars"></label>
14
+ <% end %>
15
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star3" name="<%= add_class_rating.gsub(" ","") %>_rating" value="3">
16
+ <label class = "full" for="<%= add_class_rating.gsub(" ","") %>_star3" title="Meh - 3 stars"></label>
17
+ <% if show_half_star == true %>
18
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star2half" name="<%= add_class_rating.gsub(" ","") %>_rating" value="2.5">
19
+ <label class="half" for="<%= add_class_rating.gsub(" ","") %>_star2half" title="Kinda bad - 2.5 stars"></label>
20
+ <% end %>
21
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star2" name="<%= add_class_rating.gsub(" ","") %>_rating" value="2">
22
+ <label class = "full" for="<%= add_class_rating.gsub(" ","") %>_star2" title="Kinda bad - 2 stars"></label>
23
+ <% if show_half_star == true %>
24
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star1half" name="<%= add_class_rating.gsub(" ","") %>_rating" value="1.5">
25
+ <label class="half" for="<%= add_class_rating.gsub(" ","") %>_star1half" title="Meh - 1.5 stars"></label>
26
+ <% end %>
27
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_star1" name="<%= add_class_rating.gsub(" ","") %>_rating" value="1">
28
+ <label class = "full" for="<%= add_class_rating.gsub(" ","") %>_star1" title="Sucks big time - 1 star"></label>
29
+ <% if show_half_star == true %>
30
+ <input type="radio" class="<%= add_class_rating.gsub(" ","") %>" id="<%= add_class_rating.gsub(" ","") %>_starhalf" name="<%= add_class_rating.gsub(" ","") %>_rating" value="0.5">
31
+ <label class="half" for="<%= add_class_rating.gsub(" ","") %>_starhalf" title="Sucks big time - 0.5 stars"></label>
32
+ <% end %>
33
+ </fieldset>
34
+ </div>
35
+
36
+ <script>
37
+ $("#custom_rating fieldset.rating input.<%= add_class_rating.gsub(" ","") %>").change(function(){
38
+ point = $(this).closest("fieldset.rating").find('input[name="<%= add_class_rating.gsub(" ","") %>_rating"]:checked').val();
39
+ $(this).closest("#point_selected").find("input#rating_<%= add_class_rating.gsub(" ","") %>").val(point);
40
+ });
41
+ if (<%= default_checked %> > 0) {
42
+ $("#<%= add_class_rating.gsub(" ","") %>_<%= parse_id_rating(default_checked) %>").attr("checked", true);
43
+ }
44
+ </script>
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+
3
+ module RatingViewCustomize
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ desc "This generator installs jQuery dataTables to the Asset Pipeline"
7
+ argument :style, :type => :string, :default => 'regular'
8
+
9
+ def add_assets
10
+ js_manifest = 'app/assets/javascripts/application.js'
11
+ css_manifest = 'app/assets/stylesheets/application.css'
12
+ end
13
+
14
+ private
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ # Configure for Rails 5
2
+ module Jquery
3
+ module Datatables
4
+ if defined?(::Rails) and Gem::Requirement.new('>= 5').satisfied_by?(Gem::Version.new ::Rails.version)
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module RatingViewCustomize
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
Binary file
@@ -11,8 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Rating view for rails using css.}
13
13
  spec.description = %q{}
14
- spec.homepage = "https://github.com/dboiii"
15
- spec.license = "MIT"
14
+ spec.homepage = "https://github.com/dboiii/rating_view_customize"
16
15
 
17
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
17
  # to allow pushing to a single host or delete this section to allow pushing to any host.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rating_view_customize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William
@@ -105,14 +105,19 @@ files:
105
105
  - Gemfile
106
106
  - README.md
107
107
  - Rakefile
108
+ - app/assets/stylesheets/lib_ratings/rating.scss
109
+ - app/helpers/rating_customize_helper.rb
110
+ - app/views/shared_rating/_rating_partial.html.erb
108
111
  - bin/console
109
112
  - bin/setup
113
+ - lib/generators/rating_view_customize/install_generator.rb
110
114
  - lib/rating_view_customize.rb
115
+ - lib/rating_view_customize/engine.rb
111
116
  - lib/rating_view_customize/version.rb
117
+ - rating_view_customize-0.1.0.gem
112
118
  - rating_view_customize.gemspec
113
- homepage: https://github.com/dboiii
114
- licenses:
115
- - MIT
119
+ homepage: https://github.com/dboiii/rating_view_customize
120
+ licenses: []
116
121
  metadata: {}
117
122
  post_install_message:
118
123
  rdoc_options: []