-
Notifications
You must be signed in to change notification settings - Fork 78
/
index.html
127 lines (126 loc) · 5.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap rating</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap core CSS -->
<link href="bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<!-- Font Awesome CSS -->
<link href="bower_components/fontawesome/css/font-awesome.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="bootstrap-rating.css" rel="stylesheet">
<style>
.custom-heart {
font-size: 2.5em;
color: red;
}
</style>
</head>
<body>
<div class="survey-builder container">
<h2>Bootstrap rating</h2>
<hr/>
<h3>Default rating</h3>
<input type="hidden" class="rating"/>
<h3>Half rating</h3>
<input type="hidden" class="rating" data-fractions="2"/>
<h3>Disabled rating</h3>
<input type="hidden" class="rating" disabled="disabled"/>
<h3>Readonly rating with a value</h3>
<input type="hidden" class="rating" data-readonly value="3"/>
<h3>Readonly rating with a fractional value</h3>
<input type="hidden" class="rating" data-readonly value="2.5"/>
<h3>Customized heart rating</h3>
<input type="hidden" class="rating" data-filled="glyphicon glyphicon-heart custom-heart" data-empty="glyphicon glyphicon-heart-empty custom-heart"/>
<h3>Only fill selected</h3>
<input type="hidden" class="rating" data-filled="glyphicon glyphicon-heart-empty" data-filled-selected="glyphicon glyphicon-heart" data-empty="glyphicon glyphicon-heart-empty"/>
<h3>Handle events</h3>
<input type="hidden" class="rating check" data-filled="glyphicon glyphicon-check" data-empty="glyphicon glyphicon-unchecked"/>
<h3>Programmatically set/get rate</h3>
<input type="hidden" class="rating-tooltip" id="programmatically-rating">
<input type="number" id="programmatically-value">
<button type="button" id="programmatically-set">Set value</button>
<button type="button" id="programmatically-get">Get value</button>
<button type="button" id="programmatically-reset">Reset value</button>
<h3>Customize tooltips</h3>
<input type="hidden" class="rating-tooltip"/>
<h3>Set stop rate to 10 [1..10]</h3>
<input type="hidden" class="rating-tooltip" data-stop="10"/>
<h3>Set start rate to 5 [6..10]</h3>
<input type="hidden" class="rating-tooltip" data-start="5"/>
<h3>Set start and stop rate [2..10]</h3>
<input type="hidden" class="rating-tooltip" data-start="1" data-stop="10"/>
<h3>Set start and stop rate [2..10] with step 2</h3>
<input type="hidden" class="rating-tooltip" data-stop="10" data-step="2"/>
<h3>Set start and stop rate [-2..-10] with step -2</h3>
<input type="hidden" class="rating-tooltip" data-stop="-10" data-step="-2"/>
<h3>Font Awesome icons</h3>
<input type="hidden" class="rating-tooltip" data-filled="fa fa-bell fa-3x" data-empty="fa fa-bell-o fa-3x"/>
<h3>Fractional rating</h3>
<input type="hidden" class="rating-tooltip-manual" data-filled="fa fa-star fa-3x" data-empty="fa fa-star-o fa-3x" data-fractions="3"/>
<h3>Fractional right-to-left rating</h3>
<div dir="rtl">
<input type="hidden" class="rating-tooltip-manual" data-filled="fa fa-star fa-3x" data-empty="fa fa-star-o fa-3x" data-fractions="3"/>
</div>
<h3>Custom CSS icons</h3>
<input type="hidden" class="rating" data-filled="symbol symbol-filled" data-empty="symbol symbol-empty" data-fractions="2"/>
</div>
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/bootstrap/js/tooltip.js"></script>
<script type="text/javascript" src="bootstrap-rating.js"></script>
<script>
$(function () {
$('input.check').on('change', function () {
alert('Rating: ' + $(this).val());
});
$('#programmatically-set').click(function () {
$('#programmatically-rating').rating('rate', $('#programmatically-value').val());
});
$('#programmatically-get').click(function () {
alert($('#programmatically-rating').rating('rate'));
});
$('#programmatically-reset').click(function () {
$('#programmatically-rating').rating('rate', '');
});
$('.rating-tooltip').rating({
extendSymbol: function (rate) {
$(this).tooltip({
container: 'body',
placement: 'bottom',
title: 'Rate ' + rate
});
}
});
$('.rating-tooltip-manual').rating({
extendSymbol: function () {
var title;
$(this).tooltip({
container: 'body',
placement: 'bottom',
trigger: 'manual',
title: function () {
return title;
}
});
$(this).on('rating.rateenter', function (e, rate) {
title = rate;
$(this).tooltip('show');
})
.on('rating.rateleave', function () {
$(this).tooltip('hide');
});
}
});
$('.rating').each(function () {
$('<span class="label label-default"></span>')
.text($(this).val() || ' ')
.insertAfter(this);
});
$('.rating').on('change', function () {
$(this).next('.label').text($(this).val());
});
});
</script>
</body>
</html>