rating.js
3.49 KB
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
"use strict";
$(document).ready(function() {
function ratingEnable() {
$('#example-1to10').barrating('show', {
theme: 'bars-1to10',
});
$('#example-movie').barrating('show', {
theme: 'bars-movie'
});
$('#example-movie').barrating('set', 'Mediocre');
$('#example-square').barrating('show', {
theme: 'bars-square',
showValues: true,
showSelectedRating: false
});
$('#example-pill').barrating('show', {
theme: 'bars-pill',
initialRating: 'A',
showValues: true,
showSelectedRating: false,
allowEmpty: true,
emptyValue: '-- no rating selected --',
onSelect: function(value, text) {
alert('Selected rating: ' + value);
}
});
$('#example-reversed').barrating('show', {
theme: 'bars-reversed',
showSelectedRating: true,
reverse: true
});
$('#example-horizontal').barrating('show', {
theme: 'bars-horizontal',
reverse: true,
hoverState: false
});
$('#example-fontawesome').barrating({
theme: 'fontawesome-stars',
showSelectedRating: false
});
$('.rating-star').barrating({
theme: 'css-stars',
showSelectedRating: false
});
$('#example-bootstrap').barrating({
theme: 'bootstrap-stars',
showSelectedRating: false
});
var currentRating = $('#example-fontawesome-o').data('current-rating');
$('.stars-example-fontawesome-o .current-rating')
.find('span')
.html(currentRating);
$('.stars-example-fontawesome-o .clear-rating').on('click', function(event) {
event.preventDefault();
$('#example-fontawesome-o')
.barrating('clear');
});
$('#example-fontawesome-o').barrating({
theme: 'fontawesome-stars-o',
showSelectedRating: false,
initialRating: currentRating,
onSelect: function(value, text) {
if (!value) {
$('#example-fontawesome-o')
.barrating('clear');
} else {
$('.stars-example-fontawesome-o .current-rating')
.addClass('hidden');
$('.stars-example-fontawesome-o .your-rating')
.removeClass('hidden')
.find('span')
.html(value);
}
},
onClear: function(value, text) {
$('.stars-example-fontawesome-o')
.find('.current-rating')
.removeClass('hidden')
.end()
.find('.your-rating')
.addClass('hidden');
}
});
}
function ratingDisable() {
$('select').barrating('destroy');
}
$('.rating-enable').on('click',function(event) {
event.preventDefault();
ratingEnable();
$(this).addClass('deactivated');
$('.rating-disable').removeClass('deactivated');
});
$('.rating-disable').on('click',function(event) {
event.preventDefault();
ratingDisable();
$(this).addClass('deactivated');
$('.rating-enable').removeClass('deactivated');
});
ratingEnable();
});