-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathindex.html
311 lines (243 loc) · 6.61 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<DOCTYPE html>
<html>
<head>
<title>starRating, star rating jquery plugin</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
<link rel="stylesheet" type="text/css" href="../src/css/star-rating-svg.css">
<link rel="stylesheet" type="text/css" href="css/demo.css">
</head>
<body>
<div class="content">
<div class="logo">
<img src="img/star-rating-svg-logo.png" alt="star-rating-svg-logo" />
</div>
<h4>star-rating-svg.js</h4>
<div class="info"><a href="https://github.com/nashio/star-rating-svg/">Github</a> / v.1.3.0
<iframe src="https://ghbtns.com/github-btn.html?user=nashio&repo=star-rating-svg&type=star&count=true&size=medium" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
</div>
<h2>examples</h2>
<!-- example with label -->
<h4>Basic implementation</h4>
<div class="my-rating jq-stars"></div>
<pre class="pre-show prettyprint">
<div class="my-rating"></div>
</pre>
<pre class="pre-show prettyprint">
$(".my-rating").starRating({
initialRating: 4,
strokeColor: '#894A00',
strokeWidth: 10,
starSize: 25
});
</pre>
<hr>
<h4>Rounded star shape</h4>
<!-- example grabing rating from markup -->
<div class="my-rating-4" data-rating="2.5"></div>
<pre class="pre-show prettyprint">
<div> class="my-rating-4" data-rating="2.5"></div>
</pre>
<pre class="pre-show prettyprint">
$(".my-rating-4").starRating({
totalStars: 5,
starShape: 'rounded',
starSize: 40,
emptyColor: 'lightgray',
hoverColor: 'salmon',
activeColor: 'crimson',
useGradient: false
});
</pre>
<hr>
<h4>Use gradients</h4>
<!-- example using gradient -->
<div class="my-rating-5" data-rating="3.3"></div>
<pre class="pre-show prettyprint">
<div> class="my-rating-5"></div>
</pre>
<pre class="pre-show prettyprint">
// specify the gradient start and end for the selected stars
$(".my-rating-5").starRating({
starSize: 80,
strokeWidth: 9,
strokeColor: 'black',
initialRating: 2,
starGradient: {
start: '#93BFE2',
end: '#105694'
}
});
</pre>
<hr>
<h4>Execute callback when rating</h4>
<!-- example using callback -->
<div class="my-rating-6"></div>
<pre class="pre-show prettyprint">
<div> class="my-rating-6"></div>
</pre>
<pre class="pre-show prettyprint">
$(".my-rating-6").starRating({
totalStars: 5,
emptyColor: 'lightgray',
hoverColor: 'salmon',
activeColor: 'cornflowerblue',
initialRating: 4,
strokeWidth: 0,
useGradient: false,
minRating: 1,
callback: function(currentRating, $el){
alert('rated ', currentRating);
console.log('DOM element ', $el);
}
});
</pre>
<hr>
<h4>read only mode</h4>
<!-- example read-only -->
<div class="my-rating-7"></div>
<pre class="pre-show prettyprint">
<div> class="my-rating-7"></div>
</pre>
<pre class="pre-show prettyprint">
$(".my-rating-7").starRating({
readOnly: true
});
</pre>
<hr>
<!-- example fullstars -->
<h4>Use fullstars</h4>
<div class="my-rating-8"></div>
<pre class="pre-show prettyprint">
// use full stars only
<div> class="my-rating-8"></div>
</pre>
<pre class="pre-show prettyprint">
$(".my-rating-8").starRating({
useFullStars: true
});
</pre>
<hr>
<h4>On hover event</h4>
<pre class="pre-show prettyprint">
<span> class="my-rating-9"></span>
<span> class="live-rating"></span>
</pre>
<!-- example using callback -->
<span class="my-rating-9"></span>
<span class="live-rating"></span>
<pre class="pre-show prettyprint">
$(".my-rating-9").starRating({
initialRating: 3.5,
disableAfterRate: false,
onHover: function(currentIndex, currentRating, $el){
$('.live-rating').text(currentIndex);
},
onLeave: function(currentIndex, currentRating, $el){
$('.live-rating').text(currentRating);
}
});
</pre>
<h4>rating level colors</h4>
<!-- example using level colors -->
<div class="my-rating-10"></div>
<pre class="pre-show prettyprint">
<div> class="my-rating-10"></div>
</pre>
<pre class="pre-show prettyprint">
// specify the color per rating level
$(".my-rating-10").starRating({
starSize: 80,
strokeWidth: 9,
strokeColor: 'black',
ratedColors: ['#e2c181', '#ffa700', '#c4573e', '#9a321a', '#5e1e0f']
initialRating: 2,
});
</pre>
<hr>
<div class="options">
See options @ <a href="https://github.com/nashio/star-rating-svg/">github</a>
</div>
<script>
$(function() {
// basic use comes with defaults values
$(".my-rating").starRating({
initialRating: 4.0,
starSize: 25
});
$(".my-rating-2").starRating({
totalStars: 5,
starSize: 30,
starShape: 'rounded',
emptyColor: 'lightgray',
hoverColor: 'salmon',
activeColor: 'crimson',
useGradient: false
});
// example grabing rating from markup, and custom colors
$(".my-rating-4").starRating({
totalStars: 5,
starShape: 'rounded',
starSize: 40,
emptyColor: 'lightgray',
hoverColor: 'salmon',
activeColor: 'crimson',
useGradient: false
});
// specify the gradient start and end for the selected stars
$(".my-rating-5").starRating({
starSize: 80,
strokeWidth: 10,
strokeColor: 'black',
initialRating: 2,
starGradient: {
start: '#93BFE2',
end: '#105694'
},
});
$(".my-rating-6").starRating({
totalStars: 5,
emptyColor: 'lightgray',
hoverColor: 'slategray',
activeColor: 'cornflowerblue',
initialRating: 4,
strokeWidth: 0,
useGradient: false,
minRating: 2,
callback: function(currentRating, $el){
alert('rated ' + currentRating);
console.log('DOM Element ', $el);
}
});
$(".my-rating-7").starRating({
initialRating: 4,
readOnly: true,
starShape: 'rounded'
});
$(".my-rating-8").starRating({
useFullStars: true
});
$(".my-rating-9").starRating({
initialRating: 3.5,
disableAfterRate: false,
onHover: function(currentIndex, currentRating, $el){
console.log('index: ', currentIndex, 'currentRating: ', currentRating, ' DOM element ', $el);
$('.live-rating').text(currentIndex);
},
onLeave: function(currentIndex, currentRating, $el){
console.log('index: ', currentIndex, 'currentRating: ', currentRating, ' DOM element ', $el);
$('.live-rating').text(currentRating);
}
});
$(".my-rating-10").starRating({
initialRating: 2,
starSize: 80,
strokeWidth: 9,
strokeColor: 'black',
ratedColors: ['#e2c181', '#ffa700', '#c4573e', '#9a321a', '#5e1e0f']
});
});
</script>
<script src="../src/jquery.star-rating-svg.js"></script>
</body>
</html>