forked from matthewlein/jQuery-jSlots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·366 lines (304 loc) · 10.6 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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jSlots Slot Machine - Matthew Lein</title>
<link href='http://fonts.googleapis.com/css?family=Gravitas+One&text=1234567' rel='stylesheet' type='text/css'>
<!-- Syntax highlighting, ignore this -->
<link rel="stylesheet" href="SyntaxHighlighter/Styles/SyntaxHighlighter.css" type="text/css" media="screen" title="no title" charset="utf-8">
<style type="text/css">
ul {
padding: 0;
margin: 0;
list-style: none;
}
.jSlots-wrapper {
overflow: hidden;
height: 20px;
display: inline-block; /* to size correctly, can use float too, or width*/
border: 1px solid #999;
}
.slot {
float: left;
}
input[type="button"] {
display: block;
}
/* ---------------------------------------------------------------------
FANCY EXAMPLE
--------------------------------------------------------------------- */
.fancy .jSlots-wrapper {
overflow: hidden;
height: 100px;
display: inline-block; /* to size correctly, can use float too, or width*/
border: 1px solid #999;
}
.fancy .slot li {
width: 100px;
line-height: 100px;
text-align: center;
font-size: 70px;
font-weight: bold;
color: #fff;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
font-family: 'Gravitas One', serif;
border-left: 1px solid #999;
}
.fancy .slot:first-child li {
border-left: none;
}
.fancy .slot li:nth-child(7) {
background-color: #FFCE29;
}
.fancy .slot li:nth-child(6) {
background-color: #FFA22B;
}
.fancy .slot li:nth-child(5) {
background-color: #FF8645;
}
.fancy .slot li:nth-child(4) {
background-color: #FF6D3F;
}
.fancy .slot li:nth-child(3) {
background-color: #FF494C;
}
.fancy .slot li:nth-child(2) {
background-color: #FF3333;
}
.fancy .slot li:nth-child(1),
.fancy .slot li:nth-child(8) {
background-color: #FF0000;
}
.fancy .slot li span {
display: block;
}
/* ---------------------------------------------------------------------
ANIMATIONS
--------------------------------------------------------------------- */
@-webkit-keyframes winner {
0%, 50%, 100% {
-webkit-transform: rotate(0deg);
font-size:70px;
color: #fff;
}
25% {
-webkit-transform: rotate(20deg);
font-size:90px;
color: #FF16D8;
}
75% {
-webkit-transform: rotate(-20deg);
font-size:90px;
color: #FF16D8;
}
}
@-moz-keyframes winner {
0%, 50%, 100% {
-moz-transform: rotate(0deg);
font-size:70px;
color: #fff;
}
25% {
-moz-transform: rotate(20deg);
font-size:90px;
color: #FF16D8;
}
75% {
-moz-transform: rotate(-20deg);
font-size:90px;
color: #FF16D8;
}
}
@-ms-keyframes winner {
0%, 50%, 100% {
-ms-transform: rotate(0deg);
font-size:70px;
color: #fff;
}
25% {
-ms-transform: rotate(20deg);
font-size:90px;
color: #FF16D8;
}
75% {
-ms-transform: rotate(-20deg);
font-size:90px;
color: #FF16D8;
}
}
@-webkit-keyframes winnerBox {
0%, 50%, 100% {
box-shadow: inset 0 0 0px yellow;
background-color: #FF0000;
}
25%, 75% {
box-shadow: inset 0 0 30px yellow;
background-color: aqua;
}
}
@-moz-keyframes winnerBox {
0%, 50%, 100% {
box-shadow: inset 0 0 0px yellow;
background-color: #FF0000;
}
25%, 75% {
box-shadow: inset 0 0 30px yellow;
background-color: aqua;
}
}
@-ms-keyframes winnerBox {
0%, 50%, 100% {
box-shadow: inset 0 0 0px yellow;
background-color: #FF0000;
}
25%, 75% {
box-shadow: inset 0 0 30px yellow;
background-color: aqua;
}
}
.winner li {
-webkit-animation: winnerBox 2s infinite linear;
-moz-animation: winnerBox 2s infinite linear;
-ms-animation: winnerBox 2s infinite linear;
}
.winner li span {
-webkit-animation: winner 2s infinite linear;
-moz-animation: winner 2s infinite linear;
-ms-animation: winner 2s infinite linear;
}
/* Syntax Highlighter, ignore */
.dp-highlighter ol {
padding: 10px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="content">
<h1>jQuery jSlots – Lucky 7's!</h1>
<p>jSlots is 2k of jQuery slot machine magic. It turns any list (<ol> or <ul>) into a slot machine!</p>
<div class="fancy">
<ul class="slot">
<!-- In reverse order so the 7s show on load -->
<li><span>7</span></li>
<li><span>6</span></li>
<li><span>5</span></li>
<li><span>4</span></li>
<li><span>3</span></li>
<li><span>2</span></li>
<li><span>1</span></li>
</ul>
<input type="button" id="playFancy" value="Play">
</div>
</div>
</div>
<section class="demos">
<h2>Demos</h2>
<ul>
<li><a href="demos/simple.html">Super simple basic 3 slot</a></li>
<li><a href="demos/fancy.html">Fun fancy 7 slot (shown above)</a></li>
</ul>
</section>
<section class="docs">
<h2>Options</h2>
<p>These are the options, with their default values, and what they do</p>
<pre name="code" class="js">
$.jSlots.defaultOptions = {
number : 3, // Number: number of slots
winnerNumber : 1, // Number or Array: list item number(s) upon which to trigger a win, 1-based index, NOT ZERO-BASED
spinner : '', // CSS Selector: element to bind the start event to
spinEvent : 'click', // String: event to start slots on this event
onStart : $.noop, // Function: runs on spin start,
onEnd : $.noop, // Function: run on spin end. It is passed (finalNumbers:Array). finalNumbers gives the index of the li each slot stopped on in order.
onWin : $.noop, // Function: run on winning number. It is passed (winCount:Number, winners:Array, finalNumbers:Array)
easing : 'swing', // String: easing type for final spin. I recommend the easing plugin and easeOutSine, or an easeOut of your choice.
time : 7000, // Number: total time of spin animation
loops : 6 // Number: times it will spin during the animation
};</pre>
<h2 id="scroll_to_here">Usage</h2>
<p>Attach jQuery (successfully tested down to v1.4.1)</p>
<pre name="code" class="html">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script></pre>
<p>Attach jSlots plugin</p>
<pre name="code" class="html">
<script src="jquery.jSlots.js" charset="utf-8"></script></pre>
<p>Attach easing plugin (optional but HIGHLY recommended for nice animation)</p>
<pre name="code" class="html">
<script src="jquery.easing.1.3.js" charset="utf-8"></script></pre>
<p>Create a list and an element that will spin the slots</p>
<pre name="code" class="html">
<ul class="slot">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
<!-- this button will start the spin -->
<input type="button" id="playBtn" value="play"></pre>
<p>Target the list and make it a jSlot!</p>
<pre name="code" class="html">
<script type="text/javascript" charset="utf-8">
$('.slot').jSlots({
spinner : '#playBtn',
winnerNumber : 7
});
</script></pre>
<p>Styling is up to you, but jSlots supplies a jSlots-wrapper div around your lists that should get overflow: hidden and a height set on it. Here are some recommended styles:</p>
<pre name="code" class="css">
.jSlots-wrapper {
overflow: hidden; /* to hide the magic */
height: 20px; /* whatever the height of your list items are */
display: inline-block; /* to size width correctly, can use float too, or width*/
border: 1px solid #999;
}</pre>
</section>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="jquery.easing.1.3.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.jSlots.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// normal example
$('.normal .slot').jSlots({
spinner : '#playNormal',
winnerNumber : 7
});
// fancy example
$('.fancy .slot').jSlots({
number : 7,
winnerNumber : 1,
spinner : '#playFancy',
easing : 'easeOutSine',
time : 7000,
loops : 6,
onStart : function() {
$('.slot').removeClass('winner');
},
onWin : function(winCount, winners, finalNumbers) {
// only fires if you win
$.each(winners, function() {
this.addClass('winner');
});
// react to the # of winning slots
if ( winCount === 1 ) {
//alert('You got ' + winCount + ' 7!!!');
} else if ( winCount > 1 ) {
//alert('You got ' + winCount + ' 7’s!!!');
}
}
});
</script>
<!-- Syntax highlighting, ignore this -->
<script src="SyntaxHighlighter/Scripts/shCore.js" type="text/javascript" charset="utf-8"></script>
<script src="SyntaxHighlighter/Scripts/shBrushCss.js" type="text/javascript" charset="utf-8"></script>
<script src="SyntaxHighlighter/Scripts/shBrushJScript.js" type="text/javascript" charset="utf-8"></script>
<script src="SyntaxHighlighter/Scripts/shBrushXml.js" type="text/javascript" charset="utf-8"></script>
<script language="javascript">
dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code', false, false )//, [collapseAll], [firstLine], [showColumns] );
//HighlightAll(name, [showGutter], [showControls], [collapseAll], [firstLine], [showColumns])
</script>
<!-- /Syntax highlighting -->
</body>
</html>