forked from iOvergaard/raty-fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
469 lines (380 loc) · 31.4 KB
/
demo.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
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="author" content="Jacob Overgaard">
<meta name="description" content="A Star Rating Plugin with Font Awesome">
<meta name="google" content="notranslate">
<meta name="keywords" content="jquery,plugin,rating,raty,voto,star,staring,classificacao,classificar,votar,plugin">
<meta name="robots" content="ALL">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>jQuery Raty FA | A Star Rating Plugin with Font Awesome</title>
<meta content="authenticity_token" name="csrf-param">
<style>.white{
background-color:#FFF
}
.hint{
text-align:center;
width:160px
}
div.hint{
font-size:1.4em;
height:46px;
margin-top:15px;
padding:7px
}
#size i{font-size:24px;}</style>
</head>
<body>
<div class="content">
<div role="banner" class="header">
<h1>jQuery Raty FA</h1>
<div>A Star Rating Plugin with Font Awesome</div>
</div>
<div class="clearfix"></div>
<div>Special mention to Washington Botelhos for the original <a href="https://github.com/wbotelhos/raty">jQuery Raty plugin</a></div>
<div class="clearfix"></div>
<article><div class="body">
<h1>Default</h1>
<p>You need just to have a <code>div</code> to build the Raty.</p>
<div id="default"></div>
<div class="highlight"><pre><span class="nt"><div></div></span>
</pre></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</span><span class="p">).</span><span class="nx">raty</span><span class="p">();</span>
</pre></div>
<h1>Score</h1>
<p>Used when we want to start with a saved rating.</p>
<div id="score"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Score callback</h1>
<p>If you need to start you score depending of a dynamic value, you can to use callback for it.<br>
You can pass any value for it, not necessarily a data- value. You can use a field value for example.</p>
<div id="score-callback" data-score="1"></div>
<div class="highlight"><pre><span class="nt"><div</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">'div'</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>
<h1>Score Name</h1>
<p>Changes the name of the hidden <a href="#score">score</a> field.</p>
<div id="scoreName"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Number</h1>
<p>Changes the number of stars.</p>
<div id="number"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Number callback</h1>
<p>You can receive the <a href="#number">number</a> of stars dynamic using callback to set it.</p>
<div id="number-callback" data-number="3"></div>
<div class="highlight"><pre><span class="nt"><div</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">'div'</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>
<h1>Number Max</h1>
<p>Change the maximum of start that can be created.</p>
<div id="numberMax"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">100</span>
<span class="p">});</span>
</pre></div>
<h1>Read Only</h1>
<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 id="readOnly"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Read Only callback</h1>
<p>You can decide if the rating will be <a href="#readOnly">readOnly</a> dynamically returning <code>true</code> of <code>false</code> on callback.</p>
<div id="readOnly-callback"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>No Rated Message</h1>
<p>If <a href="#readOnly">readOnly</a> is enabled and there is no <a href="#score">score</a>, the <a href="#hint">hint</a> "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 id="noRatedMsg"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Half Show</h1>
<p>You can represent a float <a href="#score">score</a> as a half star icon.<br>
This options is just to <strong>show</strong> 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 <code>round</code> options showed belows is just for the <strong>icon</strong>, the score keeps as <strong>float</strong> always.</p>
<h2>Enabled</h2>
<p>The round rules are:</p>
<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 id="halfShow-true"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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="mf">3.26</span> <span class="p">});</span>
</pre></div>
<h2>Disabled</h2>
<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 id="halfShow-false"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Round</h1>
<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 halfShow is disabled.<br>
You can specify just the attribute you want to change and keeps the others as default.</p>
<div id="round"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Half</h1>
<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 id="half"></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>
</pre></div>
<h1>Star Half</h1>
<p>Changes the name of the half star.<br>
<div id="starHalf"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">'fa fa-fw fa-star-half'</span>
<span class="p">});</span>
</pre></div>
<h1>Click</h1>
<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 id="click"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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="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>
<h1>Hints</h1>
<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.</p>
<div id="hints"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Star Off and Star On</h1>
<p>Changes the name of the star on and star off.</p>
<div id="star-off-and-star-on"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">'fa fa-fw fa-bell-o'</span><span class="p">,</span>
<span class="nx">starOn</span> <span class="o">:</span> <span class="s1">'fa fa-fw fa-bell'</span>
<span class="p">});</span>
</pre></div>
<h1>Cancel</h1>
<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 receives the value <code>null</code> when we click on cancel button.</p>
<div id="cancel"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Cancel Hint</h1>
<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 id="cancelHint"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Cancel Place</h1>
<p>Changes the <a href="#cancel">cancel</a> button to the right side.</p>
<div id="cancelPlace"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Cancel off and Cancel On</h1>
<p>Changes the on and off icon of the <a href="#cancel">cancel</a> button.</p>
<div id="cancel-off-and-cancel-on"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">'fa fa-fw fa-minus-square-o'</span><span class="p">,</span>
<span class="nx">cancelOn</span> <span class="o">:</span> <span class="s1">'fa fa-fw fa-minus-square'</span>
<span class="p">});</span>
</pre></div>
<h1>Icon Range</h1>
<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 id="iconRange"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">'fa fa-fw fa-cloud'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'fa fa-fw fa-circle-o'</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">'fa fa-fw fa-cloud-download'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'fa fa-fw fa-circle-o'</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">'fa fa-fw fa-cloud-upload'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'fa fa-fw fa-circle-o'</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">'fa fa-fw fa-circle'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'fa fa-fw fa-circle-o'</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">'fa fa-fw fa-cogs'</span><span class="p">,</span> <span class="nx">off</span><span class="o">:</span> <span class="s1">'fa fa-fw fa-circle-o'</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">'div'</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">'fa fa-fw fa-circle-o'</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">'fa fa-fw fa-cloud'</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">'fa fa-fw fa-cloud-upload'</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">'fa fa-fw fa-cogs'</span> <span class="p">}</span>
<span class="p">]</span>
<span class="p">});</span>
</pre></div>
<p>Now we have all off icons as <strong>fa fa-fw fa-circle-o</strong>, icons 1 and 2 as <strong>fa fa-fw fa-cloud</strong>, icon 3 as <strong>fa fa-fw fa-cloud-upload</strong> and icons 4 and 5 as <strong>fa fa-fw fa-cogs</strong>. </p>
<h1>Size</h1>
<p>The size of the icons are controlled by the css property <strong>font-size</strong> as all icons are text. The plugin tries to calculate the font size automatically, but should that fail, you can provide a size (in pixels) with the <strong>size</strong> option.<br>
It does <strong>not</strong> change the icon size, just the calculation used to find the half position.</p>
<div id="size"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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">size</span> <span class="o">:</span> <span class="mi">24</span>
<span class="p">});</span>
</pre></div>
<h1>Width</h1>
<p>By default Raty does not set a width on its container. But if for some reason the width does not fit the layout, you can change it manually.</p>
<div id="width" class="white"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Target</h1>
<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">'div'</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 id="target-div"></div>
<div id="target-div-hint" class="input hint"></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 id="target-text"></div>
<p><input id="target-text-hint" type="text" class="input hint"></p>
<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 id="target-textarea"></div>
<p><textarea id="target-textarea-hint" class="input hint"></textarea></p>
<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 id="target-select"></div>
<p><select id="target-select-hint" class="input hint"><br><option value="">--</option>
<br><option value="bad">bad</option>
<br><option value="poor">poor</option>
<br><option value="regular">regular</option>
<br><option value="good">good</option>
<br><option value="gorgeous">gorgeous</option>
<br></select></p>
<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>
<h1>Target Type</h1>
<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 id="targetType"></div>
<div id="targetType-hint" class="input hint"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Target Keep</h1>
<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 id="targetKeep"></div>
<div id="targetKeep-hint" class="input hint"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Target Text</h1>
<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 id="targetText"></div>
<div id="targetText-hint" class="input hint"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Target Format</h1>
<p>You can choose a template to be merged with your hints and displayed on <a href="#target">target</a>.</p>
<div id="targetFormat"></div>
<div id="targetFormat-hint" class="input hint"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Mouseover</h1>
<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 id="mouseover"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
<h1>Mouseout</h1>
<p>You can handle the action on mouseout.<br>
The arguments is the same of the <a href="#mouseover">mouseover</a> callback.</p>
<div id="mouseout"></div>
<div class="highlight"><pre><span class="nx">$</span><span class="p">(</span><span class="s1">'div'</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>
</div>
</article>
</div>
<link href="//netdna.bootstrapcdn.com/font-awesome/latest/css/font-awesome.css" rel="stylesheet">
<link href="demo/stylesheets/labs.css" media="screen" rel="stylesheet" type="text/css">
<script src="demo/javascripts/jquery.js"></script>
<script src="lib/jquery.raty-fa.js"></script>
<script src="demo/javascripts/demo.js"></script>
</body>
</html>