Forum Moderators: open
var SingleStar = Class.create();
SingleStar.prototype = {
initialize: function(parent, index) {
this.parent = parent;
this.index = index;
if(debug) console.log('Creating star at index '+ this.index);
this.value = this.index * this.parent.options.multiplier;
if(debug) console.log('value '+ this.value);
this.element = document.createElement("div");
this.element.style.width = this.parent.options.width + "px";
this.element.style.height = this.parent.options.height + "px";
this.element.style.backgroundImage = "url(" + this.parent.options.sprite + ")";
this.element.style.backgroundPosition = (this.index == 0) ? "0 -" + this.parent.options.height * 3 +"px" : "0 0";
this.element.className = "standard_star";
this.element.style.cssFloat = this.parent.options.align;
if(!this.parent.options.showNull && this.index == 0) this.element.style.display = "none";
//
// this.element.onclick = handleclick (parent, index);
// LINE BELOW IS THE CODE I CANNOT FIGURE OUT
this.element.onclick = function () {this.parent.set(this.index)}.bind(this);
this.element.onmouseover = function() { this.parent.show(this.index); }.bind(this);
this.element.onmouseout = this.parent.reset.bind(this.parent);
if(debug) console.log('set onclick handler');
}
};
// Below is the solution I tried.
<!--
/* function handleclick(parent, index)
{
this.parent = parent;
this.index = index;
this.parent.set(this.index).bind(this);
showall();
return true;
};
*/
-->