rendered paste body/*
* Copyright dmitrizone 2007. All rights reserved
*/
function get_num(obj, v) {
if(obj.is(v + "-1")) {
pos = 1;
}
if(obj.is(v + "-2")) {
pos = 2;
}
if(obj.is(v + "-3")) {
pos = 3;
}
if(obj.is(v + "-4")) {
pos = 4;
}
if(obj.is(v + "-5")) {
pos = 5;
}
pos++;
return pos;
}
jQuery.fn.extend({
stars : function(e) {
radios = this;
$(radios).hide();
for(i = 1; i < 6; i++) {
$(e.container).append('<div class="'+ e.star +'-vote '+ e.star +'-vote-'+ i +'"><span class="left"> </span><span class="right"> </span></div>');
}
stars = e.container +' > '+ e.star;
$(stars).css("background-color", "#000");
//$(stars).css({background: "url(./stars/star_empty.gif) no-repeat #CCC", display: "inline", cursor: "pointer"});
$(stars + " > .right").css("width", "7");
$(stars + " > .left").css("width", "8");
$(stars + " > .left").mouseover(function() {
$(stars).css("background-image", "url(./stars/star_empty.gif)");
pos = get_num($(this).parent(), stars);
pos--;
for(var i = 0; i < pos; i++) {
$(stars +"-"+ i).css("background-image", "url(./stars/star_whole.gif)");
}
$(stars +"-"+ pos).css("background-image", "url(./stars/star_half.gif)");
});
$(stars +" > .right").mouseover(function() {
$(stars).css("background-image", "url(./stars/star_empty.gif)");
pos = get_num($(this).parent(), stars);
for(var i = 0; i < pos; i++) {
$(stars +"-"+ i).css("background-image", "url(./stars/star_whole.gif)");
}
});
$(stars).mouseout(function(){
$(stars).css("background-image", "url(./stars/star_empty.gif)");
pos = $(radios + "[@checked]").attr("value");
var y = pos.split(".");
var z = Number(y[0]);
if(pos == z) {
for(var y = 0; y < pos; y++) {
$(stars + "-" + y).css("background-image", "url(./stars/star_whole.gif)");
}
}
else {
for(var y = 0; y < z; y++) {
$(stars + "-" + y).css("background-image", "url(./stars/star_whole.gif)");
}
$(stars + "-" + z).css("background-image", "url(./stars/star_half.gif)");
}
});
$(stars + " > .right").click(function(){
$(sas).removeAttr("checked");
var num = get_num($(this).parent(), vote);
$(radios + "[@value="+ num +".0]").attr("checked", "checked");
});
$(stars + " > .left").click(function(){
$(radios).removeAttr("checked");
var num = get_num($(this).parent(), vote);
num = num - 1;
$(radios + "[@value="+ num +".5]").attr("checked", "checked");
});
},
});