<script type="text/javascript">
$(function(){
$("#avg").children().not(":input").hide();
$("#rat").children().not("select, #messages").hide();
// Create stars for: Average rating
$("#avg").stars();
// Create stars for: Rate this
$("#rat").stars({
inputType: "select",
cancelShow: false,
captionEl: $("#caption"),
oneVoteOnly: true,
callback: function(ui, type, value)
{
// Disable Stars while AJAX connection is active
ui.disable();
$("#caption").hide();
// Display message to the user at the begining of request
$("#messages").text("Saving:(" + value + ") ").stop().css("opacity", 1).fadeIn(30);
$.post("rating/com/rate.cfc?method=getRatings&returnformat=json", {rate: value, uid: 66}
, function(db)
{
// Select stars from "Average rating" control to match the returned average rating value
$("#avg").stars("select", Math.round(db.avg));
// Update other text controls...
$("#all_votes").text(db.votes);
$("#all_avg").text(db.avg);
// Display confirmation message to the user
$("#messages").text("Thank you!").stop().css("opacity", 1).fadeIn(30);
// Hide confirmation message and enable stars for "Rate this" control, after 2 sec...
setTimeout(function(){
$("#messages").fadeOut(500, function(){ui.enable()})
}, 2000);
setTimeout(function(){
$("#caption").fadeIn(2000, function(){ui.enable()})
}, 2000);
}, "json");
}
});
// Since the <option value="3"> was selected by default, we must remove selection from Stars.
$("#rat").stars("selectID", -1);
// Create element to use for confirmation messages
$('<div id="messages"/>').appendTo("#rat");
});
</script>
<div class="ratings">
<div id="rating-t" class="rating-t" align="left">
<form id="rat" name="rat" action="" method="post">
<select name="rate">
<option value="1" >Rate: 1</option>
<option value="2" >Rate: 2</option>
<option value="3" >Rate: 3</option>
<option value="4" >Rate: 4</option>
<option value="5" >Rate: 5</option>
</select>
<input type="hidden" value="66" name="uid">
<input type="submit" value="Rate it!" />
</form><span id="caption" style="display:inline"></span>
</div>
<div align="left" style="display:block">
<form id="avg" style="width: 200px">
<input type="radio" name="rate_avg" value="1" title="Rate 1" disabled="disabled">
<input type="radio" name="rate_avg" value="2" title="Rate 2" disabled="disabled">
<input type="radio" name="rate_avg" value="3" title="Rate 3" disabled="disabled">
<input type="radio" name="rate_avg" value="4" title="Rate 4" disabled="disabled" checked="checked">
<input type="radio" name="rate_avg" value="5" title="Rate 5" disabled="disabled">
</form>
<div class="rating-b" align="left">
<span>(<span id="all_votes">1 </span>ratings ,average<span id="all_avg">4</span>)</span>
</div>
</div>
|