Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added starsContainer div

  • Loading branch information...
commit 805c1dc898a6899aa452861342a144eae80cdb32 1 parent af6ebca
Andrea Franz authored
14  index.html
@@ -16,7 +16,7 @@
16 16
           alert(element.id + " - " + value)
17 17
         },
18 18
         labelTemplate: "#{rate} #{text}",
19  
-        resetDelay: 1
  19
+        resetDelay: 0.1
20 20
       });
21 21
     });
22 22
 	</script>
@@ -27,11 +27,13 @@
27 27
     <div class="song">
28 28
       <span class="title">Song 1</span>
29 29
       <div class="rating" id="rating_song_1">
30  
-        <div class="star on"></div>
31  
-        <div class="star on"></div>
32  
-        <div class="star"></div>
33  
-        <div class="star"></div>
34  
-        <div class="star"></div>
  30
+        <div class="stars">
  31
+          <div class="star on"></div>
  32
+          <div class="star on"></div>
  33
+          <div class="star"></div>
  34
+          <div class="star"></div>
  35
+          <div class="star"></div>
  36
+        </div>
35 37
         <div class="label">2</div>
36 38
       </div>
37 39
     </div>    
10  javascripts/rating.js
@@ -42,12 +42,13 @@ var Ratable = Class.create({
42 42
 
43 43
   initialize: function(element) {
44 44
     this.element = element;
  45
+    this.starsContainer = this.element.down('.stars');
45 46
     this.options = Object.extend({
46 47
       onRate: Prototype.emptyFunction,
47 48
       labelClassName: 'label',
48 49
       labelValues: ['bad', 'not bad', 'good', 'very good', 'excellent'],
49 50
       labelTemplate: "#{text}",
50  
-      resetDelay: 0.2
  51
+      resetDelay: 0.0
51 52
     }, arguments[1] || {});
52 53
     this.stars = new Array();
53 54
     this.resettingTimeout = null;
@@ -60,9 +61,9 @@ var Ratable = Class.create({
60 61
     this.element.select('.star').each(function(element) {
61 62
       this.stars.push(new RatingStar(element, this));      
62 63
     }.bind(this));
63  
-    this.element.observe('mouseover', this.handleMouseOver.bind(this));
64  
-    this.element.observe('mouseout', this.handleMouseOut.bind(this));
65  
-    this.element.observe('click', this.handleClick.bind(this));
  64
+    this.starsContainer.observe('mouseover', this.handleMouseOver.bind(this));
  65
+    this.starsContainer.observe('mouseout', this.handleMouseOut.bind(this));
  66
+    this.starsContainer.observe('click', this.handleClick.bind(this));
66 67
   },
67 68
   
68 69
   reset: function() {
@@ -139,7 +140,6 @@ var Rating = Class.create({
139 140
 
140 141
   setup: function() {
141 142
     $$('.' + this.options.className).each(function(element) {
142  
-      alert(element.id)
143 143
       new Ratable(element, this.options);
144 144
     }.bind(this));
145 145
   }
9  stylesheets/rating.css
... ...
@@ -1,18 +1,19 @@
1  
-.rating {
  1
+.rating .stars {
2 2
   width: 50px;
3 3
   height: 9px;
  4
+  float: left;
4 5
 }
5  
-.rating .star {
  6
+.rating .stars .star {
6 7
   width: 10px;
7 8
   height: 9px;
8 9
   cursor: pointer;
9 10
   background: transparent url('../images/stars.png') no-repeat 0 0;
10 11
   float: left;
11 12
 }	  
12  
-.rating .star.on {
  13
+.rating .stars  .star.on {
13 14
   background-position: 0 -9px;
14 15
 }
15 16
 
16  
-.rating.selected .star.on {
  17
+.rating.selected .stars .star.on {
17 18
   background-position: 0 -18px;
18 19
 }

0 notes on commit 805c1dc

Please sign in to comment.
Something went wrong with that request. Please try again.