index.html
20.4 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
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>jQuery Raty - A Star Rating Plugin</title>
<script type="text/javascript" src="js/jquery.min_wev8.js"></script>
<script type="text/javascript" src="js/jquery.raty.min_wev8.js"></script>
<style type="text/css">
/* This CSS does not belong to the plugin. */
body { background: url('img/background_wev8.gif'); font: normal 11px verdana; }
a { color: #2C8CBD; text-decoration: none; }
a:hover { color: #48A5D4; }
a#coffee {
background: url('img/coffee_wev8.png') 6px 2px no-repeat #DC5; border: 1px solid #D9C640; color: #FFF; display: block; float: right; font-size: 10px; font-weight: bold; letter-spacing: .9px; margin-right: 9px; padding: 4px 5px 4px 26px; text-decoration: none;
-khtml-border-radius: 4px; -moz-border-radius: 4px; -opera-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
}
a#coffee:hover { text-decoration: underline; }
span.comment { color: #999; font: 12px monospace; letter-spacing: .1px; margin-bottom: 7px; margin-top: 5px; }
div#content { background-color: #FFF; border: 1px solid #DEDEDE; box-shadow: 0 1px 3px rgba(100, 100, 100, 0.4); margin: 0 auto; padding: 15px; width: 1100px; min-height: 510px; }
div.description { color: #555; letter-spacing: .1px; margin-bottom: 15px; margin-top: 10px; text-align: left; }
div.description-code { color: #555; letter-spacing: .1px; margin-bottom: 10px; text-indent: 7px; }
div#footer { clear: both; height: 25px; margin-top: 5px; width: 100%; }
div#footer div#copy { margin: 0 auto; text-align: center; width: 1100px; }
div#header { margin: 0 auto; padding-left: 20px; width: 1130px; }
div#menu { color: #AB9927; font: bold 14px 'Lucida Grande', 'Helvetica', 'Times New Roman', serif; text-shadow: 1px 1px 1px #FFF; text-transform: uppercase; }
div#menu a { color: #EA9C00; font: bold 10px verdana; letter-spacing: .9px; text-decoration: none; }
div#menu a:hover { color: #DC5; font-weight: bold; letter-spacing: .9px; text-decoration: underline; }
div.session { font: bold 13px verdana; border-bottom: 1px solid #EFEFEF; color: #444; letter-spacing: .7px; margin-bottom: 18px; margin-top: 24px; text-align: left; }
div.session-first { font: bold 13px verdana; border-bottom: 1px solid #EFEFEF; color: #444; letter-spacing: .7px; margin-bottom: 18px; text-align: left; }
div.session-mini { font: bold 10px verdana; color: #444; letter-spacing: .7px; margin-top: 17px; }
div.source { background: #F8F8FF; border: 1px solid #EFEFEF; border-left: 3px solid #CCC; color: #444; font: 12px monospace; border-radius: 2px; letter-spacing: .1px; margin-bottom: 7px; margin-top: 15px; padding: 7px; width: 1081px; -khtml-border-radius: 2px; -moz-border-radius: 2px; -opera-border-radius: 2px; -webkit-border-radius: 2px; }
div.source div.comment { color: #777; font: 9px verdana; letter-spacing: 0.4px; margin-bottom: 9px; text-align: left; }
div#title { font: bold 17px verdana; color: #269; letter-spacing: .7px; margin-bottom: 10px; text-align: left; }
div#title span { color: #777; font: 10px verdana; }
span#version { color: #777; font: 10px verdana; }
/* wbotelhos.com/raty */
.left { float: left; }
div#target { float: left; }
div#hint { background-color: #F0F0F0; border-radius: 3px; float: left; height: 15px; margin-left: 5px; padding-bottom: 2px; padding-left: 8px; padding-right: 8px; text-align: center; width: 50px; }
div#target-number { float: left; }
select#score { float: left; margin-left: 5px }
</style>
<script type="text/javascript">
// This code does NOT belong the plugin. See the example code at the bottom of this page.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-194992347-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga_wev8.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="header">
<div id="title">
<a href="http://wbotelhos.com/raty">jQuery Raty - A Star Rating Plugin</a>
<span id="version">(current version: 1.4.3)</span>
</div>
<div id="menu">
<a href="http://github.com/downloads/wbotelhos/raty/jquery.raty-1.4.3.zip" target="_blank">Download</a> |
<a href="http://github.com/wbotelhos/raty" target="_blank">Github</a> |
<a href="http://wbotelhos.com/raty/changelog.txt" target="_blank">Change Log</a> |
<a href="http://wbotelhos.com/raty/README.txt" target="_blank">Readme</a> |
<a href="http://www.wbotelhos.com/2010/07/14/jquery-raty-a-star-rating-plugin/" target="_blank">Article</a> |
<a href="http://www.wbotelhos.com/raty/LICENSE.txt" target="_blank">License</a> |
<a href="http://www.wbotelhos.com/raty/who.html" target="_blank">Who is using</a> |
<a href="http://www.wbotelhos.com/2010/07/14/jquery-raty-a-star-rating-plugin/#comments" target="_blank" style="color: #2C8CBD;">Doubt</a> |
<a href="http://www.wbotelhos.com/lab" target="_blank" style="color: #000;">yLab</a>
</div>
<a id="coffee" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=jQuery%20Raty" target="_blank">buy me a coffee</a>
<div class="description">jQuery <strong>Raty</strong> is a plugin that generates a customizable star rating automatically.</div>
</div>
<div id="content">
<div id="default-demo" class="session-first">With default options:</div>
<div id="default"></div>
<div class="source">
$('#default').raty();<br/><br/>
<div id="default"></div>
</div>
<div id="fixed-demo" class="session">Started with a score and read only value:</div>
<div id="fixed"></div>
<div class="source">
$('#fixed').raty({<br/>
readOnly: true,<br/>
start: 2<br/>
});<br/><br/>
<div id="fixed"></div>
</div>
<div id="anyone-demo" class="session">A hint for no rated elements when it's read-only:</div>
<div id="anyone"></div>
<div class="source">
$('#anyone').raty({<br/>
readOnly: true,<br/>
noRatedMsg: 'anyone rated this product yet!'<br/>
});<br/><br/>
<div id="anyone"></div>
</div>
<div id="number-demo" class="session">With a custom score name and a number of stars:</div>
<div id="number"></div>
<div class="source">
$('#number').raty({<br/>
scoreName: 'entity.score',<br/>
number: 10<br/>
});<br/><br/>
<div id="number"></div>
</div>
<div id="click-demo" class="session">Using click function:</div>
<div id="click"></div>
<div class="source">
$('#click').raty({<br/>
click: function(score, evt) {<br/>
alert('ID: ' + this.attr('id') + '\nscore: ' + score + '\nevent: ' + evt);<br/>
}<br/>
});<br/><br/>
<div id="click"></div>
</div><br/>
<span class="comment">
- The argument score is the selected value;<br/>
- The argument evt is the click event;<br/>
- You can mension the star element itself using 'this'.<br/>
</span>
<div id="cancel-demo" class="session">With a default cancel button:</div>
<div id="cancel"></div>
<div class="source">
$('#cancel').raty({<br/>
cancel: true<br/>
});<br/><br/>
<div id="cancel"></div>
</div><br/>
<span class="comment">
- The score value for the click on cancel button is null.<br/>
</span>
<div id="cancel-custom-demo" class="session">With a custom cancel button:</div>
<div id="cancel-custom"></div>
<div class="source">
$('#cancel-custom').raty({<br/>
cancel: true<br/>
cancelHint: 'remove my rating!',<br/>
cancelPlace: 'right',<br/>
click: function(score, evt) {<br/>
alert('score: ' + score);<br/>
}<br/>
});<br/><br/>
<div id="cancel-custom"></div>
</div>
<div id="half-demo" class="session">Enabling half star:</div>
<div id="half"></div>
<div class="source">
$('#half').raty({<br/>
half: true,<br/>
start: 3.3<br/>
});<br/><br/>
<div id="half"></div>
</div><br/>
<span class="comment">
The interval can be:<br/>
- Rounded down: [x.00 ... x.25]<br/>
- Half star: [x.26 ... x.75]<br/>
- Rounded up: [x.76 ... x.99]
</span>
<div id="icon-demo" class="session">With a custom hint and icons:</div>
<div id="icon"></div>
<div class="source">
$('#icon').raty({<br/>
hintList: ['a', '', null, 'd', '5'],<br/>
starOn: 'medal-on_wev8.png',<br/>
starOff: 'medal-off_wev8.png'<br/>
});<br/><br/>
<div id="icon"></div>
</div><br/>
<span class="comment">
- To display the number of the star, set null.
</span>
<div id="range-demo" class="session">With a range of custom icons:</div>
<div id="range"></div>
<div class="source">
$('#range').raty({<br/>
iconRange: [['face-a_wev8.png', 2], ['face-b_wev8.png', 3], ['face-c_wev8.png', 4], ['face-d_wev8.png', 5]],<br/>
starOff: 'face-off_wev8.png'<br/>
});<br/><br/>
<div id="range"></div>
</div><br/>
<span class="comment">
- It's a array of array where each inner array represents a custom icon;<br/>
- The second parameter is until where this icon will be displayed;<br/>
- The sequence of the range interval should be in a ascending order.
</span>
<div id="big-demo" class="session">With a bigger icon:</div>
<div id="big"></div>
<div class="source">
$('#big').raty({<br/>
cancel: true,<br/>
cancelOff: 'cancel-off-big_wev8.png',<br/>
cancelOn: 'cancel-on-big_wev8.png',<br/>
half: true,<br/>
size: 24,<br/>
starHalf: 'star-half-big_wev8.png',<br/>
starOff: 'star-off-big_wev8.png',<br/>
starOn: 'star-on-big_wev8.png'<br/>
});<br/><br/>
<div id="big"></div>
</div><br/>
<span class="comment">
- You can specify your own width as following: width: 120.
</span>
<div id="group-demo" class="session">With a group of elements:</div>
<div class="group"></div>
<div class="group"></div>
<div class="group"></div>
<div class="source">
$('.group').raty();<br/><br/>
<div class="group"></div><br/>
<div class="group"></div><br/>
<div class="group"></div>
</div><br/>
<span class="comment">
- The ID is optional and must be unique;<br/>
- If you don't pass a ID for the element, then it will be created.
</span>
<div id="action-demo" class="session">Using directed actions with public functions:</div>
love:
<div class="action"></div>
happy:
<div class="action"></div><br/>
your last rate:
<div id="result"></div>
<div class="source">
$('.action').raty({<br/>
half: true,<br/>
click: function(score, evt) {<br/>
$.fn.raty.cancel('.action');<br/>
$.fn.raty.start(score, '#result');<br/>
}<br/>
});<br/><br/>
<div class="action"></div><br/>
<div class="action"></div><br/><br/>
<div id="result"></div>
</div><br/>
<span class="comment">
- All public functions have a optional second parameter to specify which container will be executed;<br/>
- You can pass a ID or a class to be the target of the action;<br/>
- If the ID or class are not specified, then the last element Raty will be takes.
</span>
<div id="target-demo" class="session">Displaying the hint in a target element:</div>
<div id="target"></div>
<div id="hint" class="target-score"></div><br/>
<div class="source">
$('#target').raty({<br/>
cancel: true<br/>
cancelHint: 'none'<br/>
target: '#hint'<br/>
});<br/><br/>
<div id="target"></div><br/>
<div id="hint"></div>
</div>
<div id="target-number-demo" class="session">Displaying and keeping the score in a target element:</div>
<div id="target-number"></div>
<select id="score">
<option value="">--</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div class="source left">
$('#target-number').raty({<br/>
cancel: true<br/>
target: '#score'<br/>
targetKeep: true,<br/>
targetType: 'number'<br/>
});<br/><br/>
<select id="score"><br/>
<option value="">0</option><br/>
<option value="1">1</option><br/>
<option value="2">2</option><br/>
<option value="3">3</option><br/>
<option value="4">4</option><br/>
<option value="5">5</option><br/>
</select><br/>
</div><br/>
<span class="comment">
- You can to choose the target types 'hint' or 'number'.
</span>
<div class="session">Default options:</div>
<div class="source">
cancel: false<br/>
<div class="comment">If will be showed a button to cancel the rating.</div>
cancelHint: 'cancel this rating!'<br/>
<div class="comment">The hint information.</div>
cancelOff: 'cancel-off_wev8.png'<br/>
<div class="comment">Name of the cancel image off.</div>
cancelOn: 'cancel-on_wev8.png'<br/>
<div class="comment">Name of the cancel image on.</div>
cancelPlace: 'left'<br/>
<div class="comment">Position of the cancel button.</div>
click: null<br/>
<div class="comment">Function that returns the selected value.</div>
half: false<br/>
<div class="comment">Enables half star display and selection.</div>
hintList: ['bad', 'poor', 'regular', 'good', 'gorgeous']<br/>
<div class="comment">List of names that will be used as a hint on each star.</div>
iconRange: []<br/>
<div class="comment">Name and position of the set icons.</div>
noRatedMsg: 'not rated yet'<br/>
<div class="comment">A hint for no rated elements when it's read-only.</div>
number: 5<br/>
<div class="comment">Number of stars that will be presented.</div>
path: 'img/'<br/>
<div class="comment">A range of custom icons that you can set.</div>
readOnly: false<br/>
<div class="comment">If the stars will be read-only.</div>
scoreName: 'score'<br/>
<div class="comment">Name of the hidden field that holds the score value.</div>
size: 16<br/>
<div class="comment">The icons size.</div>
starHalf: 'star-half_wev8.png'<br/>
<div class="comment">The name of the half star image.</div>
starOff: 'star-off_wev8.png'<br/>
<div class="comment">Name of the star image off.</div>
starOn: 'star-on_wev8.png'<br/>
<div class="comment">Name of the star image on.</div>
start: 0<br/>
<div class="comment">Number of stars to be selected.</div>
target: null<br/>
<div class="comment">Number of stars to be selected.</div>
targetKeep: false<br/>
<div class="comment">If the last choose value will be keeped on mouseout.</div>
targetType: 'hint'<br/>
<div class="comment">What display on target element: hint or number.</div>
width: null<br/>
<div class="comment">The container width of the stars.</div>
</div>
<div class="session">Public functions:</div>
<div class="source">$.fn.raty.start(3);</div>
<div class="description">Starts the last Raty with 3 stars later.</div>
<div class="source">$.fn.raty.click(2, '#raty');</div>
<div class="description">Click on the second star of the Raty with ID called 'raty' later.</div>
<div class="source">$.fn.raty.readOnly(true, '.raty');</div>
<div class="description">Adjusts all Raty with class called 'raty' for read-only later.</div>
<div class="source">$.fn.raty.cancel('#raty', true);</div>
<div class="description">Cancel the rating. The second parameter is optionally and enable the click callback.</div>
</div>
<div id="footer">
<div id="copy">© 2011 <a href="http://www.wbotelhos.com/" target="_blank">wbotelhos.com</a></div>
</div>
<script type="text/javascript">
$(function() {
$('#default').raty();
$('#fixed').raty({
readOnly: true,
start: 2
});
$('#anyone').raty({
readOnly: true,
noRatedMsg: 'anyone rated this product yet!'
});
$('#number').raty({
scoreName: 'entity.score',
number: 10
});
$('#click').raty({
click: function(score, evt) {
alert('ID: ' + this.attr('id') + '\nscore: ' + score + '\nevent: ' + evt);
}
});
$('#cancel').raty({
cancel: true
});
$('#cancel-custom').raty({
cancel: true,
cancelHint: 'remove my rating!',
cancelPlace: 'right',
click: function(score, evt) {
alert('score: ' + score);
}
});
$('#half').raty({
half: true,
start: 3.3
});
$('#icon').raty({
hintList: ['a', '', null, 'd', '5'],
starOn: 'medal-on_wev8.png',
starOff: 'medal-off_wev8.png'
});
$('#range').raty({
iconRange: [['face-a_wev8.png', 2], ['face-b_wev8.png', 3], ['face-c_wev8.png', 4], ['face-d_wev8.png', 5]],
starOff: 'face-off_wev8.png'
});
$('#big').raty({
cancel: true,
cancelOff: 'cancel-off-big_wev8.png',
cancelOn: 'cancel-on-big_wev8.png',
half: true,
size: 24,
starOff: 'star-off-big_wev8.png',
starOn: 'star-on-big_wev8.png',
starHalf: 'star-half-big_wev8.png'
});
$('.group').raty();
$('#result').raty({
half: true,
readOnly: true
});
$('.action').raty({
click: function(score) {
$.fn.raty.cancel('.action');
$.fn.raty.start(score, '#result');
}
});
$('#target').raty({
cancel: true,
cancelHint: 'none',
target: '#hint'
});
$('#target-number').raty({
cancel: true,
target: '#score',
targetKeep: true,
targetType: 'number'
});
});
</script>
</body>
</html>