Permalink
Browse files

added starsContainer div

  • Loading branch information...
1 parent af6ebca commit 805c1dc898a6899aa452861342a144eae80cdb32 @pilu committed May 5, 2008
Showing with 18 additions and 15 deletions.
  1. +8 −6 index.html
  2. +5 −5 javascripts/rating.js
  3. +5 −4 stylesheets/rating.css
View
@@ -16,7 +16,7 @@
alert(element.id + " - " + value)
},
labelTemplate: "#{rate} #{text}",
- resetDelay: 1
+ resetDelay: 0.1
});
});
</script>
@@ -27,11 +27,13 @@ <h3>Songs</h3>
<div class="song">
<span class="title">Song 1</span>
<div class="rating" id="rating_song_1">
- <div class="star on"></div>
- <div class="star on"></div>
- <div class="star"></div>
- <div class="star"></div>
- <div class="star"></div>
+ <div class="stars">
+ <div class="star on"></div>
+ <div class="star on"></div>
+ <div class="star"></div>
+ <div class="star"></div>
+ <div class="star"></div>
+ </div>
<div class="label">2</div>
</div>
</div>
View
@@ -42,12 +42,13 @@ var Ratable = Class.create({
initialize: function(element) {
this.element = element;
+ this.starsContainer = this.element.down('.stars');
this.options = Object.extend({
onRate: Prototype.emptyFunction,
labelClassName: 'label',
labelValues: ['bad', 'not bad', 'good', 'very good', 'excellent'],
labelTemplate: "#{text}",
- resetDelay: 0.2
+ resetDelay: 0.0
}, arguments[1] || {});
this.stars = new Array();
this.resettingTimeout = null;
@@ -60,9 +61,9 @@ var Ratable = Class.create({
this.element.select('.star').each(function(element) {
this.stars.push(new RatingStar(element, this));
}.bind(this));
- this.element.observe('mouseover', this.handleMouseOver.bind(this));
- this.element.observe('mouseout', this.handleMouseOut.bind(this));
- this.element.observe('click', this.handleClick.bind(this));
+ this.starsContainer.observe('mouseover', this.handleMouseOver.bind(this));
+ this.starsContainer.observe('mouseout', this.handleMouseOut.bind(this));
+ this.starsContainer.observe('click', this.handleClick.bind(this));
},
reset: function() {
@@ -139,7 +140,6 @@ var Rating = Class.create({
setup: function() {
$$('.' + this.options.className).each(function(element) {
- alert(element.id)
new Ratable(element, this.options);
}.bind(this));
}
View
@@ -1,18 +1,19 @@
-.rating {
+.rating .stars {
width: 50px;
height: 9px;
+ float: left;
}
-.rating .star {
+.rating .stars .star {
width: 10px;
height: 9px;
cursor: pointer;
background: transparent url('../images/stars.png') no-repeat 0 0;
float: left;
}
-.rating .star.on {
+.rating .stars .star.on {
background-position: 0 -9px;
}
-.rating.selected .star.on {
+.rating.selected .stars .star.on {
background-position: 0 -18px;
}

0 comments on commit 805c1dc

Please sign in to comment.