seems_rateable 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 455364eb31c4b61fd79908f70d62f34542f2b41c
4
- data.tar.gz: 4a6ec381afaebc84a93857d800b0b1e35ee70a3b
3
+ metadata.gz: 0eb8a1e5c55ccaff4c140702bdd45ae130ab3adb
4
+ data.tar.gz: 6e6172c3197be41dafd85972be9a6a453bf82e5e
5
5
  SHA512:
6
- metadata.gz: 2fa2e95394681b239bd15417c8c2f627acec5b0c4dedf60adfb3b9f379e836b39a54774e9e88ee3b16fcef6de218e2f09e2cb330900a41d04c1255242bc1ae8b
7
- data.tar.gz: efc3f581ccbc155769d104ce5b6de6b65398ecf7d26c5dc99c0fd833b3b66c8cc7e5a5d6cfeba647bfacec9f94964b79b0e63a5c2928146231b49759499278a1
6
+ metadata.gz: fcc9344aa5b330b35c220208a910929f3396a8cf579e4a56e63bc9d0c6dff2bb64b371135a23478ad6b0cd9dab1f7de1743eb32d91a0426762d9d1f8cd5a27ca
7
+ data.tar.gz: fc8d7526d7726c2b16f07b72f7e2794a6a716f4b945e92313c522812dc6c3c683c49b18db28aaface6fbd4159d4967a9ff654fdcba563b0adace5c40776a50d8
data/README.md CHANGED
@@ -76,7 +76,7 @@ And to object's raters e.g
76
76
  @object.raters(:quantity)
77
77
 
78
78
  To track user's given ratings add <code>seems_rateable_rater</code> to your rater model.
79
- If your rater class is not "User"(e.g "Client" or "Customer") change configuration in initializer generated by this engine
79
+ If your rater class is not "User"(e.g "Client" or "Customer") change configuration in initializer generated by this engine.
80
80
  Now you can access user's ratings by <code>@user.ratings_given</code>
81
81
 
82
82
  ### Usage
@@ -99,7 +99,7 @@ You can specify these options :
99
99
  <li><code>:id</code>ID of the div e.g <code>:id => "info"</code>, default nil</li>
100
100
  </ul>
101
101
 
102
- To edit the javascript options locate rateable.jquery.js file in /app/assets/javascripts/rateable/.
102
+ To edit the javascript options locate rateable.js file in /app/assets/javascripts/rateable/.
103
103
  The javascript options are explained directly in the file
104
104
 
105
105
  ## Contributing
@@ -1,48 +1,62 @@
1
- /*********************/
2
- /** jRating CSS **/
3
- /*********************/
4
-
5
- /**Div containing the color of the stars */
6
-
7
-
8
- .jRatingAverage {
9
- background-color:#f62929;
10
- position:relative;
11
- top:0;
12
- left:0;
13
- z-index:2;
14
- height:100%;
15
- }
16
- .jRatingColor {
17
- background-color:#FFD400; /* bgcolor of the stars*/
18
- position:relative;
19
- top:0;
20
- left:0;
21
- z-index:2;
22
- height:100%;
23
- }
24
-
25
- /** Div containing the stars **/
26
- .jStar {
27
- position:relative;
28
- left:0;
29
- z-index:3;
30
- }
31
-
32
- /** P containing the rate informations **/
33
- p.jRatingInfos {
34
- position: absolute;
35
- z-index:9999;
36
- background: transparent url('bg_jRatingInfos.png') no-repeat;
37
- color: #CACACA;
38
- display: none;
39
- width: 91px;
40
- height: 29px;
41
- font-size:16px;
42
- text-align:center;
43
- padding-top:5px;
44
- }
45
- p.jRatingInfos span.maxRate {
46
- color:#c9c9c9;
47
- font-size:14px;
48
- }
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
14
+
15
+ /*********************/
16
+ /** jRating CSS **/
17
+ /*********************/
18
+
19
+ /**Div containing the color of the stars */
20
+
21
+
22
+ .jRatingAverage {
23
+ background-color:#f62929;
24
+ position:relative;
25
+ top:0;
26
+ left:0;
27
+ z-index:2;
28
+ height:100%;
29
+ }
30
+ .jRatingColor {
31
+ background-color:#FFD400; /* bgcolor of the stars*/
32
+ position:relative;
33
+ top:0;
34
+ left:0;
35
+ z-index:2;
36
+ height:100%;
37
+ }
38
+
39
+ /** Div containing the stars **/
40
+ .jStar {
41
+ position:relative;
42
+ left:0;
43
+ z-index:3;
44
+ }
45
+
46
+ /** P containing the rate informations **/
47
+ p.jRatingInfos {
48
+ position: absolute;
49
+ z-index:9999;
50
+ background: transparent url('bg_jRatingInfos.png') no-repeat;
51
+ color: #CACACA;
52
+ display: none;
53
+ width: 91px;
54
+ height: 29px;
55
+ font-size:16px;
56
+ text-align:center;
57
+ padding-top:5px;
58
+ }
59
+ p.jRatingInfos span.maxRate {
60
+ color:#c9c9c9;
61
+ font-size:14px;
62
+ }
@@ -16,7 +16,7 @@ module SeemsRateable
16
16
  end
17
17
 
18
18
  def seems_rateable_stylesheet
19
- stylesheet_link_tag "seems_rateable"
19
+ stylesheet_link_tag "seems_rateable/application", media: "all", "data-turbolinks-track" => true
20
20
  end
21
21
 
22
22
  private
@@ -1,3 +1,3 @@
1
1
  module SeemsRateable
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seems_rateable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Toth
@@ -102,9 +102,8 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - app/views/layouts/seems_rateable/application.html.erb
105
- - app/assets/stylesheets/seems_rateable/index.css
105
+ - app/assets/stylesheets/seems_rateable/application.css
106
106
  - app/assets/javascripts/seems_rateable/application.js
107
- - app/assets/javascripts/seems_rateable/jRating.jquery.js.erb
108
107
  - app/assets/images/seems_rateable/stars.png
109
108
  - app/assets/images/seems_rateable/small.png
110
109
  - app/assets/images/seems_rateable/bg_jRatingInfos.png
@@ -122,13 +121,11 @@ files:
122
121
  - lib/generators/seems_rateable/install/templates/rates_migration.rb
123
122
  - lib/generators/seems_rateable/install/templates/cached_ratings_migration.rb
124
123
  - lib/generators/seems_rateable/install/templates/jRating.js.erb
125
- - lib/seems_rateable/version.rb~
126
124
  - lib/seems_rateable/version.rb
127
125
  - lib/seems_rateable/helpers.rb
128
126
  - lib/seems_rateable/routes.rb
129
127
  - lib/seems_rateable/errors.rb
130
128
  - lib/seems_rateable/engine.rb
131
- - lib/seems_rateable/helpers.rb~
132
129
  - lib/seems_rateable/model.rb
133
130
  - lib/tasks/seems_rateable_tasks.rake
134
131
  - MIT-LICENSE
@@ -1,225 +0,0 @@
1
- /************************************************************************
2
- *************************************************************************
3
- @Name : jRating - jQuery Plugin
4
- @Revison : 3.0
5
- @Date : 28/01/2013
6
- @Author: ALPIXEL - (www.myjqueryplugins.com - www.alpixel.fr)
7
- @License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php
8
-
9
- **************************************************************************
10
- *************************************************************************/
11
- (function($) {
12
- $.fn.jRating = function(op) {
13
- var defaults = {
14
- /** String vars **/
15
- bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png
16
- smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png
17
- path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
18
- type : 'big', // can be set to 'small' or 'big'
19
-
20
- /** Boolean vars **/
21
- step:false, // if true, mouseover binded star by star,
22
- isDisabled:false,
23
- showRateInfo: false,
24
- canRateAgain : false,
25
-
26
- /** Integer vars **/
27
- length:5, // number of star to display
28
- decimalLength : 0, // number of decimals.. Max 3, but you can complete the function 'getNote'
29
- rateMax : 20, // maximal rate - integer from 0 to 9999 (or more)
30
- rateInfosX : -45, // relative position in X axis of the info box when mouseover
31
- rateInfosY : 5, // relative position in Y axis of the info box when mouseover
32
- nbRates : 1,
33
-
34
- /** Functions **/
35
- onSuccess : null,
36
- onError : null
37
- };
38
-
39
- if(this.length>0)
40
- return this.each(function() {
41
- /*vars*/
42
- var opts = $.extend(defaults, op),
43
- newWidth = 0,
44
- starWidth = 0,
45
- starHeight = 0,
46
- bgPath = '',
47
- hasRated = false,
48
- globalWidth = 0,
49
- nbOfRates = opts.nbRates;
50
-
51
- if($(this).hasClass('jDisabled') || opts.isDisabled)
52
- var jDisabled = true;
53
- else
54
- var jDisabled = false;
55
-
56
- getStarWidth();
57
- $(this).height(starHeight);
58
-
59
-
60
-
61
- var average = parseFloat($(this).attr('data-average')), // get the average of all rates
62
- idBox = parseInt($(this).attr('data-id')), // get the id of the box
63
- kls = $(this).attr('data-kls'),
64
- dimension = $(this).attr('data-dimension'),
65
- widthRatingContainer = starWidth*opts.length, // Width of the Container
66
- widthColor = average/opts.rateMax*widthRatingContainer, // Width of the color Container
67
- quotient =
68
- $('<div>',
69
- {
70
- 'class' : 'jRatingColor',
71
- css:{
72
- width:widthColor
73
- }
74
- }).appendTo($(this)),
75
-
76
- average =
77
- $('<div>',
78
- {
79
- 'class' : 'jRatingAverage',
80
- css:{
81
- width:0,
82
- top:- starHeight
83
- }
84
- }).appendTo($(this)),
85
-
86
- jstar =
87
- $('<div>',
88
- {
89
- 'class' : 'jStar',
90
- css:{
91
- width:widthRatingContainer,
92
- height:starHeight,
93
- top:- (starHeight*2),
94
- background: 'url('+bgPath+') repeat-x'
95
- }
96
- }).appendTo($(this));
97
-
98
- $(this).css({width: widthRatingContainer,overflow:'hidden',zIndex:1,position:'relative'});
99
-
100
- if(!jDisabled)
101
- $(this).unbind().bind({
102
- mouseenter : function(e){
103
- var realOffsetLeft = findRealLeft(this);
104
- var relativeX = e.pageX - realOffsetLeft;
105
- if (opts.showRateInfo)
106
- var tooltip =
107
- $('<p>',{
108
- 'class' : 'jRatingInfos',
109
- html : getNote(relativeX)+' <span class="maxRate">/ '+opts.rateMax+'</span>',
110
- css : {
111
- top: (e.pageY + opts.rateInfosY),
112
- left: (e.pageX + opts.rateInfosX)
113
- }
114
- }).appendTo('body').show();
115
- },
116
- mouseover : function(e){
117
- $(this).css('cursor','pointer');
118
- },
119
- mouseout : function(){
120
- $(this).css('cursor','default');
121
- if(hasRated) average.width(globalWidth);
122
- else average.width(0);
123
- },
124
- mousemove : function(e){
125
- var realOffsetLeft = findRealLeft(this);
126
- var relativeX = e.pageX - realOffsetLeft;
127
- if(opts.step) newWidth = Math.floor(relativeX/starWidth)*starWidth + starWidth;
128
- else newWidth = relativeX;
129
- average.width(newWidth);
130
- if (opts.showRateInfo)
131
- $("p.jRatingInfos")
132
- .css({
133
- left: (e.pageX + opts.rateInfosX)
134
- })
135
- .html(getNote(newWidth) +' <span class="maxRate">/ '+opts.rateMax+'</span>');
136
- },
137
- mouseleave : function(){
138
- $("p.jRatingInfos").remove();
139
- },
140
- click : function(e){
141
- var element = this;
142
-
143
- /*set vars*/
144
- hasRated = true;
145
- globalWidth = newWidth;
146
- nbOfRates--;
147
-
148
- if(!opts.canRateAgain || parseInt(nbOfRates) <= 0) $(this).unbind().css('cursor','default').addClass('jDisabled');
149
-
150
- if (opts.showRateInfo) $("p.jRatingInfos").fadeOut('fast',function(){$(this).remove();});
151
- e.preventDefault();
152
- var rate = getNote(newWidth);
153
- average.width(newWidth);
154
-
155
-
156
- $.post(defaults.path,
157
- {
158
- idBox : idBox,
159
- rate : rate,
160
- kls : kls,
161
- dimension : dimension
162
- /** action : 'rating' **/
163
- },
164
- function(data) {
165
- if(!data.error)
166
- {
167
- /** Here you can display an alert box,
168
- or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
169
- exemple : */
170
- if(opts.onSuccess) opts.onSuccess( element, rate );
171
- }
172
- else
173
- {
174
-
175
- /** Here you can display an alert box,
176
- or use the jNotify Plugin :) http://www.myqjqueryplugins.com/jNotify
177
- exemple : */
178
- if(opts.onError) opts.onError( element, rate );
179
- }
180
- },
181
- 'json'
182
- );
183
- }
184
- });
185
-
186
- function getNote(relativeX) {
187
- var noteBrut = parseFloat((relativeX*100/widthRatingContainer)*opts.rateMax/100);
188
- switch(opts.decimalLength) {
189
- case 1 :
190
- var note = Math.round(noteBrut*10)/10;
191
- break;
192
- case 2 :
193
- var note = Math.round(noteBrut*100)/100;
194
- break;
195
- case 3 :
196
- var note = Math.round(noteBrut*1000)/1000;
197
- break;
198
- default :
199
- var note = Math.round(noteBrut*1)/1;
200
- }
201
- return note;
202
- };
203
-
204
- function getStarWidth(){
205
- switch(opts.type) {
206
- case 'small' :
207
- starWidth = 12; // width of the picture small.png
208
- starHeight = 10; // height of the picture small.png
209
- bgPath = opts.smallStarsPath;
210
- break;
211
- default :
212
- starWidth = 23; // width of the picture stars.png
213
- starHeight = 20; // height of the picture stars.png
214
- bgPath = opts.bigStarsPath;
215
- }
216
- };
217
-
218
- function findRealLeft(obj) {
219
- if( !obj ) return 0;
220
- return obj.offsetLeft + findRealLeft( obj.offsetParent );
221
- };
222
- });
223
-
224
- }
225
- })(jQuery);
@@ -1,27 +0,0 @@
1
- module SeemsRateable
2
- module Helpers
3
- def rating_for(obj, opts={})
4
- raise Errors::InvalidRateableObjectError unless obj.class.respond_to?(:rateable?)
5
-
6
- options = {
7
- :dimension => nil,
8
- :static => false,
9
- :class => 'rateable',
10
- :id => nil
11
- }.update(opts)
12
-
13
- content_tag :div, "", "data-average" => obj.average(options[:dimension]) ? obj.average(options[:dimension]).avg : 0, :id => options[:id],
14
- :class => "#{options[:class]}#{jdisabled?(options[:static])}",
15
- "data-id" => obj.id, "data-kls" => obj.class.name, "data-dimension" => options[:dimension]
16
- end
17
-
18
- def seems_rateable_stylesheet
19
- stylesheet_link_tag "seems_rateable/jRating.jquery"
20
- end
21
-
22
- private
23
- def jdisabled?(option)
24
- " jDisabled" if option || !current_user
25
- end
26
- end
27
- end
@@ -1,3 +0,0 @@
1
- module SeemsRateable
2
- VERSION = "1.0.7"
3
- end