-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.htm
272 lines (263 loc) · 7.83 KB
/
index.htm
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>AJAX Rating Stars Demo</title>
<script type="text/javascript" src="../lib/prototype/prototype.js"></script>
<script type="text/javascript" src="stars.js"></script>
<style type="text/css">
.prop{width: 500px; border: 1px green dotted; background: #EFEFEF; padding: 10px;}
.prop em {color:green; font-weight: bold;}
.prop td {vertical-align: top; text-align: left; padding: 5px;}
</style>
</head>
<body style="margin: 0px; padding: 0px; background: url(example_files/header-bg.png); background-repeat: repeat-x;">
<h1 style="margin: 20px 0px 39px 20px; color: white; vertical-align: middle;">AJAX Rating Stars Demo</h1>
<br/>
<div style="padding: 20px;">
<table>
<tr>
<td valign="top">
<h2>Examples</h2>
<table cellpadding="10">
<tr>
<td colspan="2">
<h3>Simple form binding</h3>
</td>
</tr>
<tr>
<td valign="top">
<form><input type="text" name="myRating" value="" id="myRating" readonly="readonly"/></form>
<script type="text/javascript">
var s1 = new Stars({
maxRating: 5,
bindField: 'myRating',
imagePath: 'images/',
value: 4.5
});
</script>
</td>
<td valign="top"><pre style="color: blue">
<script type="text/javascript">
var s1 = new Stars({
maxRating: 5,
bindField: 'myRating',
imagePath: 'images/',
value: 4.5
});
</script></pre>
</td>
</tr>
<tr>
<td colspan="2">
<h3>JavaScript callback function</h3>
</td>
</tr>
<tr>
<td valign="top">
<script type="text/javascript">
function rating(val)
{
alert('You rated it ' + val + ' star(s)!');
}
var s2 = new Stars({
maxRating: 5,
imagePath: 'images/',
callback: rating
});
</script></td>
<td valign="top"><pre style="color: blue">
<script type="text/javascript">
function rating(val)
{
alert('You rated it ' + val + ' star(s)!');
}
var s2 = new Stars({
maxRating: 5,
imagePath: 'images/',
callback: rating
});
</script></pre></td>
</tr>
<tr>
<td colspan="2">
<h3>Sending values through AJAX</h3>
</td>
</tr>
<tr>
<td valign="top">
<script type="text/javascript">
function ajaxRating(xml)
{
var x = xml.responseXML;
var xmlRating = x.getElementsByTagName('rating');
var rating = xmlRating[0].firstChild.nodeValue;
alert('You rated it ' + rating + ' star(s)!');
}
var s3 = new Stars({
maxRating: 5,
actionURL: 'rate.php?rating=',
callback: ajaxRating,
imagePath: 'images/',
value: 3
});
</script></td>
<td valign="top"><pre style="color: blue">
<script type="text/javascript">
function ajaxRating(xml)
{
var x = xml.responseXML;
var xmlRating = x.getElementsByTagName('rating');
var rating = xmlRating[0].firstChild.nodeValue;
alert('You rated it ' + rating + ' star(s)!');
}
var s3 = new Stars({
maxRating: 5,
actionURL: 'rate.php?rating=',
callback: ajaxRating,
imagePath: 'images/',
value: 3
});
</script></pre>
</td>
</tr>
<tr>
<td colspan="2">
<h3>Locking Example 1: Lock on update</h3>
</td>
</tr>
<tr>
<td valign="top">
<script type="text/javascript">
function rating2(val)
{
alert('You rated it ' + val + ' star(s)!');
s4.locked = true;
}
var s4 = new Stars({
maxRating: 5,
imagePath: 'images/',
callback: rating2
});
</script></td>
<td valign="top"><pre style="color: blue">
<script type="text/javascript">
function rating(val)
{
alert('You rated it ' + val + ' star(s)!');
s4.locked = true;
}
var s4 = new Stars({
maxRating: 5,
imagePath: 'images/',
callback: rating
});
</script></pre></td>
</tr>
<tr>
<td colspan="2">
<h3>Locking Example 2: Prelocked</h3>
</td>
</tr>
<tr>
<td valign="top">
<script type="text/javascript">
var s5 = new Stars({
maxRating: 5,
value: 4,
imagePath: 'images/',
locked: true
});
</script></td>
<td valign="top"><pre style="color: blue">
<script type="text/javascript">
var s5 = new Stars({
maxRating: 5,
value: 4,
imagePath: 'images/',
locked: true
});
</script></pre></td>
</tr>
</table>
</td>
<td valign="top">
<h2>Instatiation Options</h2>
<div class="prop">
<table>
<tr>
<td>
<table>
<tr>
<td><em>maxRating</em>:</td>
<td>integer. The maximum rating possible, also the number of stars to display.</td>
</tr>
<tr>
<td><em>locked</em>:</td>
<td>boolean (optional) Turns off the ability to use the rating stars, but still displays them.</td>
</tr>
<tr>
<td><em>imagePath</em>:</td>
<td>(optional) the path to look fro the star images in. Default: ./images/</td>
</tr>
<tr>
<td><em>bindField</em>:</td>
<td>(optional) the input object, or ID of the input object, to apply the rating value to.</td>
</tr>
<tr>
<td><em>value</em>:</td>
<td>(optional) the initial value of the rating.</td>
</tr>
<tr>
<td><em>actionURL</em>:</td>
<td>(optional) the URL to call when a rating is made. The rating value will be appended to the actionURL. (eg: '/rating.php?rating=' will be sent off as '/rating.php?rating=5' when the 5th star is clicked).</td>
</tr>
<tr>
<td><em>callback</em>:</td>
<td>(optional) the name of the javascript function to call when the widget is clicked. If actionURL is specified, this will be executed on the completion of the AJAX call with the XML document as the only parameter. If no actionURL is specified, the value of the rating widget will be passed in as the only parameter.</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<h2>Properties</h2>
<div class="prop">
<table>
<tr>
<td>
<table>
<tr>
<td><em>value</em>:</td>
<td>integer. The maximum rating possible, also the number of stars to display.</td>
</tr>
<tr>
<td><em>locked</em>:</td>
<td>boolean (optional) Turns off the ability to use the rating stars, but still displays them.</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<h2>Methods</h2>
<div class="prop">
<table>
<tr>
<td>
<table>
<tr>
<td><em>setValue(number value)</em>:</td>
<td>sets the value of the rating object. Also fires the callback/ajax functions</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</body>
</html>