forked from wbotelhos/raty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1608 lines (1286 loc) · 65.8 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
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<title>JQuery Raty</title>
<meta content="Washington Botelho" name="author">
<meta content="jQuery Raty - A Star Rating Plugin" name="description">
<meta content="jquery,plugin,rating,raty,voto,star,staring,classificacao,classificar,votar,plugin" name="keywords">
<link type="text/css" rel="stylesheet" href="demo/css/application.css">
<script type="text/javascript" src="demo/js/jquery.min.js"></script>
<script type="text/javascript" src="lib/jquery.raty.js"></script>
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<header role="banner">
<div id="logo">
<h1><a href="http://wbotelhos.com/raty" title="jQuery Raty">jQuery Raty</a></h1>
<p>A Star Rating Plugin</p>
</div>
<nav role="navigation">
<ul>
<li><a href="http://github.com/wbotelhos/raty/archive/2.5.2.zip" title="Download" class="download"><i class="icon-download icon-large"></i>v2.5.2</a></li>
<li><a href="http://github.com/wbotelhos/raty" title="Github" target="_blank"><i class="icon-github icon-large"></i>Github</a></li>
<li><a href="http://wbotelhos.com/labs" title="yLab" target="_blank"><i class="icon-beaker icon-large"></i>yLab</a></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=jQuery%20Raty" title="Donate" target="_blank"><i class="icon-heart-empty icon-large"></i>Donate</a></li>
</ul>
</nav>
</header>
<div id="container">
<section role="main">
<article>
<h2 id="default">
<a href="#default">Default</a>
</h2>
<p>You need just to have a <code>div</code> to build the Raty.</p>
<div class="demo">
<div id="default-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"star"</span><span class="nt">></div></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">();</span>
</pre>
</div>
<h2 id="score">
<a href="#score">Score</a>
</h2>
<p>
Used when we want starts with saved rating.
</p>
<div class="demo">
<div id="score-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">});</span>
</pre>
</div>
<h2 id="score-callback">
<a href="#score-callback">Score callback</a>
</h2>
<p>
If you need to start you <a href="#score">score</a> depending of a dynamic value, you can to use callback for it.<br/>
You can pass any value for it, not necessarily a <code>data-</code> value. You can use a field value for example.<br />
</p>
<div class="demo">
<div id="score-callback-demo" data-score="1"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"star"</span> <span class="na">data-score=</span><span class="s">"1"</span><span class="nt">></div></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">score</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'data-score'</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="number">
<a href="#number">Number</a>
</h2>
<p>Changes the number of stars.</p>
<div class="demo">
<div id="number-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">number</span><span class="o">:</span> <span class="mi">10</span> <span class="p">});</span>
</pre>
</div>
<h2 id="numberMax">
<a href="#numberMax">Number Max</a>
</h2>
<p>Change the maximum of start that can be created.</p>
<div class="demo">
<div id="numberMax-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#numberMax-demo'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">numberMax</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span>
<span class="nx">number</span> <span class="o">:</span> <span class="mi">500</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="scoreName">
<a href="#scoreName">Score Name</a>
</h2>
<p>
Changes the name of the hidden <a href="#score">score</a> field.<br />
It can be submited on a <code>form</code> or captured via JavaScript to be sended via ajax.
</p>
<div class="demo">
<div id="scoreName-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">scoreName</span><span class="o">:</span> <span class="s1">'entity[score]'</span> <span class="p">});</span>
</pre>
</div>
<h2 id="number-callback">
<a href="#number-callback">Number callback</a>
</h2>
<p>You can receive the number of stars dynamic using callback to set it.</p>
<div class="demo">
<div id="number-callback-demo" data-number="3"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"star"</span> <span class="na">data-number=</span><span class="s">"3"</span><span class="nt">></div></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">number</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'data-number'</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="readOnly">
<a href="#readOnly">Read Only</a>
</h2>
<p>
You can prevent users to vote.
It can be applied with or without <a href="#score">score</a> and all stars will receives the <a href="#hints">hint</a> corresponding of the selected star.<br />
Stop the mouse over the stars to see:
</p>
<div class="demo">
<div id="readOnly-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">readOnly</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">});</span>
</pre>
</div>
<h2 id="readOnly-callback">
<a href="#readOnly-callback">Read Only callback</a>
</h2>
<p>
You can decide if the rating will be <a href="#readOnly">readOnly</a> dynamically returning <code>true</code> of <code>false</code> on the callback.
</p>
<div class="demo">
<div id="readOnly-callback-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">readOnly</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="s1">'true becomes readOnly'</span> <span class="o">==</span> <span class="s1">'true becomes readOnly'</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="noRatedMsg">
<a href="#noRatedMsg">No Rated Message</a>
</h2>
<p>
If <a href="#readOnly">readOnly</a> is enabled and there is no <a href="#score">score</a>, the hint "Not rated yet!" will be shown for all stars. But you can change it.<br />
Stop the mouse over the star to see:
</p>
<div class="demo">
<div id="noRatedMsg-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">readOnly</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">noRatedMsg</span><span class="o">:</span> <span class="s2">"I'am readOnly and I haven't rated yet!"</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="halfShow">
<a href="#halfShow">Half Show</a>
</h2>
<p>
You can represent a float <a href="#score">score</a> as a half star icon.<br />
This options is just to show the half star. If you want enable the vote with half star on mouseover, please check the option <a href="#half">half</a>.<br />
The round options showed belows is just for the icon, the score keeps as float always.
</p>
<h3>Enabled</h3>
<p>The round rules are:<br />
<ul>
<li>Down: score <= x.25 the star will be rounded down;</li>
<li>Half: score >= x.26 and <= x.75 the star will be a half star;</li>
<li>Up: score >= x.76 the star will be rounded up.</li>
</ul>
<div class="demo">
<div id="halfShow-true-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty({ score</span><span class="o">:</span> <span class="mf">3.26</span> <span class="p">});</span>
</pre>
</div>
<h3>Disabled</h3>
<p>The rules becomes:</p>
<ul>
<li>Down: score < x.6 the star will be rounded down;</li>
<li>Up: score >= x.6 the star will be rounded up;</li>
</ul>
<div class="demo">
<div id="halfShow-false-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#halfShow-demo'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">halfShow</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nx">score</span> <span class="o">:</span> <span class="mf">3.26</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="round">
<a href="#round">Round</a>
</h2>
<p>
You can customize the round values of the <a href="#halfShow">halfShow</a> option.<br />
We changed the default interval [x.25 .. x.76], now x.26 will round down instead of to be a half star.<br />
Remember that the <code>full</code> attribute is used only when <a href="#halfShow">halfShow</a> is disabled.<br />
You can specify just the attribute you want to change and keeps the others as default.
</p>
<div class="demo">
<div id="round-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">round</span><span class="o">:</span> <span class="p">{</span> <span class="nx">down</span><span class="o">:</span> <span class="p">.</span><span class="mi">26</span><span class="p">,</span> <span class="nx">full</span><span class="o">:</span> <span class="p">.</span><span class="mi">6</span><span class="p">,</span> <span class="nx">up</span><span class="o">:</span> <span class="p">.</span><span class="mi">76</span> <span class="p">},</span>
<span class="nx">score</span><span class="o">:</span> <span class="mf">3.26</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="half">
<a href="#half">Half</a>
</h2>
<p>Enables the half star mouseover to be possible vote with half values.<br />
If you want to vote with more precison than half value, please check the option <a href="#precision">precision</a>.
</p>
<div class="demo">
<div id="half-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">half</span><span class="o">:</span> <span class="kc">true</span> });</span>
</pre>
</div>
<h2 id="starHalf">
<a href="#starHalf">Star Half</a>
</h2>
<p>Changes the name of the half star.</p>
<div class="demo">
<div id="starHalf-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">half</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">starHalf</span><span class="o">:</span> <span class="s1">'half.png'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="click">
<a href="#click">Click</a>
</h2>
<p>
Callback to handle the <a href="score">score</a> and the click <code>event</code> on click action.<br />
You can mension the Raty element (DOM) itself using <code>this</code>.
</p>
<div class="demo">
<div id="click-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">click</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">score</span><span class="p">,</span> <span class="nx">evt</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">alert</span><span class="p">(</span><span class="s1">'ID: '</span> <span class="o">+</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'id'</span><span class="p">)</span> <span class="o">+</span> <span class="s1">"\nscore: "</span> <span class="o">+</span> <span class="nx">score</span> <span class="o">+</span> <span class="s1">"\nevent: "</span> <span class="o">+</span> <span class="nx">evt</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="hints">
<a href="#hints">Hints</a>
</h2>
<p>
Changes the hint for each star by it position on array.<br />
If you pass <code>null</code>, the <a href="#score">score</a> value of this star will be the hint.<br />
If you pass <code>undefined</code>, this position will be ignored and receive the default hint.<br />
</p>
<div class="demo">
<div id="hints-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">hints</span><span class="o">:</span> <span class="p">[</span><span class="s1">'a'</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="kc">undefined</span><span class="p">,</span> <span class="s1">'*_*'</span><span class="p">]});</span>
</pre>
</div>
<h2 id="path">
<a href="#path">Path</a>
</h2>
<p>
Changes the path where your icons are located.<br />
Set it only if you want the same path for all icons.<br />
Don't mind about the last slash of the path, if you don't put it, we will set it for you.
</p>
<div class="demo">
<div id="path-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">path</span><span class="o">:</span> <span class="s1">'assets/images'</span> <span class="p">});</span>
</pre>
</div>
<p>Now we have the following full paths: <code>assets/images/star-on.png</code>, <code>assets/images/star-off.png</code> and so.</p>
<h2 id="star-off-and-star-on">
<a href="#star-off-and-star-on">Star Off and Star On</a>
</h2>
<p>Changes the name of the star on and star off.</p>
<div class="demo">
<div id="star-off-and-star-on-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">starOff</span><span class="o">:</span> <span class="s1">'img/off.png'</span><span class="p">,</span>
<span class="nx">starOn</span> <span class="o">:</span> <span class="s1">'http://icons.com/on.png'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="cancel">
<a href="#cancel">Cancel</a>
</h2>
<p>
Add a cancel button on the left side of the stars to cacel the <a href="#score">score</a>.<br />
Inside the <a href="#click">click</a> callback the argument <code>code</code> receives the value <code>null</code> when we click on cancel button.
</p>
<div class="demo">
<div id="cancel-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">cancel</span><span class="o">:</span> <span class="kc">true</span> <span class="p">});</span>
</pre>
</div>
<h2 id="cancelHint">
<a href="#cancelHint">Cancel Hint</a>
</h2>
<p>
Like the stars, the <a href="#cancel">cancel</a> button have a hint too, and you can change it.<br />
Stop the mouse over the cancel button to see:
</p>
<div class="demo">
<div id="cancelHint-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">cancelHint</span><span class="o">:</span> <span class="s1">'My cancel hint!'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="cancelPlace">
<a href="#cancelPlace">Cancel Place</a>
</h2>
<p>Changes the <a href="#cancel">cancel</a> button to the right side.</p>
<div class="demo">
<div id="cancelPlace-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">cancelPlace</span><span class="o">:</span> <span class="s1">'right'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="cancel-off-and-cancel-on">
<a href="#cancel-off-and-cancel-on">Cancel off and Cancel On</a>
</h2>
<p>Changes the off and on icon of the <a href="#cancel">cancel</a> button.</p>
<div class="demo">
<div id="cancel-off-and-cancel-on-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">cancelOff</span><span class="o">:</span> <span class="s1">'off.png'</span><span class="p">,</span>
<span class="nx">cancelOn</span> <span class="o">:</span> <span class="s1">'on.png'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="iconRange">
<a href="#iconRange">Icon Range</a>
</h2>
<p>
It's an array of objects where each one represents a custom icon.<br />
The <code>range</code> attribute is until wich position the icon will be displayed.<br />
The <code>on</code> attribute is the active icon.<br />
The <code>off</code> attribute is the inactive icon.
</p>
<div class="demo">
<div id="iconRange-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">iconRange</span><span class="o">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'1.png'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'0.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'2.png'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'0.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'3.png'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'0.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">4</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'4.png'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'0.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'5.png'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'0.png'</span> <span class="p">}</span>
<span class="p">]</span>
<span class="p">});</span>
</pre>
</div>
<p>
You can use an interval of the same icon jumping some number.<br />
The <code>range</code> attribute must be in an ascending order.<br />
If the value <code>on</code> or <code>off</code> is omitted then the attribute <code>starOn</code> and <code>starOff</code> will be used.
</p>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#iconRange-demo'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">starOff</span> <span class="o">:</span> <span class="s1">'0.png'</span><span class="p">,</span>
<span class="nx">iconRange</span><span class="o">:</span> <span class="p">[</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'1.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'3.png'</span> <span class="p">},</span>
<span class="p">{</span> <span class="nx">range</span><span class="o">:</span> <span class="mi">5</span><span class="p">,</span> <span class="nx">on</span><span class="o">:</span> <span class="s1">'5.png'</span> <span class="p">}</span>
<span class="p">]</span>
<span class="p">});</span>
</pre>
</div>
<p>
Now we have all off icons as <code>0.png</code>, icons 1 and 2 as <code>1.png</code>, icon 3 as <code>3.png</code> and icons 4 and 5 as <code>5.png</code>.
</p>
<h2 id="size">
<a href="#size">Size</a>
</h2>
<p>
The size in pixel of the icon you will to use.<br />
It changes the size for all icons.
</p>
<div class="demo">
<div id="size-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">cancelOff</span><span class="o">:</span> <span class="s1">'cancel-off-big.png'</span><span class="p">,</span>
<span class="nx">cancelOn</span> <span class="o">:</span> <span class="s1">'cancel-on-big.png'</span><span class="p">,</span>
<span class="nx">half</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">size</span> <span class="o">:</span> <span class="mi">24</span><span class="p">,</span>
<span class="nx">starHalf</span> <span class="o">:</span> <span class="s1">'star-half-big.png'</span><span class="p">,</span>
<span class="nx">starOff</span> <span class="o">:</span> <span class="s1">'star-off-big.png'</span><span class="p">,</span>
<span class="nx">starOn</span> <span class="o">:</span> <span class="s1">'star-on-big.png'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="width">
<a href="#width">Width</a>
</h2>
<p>
By default Raty calculates the width calculating the <a href="#size">size</a> of the stars plus the spaces.<br />
But for some reason the calculated width not fits on your layout, you can change it manually.<br />
If you want to avoid that Raty applies the style width on you wrapper, set it to <code>false</code>.
</p>
<div class="demo">
<div id="width-demo" style="background-color: #FFF"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">width</span><span class="o">:</span> <span class="mi">150</span> <span class="p">});</span>
</pre>
</div>
<h2 id="target">
<a href="#target">Target</a>
</h2>
<p>
Some place to display the <a href="#hints">hints</a> or the <a href="#cancelHint">cancelHint</a>.
</p>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">target</span><span class="o">:</span> <span class="s1">'#hint'</span>
<span class="p">});</span>
</pre>
</div>
<p>Your target can be a <code>div</code>.</p>
<div class="demo">
<div id="target-div-demo" class="target-demo"></div>
<div id="target-div-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"hint"</span><span class="nt">></div></span>
</pre>
</div>
<p>Your target can be a <code>text</code> field.</p>
<div class="demo">
<div id="target-text-demo" class="target-demo"></div>
<input id="target-text-hint" type="text" class="hint" />
</div>
<div class="highlight">
<pre>
<span class="nt"><input</span> <span class="na">id=</span><span class="s">"hint"</span> <span class="na">type=</span><span class="s">"text"</span> <span class="nt">/></span>
</pre>
</div>
<p>Your target can be a <code>textarea</code>.</p>
<div class="demo">
<div id="target-textarea-demo" class="target-demo"></div>
<textarea id="target-textarea-hint" class="hint"></textarea>
</div>
<div class="highlight">
<pre>
<span class="nt"><textarea</span> <span class="na">id=</span><span class="s">"hint"</span><span class="nt">></textarea></span>
</pre>
</div>
<p>Your target can be a <code>select</code>.</p>
<div class="demo">
<div id="target-select-demo" class="target-demo"></div>
<select id="target-select-hint" class="hint">
<option value="">--</option>
<option value="bad">bad</option>
<option value="poor">poor</option>
<option value="regular">regular</option>
<option value="good">good</option>
<option value="gorgeous">gorgeous</option>
</select>
</div>
<div class="highlight">
<pre>
<span class="nt"><select</span> <span class="na">id=</span><span class="s">"hint"</span><span class="nt">></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">""</span><span class="nt">></span>--<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"bad"</span><span class="nt">></span>bad<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"poor"</span><span class="nt">></span>poor<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"regular"</span><span class="nt">></span>regular<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"good"</span><span class="nt">></span>good<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"gorgeous"</span><span class="nt">></span>gorgeous<span class="nt"></option></span>
<span class="nt"></select></span>
</pre>
</div>
<h2 id="targetType">
<a href="#targetType">Target Type</a>
</h2>
<p>
You have the option <code>hint</code> or <code>score</code> to chosse.<br />
You can choose to see the <a href="#score">score</a> instead the <a href="#hints">hints</a> using the value <code>score</code>.<br />
For the <a href="#cancel">cancel</a> button the value is empty.
</p>
<div class="demo">
<div id="targetType-demo" class="target-demo"></div>
<div id="targetType-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"hint"</span><span class="nt">></div></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#targetType-demo'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">target</span> <span class="o">:</span> <span class="s1">'#hint'</span><span class="p">,</span>
<span class="nx">targetType</span><span class="o">:</span> <span class="s1">'number'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="targetKeep">
<a href="#targetKeep">Target Keep</a>
</h2>
<p>
If you want to keep the <a href="#score">score</a> into the hint box after you do the rating, turn on this option.
</p>
<div class="demo">
<div id="targetKeep-demo" class="target-demo"></div>
<div id="targetKeep-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"hint"</span><span class="nt">></div></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">cancel</span> <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nx">target</span> <span class="o">:</span> <span class="s1">'#hint'</span><span class="p">,</span>
<span class="nx">targetKeep</span><span class="o">:</span> <span class="kc">true</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="targetText">
<a href="#targetText">Target Text</a>
</h2>
<p>
Normally all <a href="#target">target</a> is keeped blank if you don't use the <a href="#targetKeep">targetKeep</a> option.<br />
If you want a default content you can use this option.
</p>
<div class="demo">
<div id="targetText-demo" class="target-demo"></div>
<div id="targetText-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">target</span> <span class="o">:</span> <span class="s1">'#hint'</span><span class="p">,</span>
<span class="nx">targetText</span><span class="o">:</span> <span class="s1">'--'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="targetFormat">
<a href="#targetFormat">Target Format</a>
</h2>
<p>
You can choose a template to be merged with your hints and displayed on <a href="#target">target</a>.
</p>
<div class="demo">
<div id="targetFormat-demo" class="target-demo"></div>
<div id="targetFormat-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">target</span> <span class="o">:</span> <span class="s1">'#hint'</span><span class="p">,</span>
<span class="nx">targetFormat</span><span class="o">:</span> <span class="s1">'Rating: {score}'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="mouseover">
<a href="#mouseover">Mouseover</a>
</h2>
<p>
You can handle the action on mouseover.<br />
The arguments is the same of the <a href="#click">click</a> callback.<br />
The options <a href="#target">target</a>, <a href="#targetFormat">targetFormat</a>, <a href="#targetKeep">targetKeep</a>, <a href="#targetText">targetText</a> and <a href="#targetType">targetType</a> are abstractions of this callback. You can do it by yourself.
</p>
<div class="demo">
<div id="mouseover-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">mouseover</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">score</span><span class="p">,</span> <span class="nx">evt</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">alert</span><span class="p">(</span><span class="s1">'ID: '</span> <span class="o">+</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'id'</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"\nscore: "</span> <span class="o">+</span> <span class="nx">score</span> <span class="o">+</span> <span class="s2">"\nevent: "</span> <span class="o">+</span> <span class="nx">evt</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="mouseout">
<a href="#mouseout">Mouseout</a>
</h2>
<p>
You can handle the action on mouseout.<br />
The arguments is the same of the <a href="#mouseover">mouseover</a> callback.
</p>
<div class="demo">
<div id="mouseout-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span>
<span class="nx">mouseout</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">score</span><span class="p">,</span> <span class="nx">evt</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">alert</span><span class="p">(</span><span class="s1">'ID: '</span> <span class="o">+</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'id'</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"\nscore: "</span> <span class="o">+</span> <span class="nx">score</span> <span class="o">+</span> <span class="s2">"\nevent: "</span> <span class="o">+</span> <span class="nx">evt</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="precision">
<a href="#precision">Precision</a>
</h2>
<p>
You can get the right position of the cursor to get a precision <a href="#score">score</a>.<br />
The star is represented just as half and full star, but the <a href="#score">score</a> is saved with precision.<br />
When you enable this option the <a href="#half">half</a> options is automatically enabled and <a href="#targetType">targetType</a> is changed to <code>score</code>.
</p>
<div class="demo">
<div id="precision-demo" class="target-demo"></div>
<div id="precision-hint" class="hint"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">precision</span><span class="o">:</span> <span class="kc">true</span> <span class="p">});</span>
</pre>
</div>
<h2 id="precision">
<a href="#precision">Font Awsome</a>
</h2>
<p>
You are able to use fontawsome instead of images.
</p>
<div class="demo">
<div id="fontawsome-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">font</span><span class="o">:</span> <span class="kc">true</span>,
<span class="nx">cancelOff</span><span class="o">:</span> <span class="kc">fa-times-circle-o</span>,
<span class="nx">cancelOn</span><span class="o">:</span> <span class="kc">fa-times-circle</span>,
<span class="nx">starHalf</span><span class="o">:</span> <span class="kc">fa-star-half</span>,
<span class="nx">starOff</span><span class="o">:</span> <span class="kc">fa-star-o</span>,
<span class="nx">starOn</span><span class="o">:</span> <span class="kc">fa-star</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="space">
<a href="#space">Space</a>
</h2>
<p>You can take off the space between the star.</p>
<div class="demo">
<div id="space-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">space</span><span class="o">:</span> <span class="kc">false</span> <span class="p">});</span>
</pre>
</div>
<h2 id="single">
<a href="#single">Single</a>
</h2>
<p>You can turn on just the mouseovered star instead all from the first until the mouseovered one.</p>
<div class="demo">
<div id="single-demo"></div>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'#star'</span><span class="p">).</span><span class="nx">raty</span><span class="p">({</span> <span class="nx">single</span><span class="o">:</span> <span class="kc">true</span> <span class="p">});</span>
</pre>
</div>
<h2 id="global">
<a href="#global">Changing the settings globally</a>
</h2>
<p>
You can change any option mentioning the scope <code>$.fn.raty.defaults.</code> + <i>option_name</i>. It must be called before you bind the plugin.
</p>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">.</span><span class="nx">fn</span><span class="p">.</span><span class="nx">raty</span><span class="p">.</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="s1">assets</span><span class="p">;</span>
<span class="nx">$</span><span class="p">.</span><span class="nx">fn</span><span class="p">.</span><span class="nx">raty</span><span class="p">.</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">cancel</span> <span class="o">=</span> <span class="s1">true</span><span class="p">;</span>
</pre>
</div>
<h2 id="options">
<a href="#options">Options</a>
</h2>
<div id="cancel-option" class="option">
<div>cancel: <span>false</span></div>
<p>Creates a cancel button to cancel the rating.</p>
</div>
<div id="cancelHint-option" class="option">
<div>cancelHint: <span>'Cancel this rating!'</span></div>
<p>The cancel's button hint.</p>
</div>
<div id="cancelOff-option" class="option">
<div>cancelOff: <span>'cancel-off.png'</span></div>
<p>Icon used on active cancel.</p>
</div>
<div id="cancelOn-option" class="option">
<div>cancelOn: <span>'cancel-on.png'</span></div>
<p>Icon used inactive cancel.</p>
</div>
<div id="cancelPlace-option" class="option">
<div>cancelPlace: <span>'left'</span></div>
<p>Cancel's button position.</p>
</div>
<div id="click-option" class="option">
<div>click: <span>undefined</span></div>
<p>Callback executed on rating click.</p>
</div>