Simple clickable rating
var div = document.getElementById("myBasicRatingDefault");
var amtRating = new Askmethat.AskmethatRating(div, 2);
Simple clickable rating
var options = {
backgroundColor : "#e5e500",
hoverColor: "#ffff66",
fontClass: "fa fa-star",
minRating: 1,
maxRating: 5,
readonly: false,
step: Askmethat.AskmethatRatingSteps["OnePerOneStep"],
inputName: "MyRating"
};
var div = document.getElementById("myBasicRating");
var amtRating = new Askmethat.AskmethatRating(div, 2, options);
Multiple independant rating
var options = {
backgroundColor : "#e5e500",
hoverColor: "#ffff66",
fontClass: "fa fa-star",
minRating: 1,
maxRating: 5,
readonly: false,
step: Askmethat.AskmethatRatingSteps["OnePerOneStep"]
};
var div = document.getElementById("myFirstMultipleRating");
var amtRating1 = new Askmethat.AskmethatRating(div, 1, options);
var div = document.getElementById("mySecondMultipleRating");
var amtRating2 = new Askmethat.AskmethatRating(div, 2, options);
Rating using different fonts
var options1 =
{
fontClass: "fa fa-cloud"
};
var options2 =
{
fontClass: "octicon octicon-clippy",
};
var div = document.getElementById("myFontAwesomeRating");
var amtRating1 = new Askmethat.AskmethatRating(div, 1, options1);
var div = document.getElementById("myOcticonRating");
var amtRating2 = new Askmethat.AskmethatRating(div, 1, options2);
Using the three differents step available for rating
var decimalOpt =
{
step: Askmethat.AskmethatRatingSteps["DecimalStep"]
};
var halpOpt =
{
step: Askmethat.AskmethatRatingSteps["HalfStep"]
};
var FullOpt =
{
step: Askmethat.AskmethatRatingSteps["OnePerOneStep"]
};
var div = document.getElementById("minimalStepRating");
var amtRating1 = new Askmethat.AskmethatRating(div, 1.8, decimalOpt);
var div = document.getElementById("halfStepRating");
var amtRating2 = new Askmethat.AskmethatRating(div, 1.5, halpOpt);
var div = document.getElementById("fullStepRating");
var amtRating3 = new Askmethat.AskmethatRating(div, 1, FullOpt);
Rating at readonly have events disabled
var options =
{
readonly: true,
};
var div = document.getElementById("readonlyRating");
var amtRating = new Askmethat.AskmethatRating(div, 3.2, options);
Event fired when the value of the rating change
0
var options = {
backgroundColor : "#e5e500",
hoverColor: "#ffff66",
fontClass: "fa fa-star",
minRating: 0,
maxRating: 5,
readonly: false,
step: Askmethat.AskmethatRatingSteps["HalfStep"]
};
var changeDiv = document.getElementById("changeEventRating");
var amtRating = new Askmethat.AskmethatRating(div, 0, options);
changeDiv.addEventListener("amt-change", function(e){
document.getElementById("changeEventRatingValue").innerHTML = e.detail;
});
If you want to display rating statistics, you can use the rating popover to display them
//popover
var options = {
backgroundColor : "#e5e500",
hoverColor: "#ffff66",
fontClass: "fa fa-star",
minRating: 0,
maxRating: 5,
readonly: true,
step: Askmethat.AskmethatRatingSteps["HalfStep"],
popover: {
color: "#e5e500",
fontClass: "fa fa-star",
direction: 0,
values : [20,20,20,20,20]
}
};
var changeDiv = document.getElementById("popoverRating");
var amtRating = new Askmethat.AskmethatRating(changeDiv, 0, options);