Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Clear Rating button and examples of its usage #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
<div class="rateyo"></div>
<div class="rateyo"></div>
<div class="rateyo"></div>

<div style="margin-top: 20px">
<div id="rateYoClearable" style="display: inline-block"></div>
<span id="rateYoClearableRating"></span>
</div>

<div>
<div id="rateYoClearableRtl" style="display: inline-block"></div>
<span id="rateYoClearableRtlRating"></span>
</div>
<script type="text/javascript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="../src/jquery.rateyo.js"></script>

Expand All @@ -42,7 +52,7 @@
precision: 2,
starWidth: "64px",
spacing: "5px",
rtl: true,
rtl: true,
multiColor: {

startColor: "#000000",
Expand Down Expand Up @@ -72,6 +82,41 @@

console.log(data.rating);
});

$("#rateYoClearable").rateYo({
rating: rating,
clearButton: true,
onInit: function () {
$("#rateYoClearableRating").html("Rating: " + rating);
},
}).on("rateyo.set", function (e, data) {
$("#rateYoClearableRating").html("Rating: " + (data.rating < 0 ? "cleared (-1)" : data.rating));
if (data.rating < 0) {
console.log("Rating cleared.");
}
}).on("rateyo.change", function (e, data) {
if (data.rating < 0) {
console.log("Clear rating?");
}
});

$("#rateYoClearableRtl").rateYo({
rating: rating,
clearButton: true,
rtl: true,
onInit: function () {
$("#rateYoClearableRtlRating").html("Rating: " + rating);
},
}).on("rateyo.set", function (e, data) {
$("#rateYoClearableRtlRating").html("Rating: " + (data.rating < 0 ? "cleared (-1)" : data.rating));
if (data.rating < 0) {
console.log("Rating cleared.");
}
}).on("rateyo.change", function (e, data) {
if (data.rating < 0) {
console.log("Clear rating?");
}
});
});
</script>
</body>
Expand Down
Loading