-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
373 lines (344 loc) · 13.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
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Jquery-levelup by pstrinkle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" media="screen">
<!-- above the fold, it is render-blocking deliberately. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="dist/jquery.levelup.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<style>
.fun_times {
background-color: lightblue;
color: #FFA500;
box-shadow: 0 0 10px 10px #fff;
}
</style>
</head>
<body>
<section class="page-header">
<h1 class="project-name">jquery-levelup</h1>
<h2 class="project-tagline">Simple +1/-1 Animation similar to point accumulation in a video game</h2>
<a href="https://github.com/pstrinkle/jquery-levelup" class="btn">View on GitHub</a>
<a href="https://github.com/pstrinkle/jquery-levelup/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/pstrinkle/jquery-levelup/tarball/master" class="btn">Download .tar.gz</a>
</section>
<section class="main-content">
<h3><a id="basics" class="anchor" href="#basics" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>The Basics</h3>
<p>This jQuery plugin provides a basic +1/-1 animation to a number styled similar to how scores were updated in old video games.</p>
<h3>Installation</h3>
<p>Basically just include the file.
<pre class="prettyprint lang-html">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/libs/jquery-levelup/jquery.levelup.min.js"></script>
<span>counter <span style="font-weight: bold;" id='the_cnt'>0</span></span>
<script>
var $tc = $('#the_cnt');
$tc.levelup({'start' : 0});
$('#incrementBtn').on('click', function(event) {
$tc.levelup('increment', 1);
$(this).blur();
});
$('#decrementBtn').on('click', function(event) {
$tc.levelup('decrement', 1);
$(this).blur();
});
</script>
</pre>
<h3>Usage</h3>
<div>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>start</td>
<td>integer</td>
<td><code>0</code></td>
<td>Start value for span.</td>
</tr>
<tr>
<td><i>incrementer|decrementer</i>.bold</td>
<td>boolean</td>
<td>true</td>
<td>Whether the incrementer|decrementer is bold</td>
</tr>
<tr>
<td><i>incrementer|decrementer</i>.color</td>
<td>CSS color string</td>
<td>null</td>
<td>Change the incrementer|decrementer's text color</td>
</tr>
<tr>
<td><i>incrementer|decrementer</i>.class</td>
<td>string</td>
<td>null</td>
<td>Add a class to the incrementer|decrementer element</td>
</tr>
<tr>
<td>showThousands</td>
<td>boolean</td>
<td><code>false</code></td>
<td>Whether to use a thousands separate everywhere.</td>
</tr>
<tr>
<td>thousandSep</td>
<td>strings</td>
<td><code>,</code></td>
<td>The thousand separator to use.</td>
</tr>
</tbody>
</table>
</div>
<br />
<table class="table">
<thead>
<tr>
<th>Methods</th>
<th>Param</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>'increment'</code></td>
<td>integer by which to increment</td>
</tr>
<tr>
<td><code>'decrement'</code></td>
<td>absolute value of integer by which to decrement (always positive)</td>
</tr>
<tr>
<td><code>'reset'</code></td>
<td></td>
</tr>
<tr>
<td><code>'get'</code></td>
<td></td>
</tr>
</tbody>
</table>
<h3>Demos</h3>
<p>I will put a few demos here.</p>
<h4>Basic Demo</h4>
<p>It was originally written as just a small JavaScript animation and this version
is effectively what I started with before adding features.</p>
<div class="btn-area">
<p>
<span id='basic_1'></span> -
<button id='incrementBtn' class="btn2">increment</button> -
<button id='decrementBtn' class="btn2">decrement</button>
</p>
</div>
<pre class="prettyprint lang-js">$('#basic_1').levelup('increment', 1);</pre>
<script>
$(function() {
$('#basic_1').levelup({'start' : 0});
$('#incrementBtn').on('click', function(event) {
$('#basic_1').levelup('increment', 1);
$(this).blur();
});
$('#decrementBtn').on('click', function(event) {
$('#basic_1').levelup('decrement', 1);
$(this).blur();
});
});
</script>
<h4>Increment by bigger value</h4>
<p>The increment and decrement methods allow for other values.</p>
<div class="btn-area">
<p>
<span id='basic_2'></span> -
<button id='incrementBtn_2' class="btn2">increment</button> -
<button id='decrementBtn_2' class="btn2">decrement</button>
</p>
</div>
<pre class="prettyprint lang-js">
$('#basic_2').levelup('increment', 10);
$('#basic_2').levelup('decrement', 7);</pre>
<script>
$(function() {
$('#basic_2').levelup({'start' : 0});
$('#incrementBtn_2').on('click', function(event) {
$('#basic_2').levelup('increment', 10);
$(this).blur();
});
$('#decrementBtn_2').on('click', function(event) {
$('#basic_2').levelup('decrement', 7);
$(this).blur();
});
});
</script>
<h4>Non-bold option</h4>
<p>The incrementer and decrementer are bold by default, but you can turn that off</p>
<div class="btn-area">
<p>
<span id='basic_3'></span> -
<button id='incrementBtn_3' class="btn2">increment</button> -
<button id='decrementBtn_3' class="btn2">decrement</button>
</p>
</div>
<pre class="prettyprint lang-js">
$('#basic_3').levelup({'start' : 0, 'incrementer' : {'bold' : false}});
$('#basic_3').levelup('increment', 10);
$('#basic_3').levelup('decrement', 7);</pre>
<script>
$(function() {
$('#basic_3').levelup({'start' : 0,
'incrementer' : {'bold' : false}});
$('#incrementBtn_3').on('click', function(event) {
$('#basic_3').levelup('increment', 10);
$(this).blur();
});
$('#decrementBtn_3').on('click', function(event) {
$('#basic_3').levelup('decrement', 7);
$(this).blur();
});
});
</script>
<h4>Controlling the color</h4>
<p>You can specify the text color. This can be done via a class as well, but
this is for those who simply wish to control one aspect of it.</p>
<div class="btn-area">
<p>
<span id='basic_4'></span> -
<button id='incrementBtn_4' class="btn2">increment</button>
</p>
</div>
<pre class="prettyprint lang-js">
$('#basic_4').levelup({'start' : 0, 'incrementer' : {'color' : 'red'}});
$('#basic_4').levelup('increment', 10);
</pre>
<script>
$(function() {
$('#basic_4').levelup({'start' : 0,
'incrementer' : {'color' : 'red'}});
$('#incrementBtn_4').on('click', function(event) {
$('#basic_4').levelup('increment', 10);
$(this).blur();
});
});
</script>
<h4>Controlling the class</h4>
<p>You can style the incrementer/decrementer however you like via a class.</p>
<div class="btn-area">
<p>
<span id='basic_5'></span> -
<button id='incrementBtn_5' class="btn2">increment</button>
</p>
</div>
<pre class="prettyprint lang-css">
<style>
.fun_times {
background-color: lightblue;
color: #FFA500;
box-shadow: 0 0 10px 10px #fff;
}
</style>
</pre>
<pre class="prettyprint lang-js">
$('#basic_5').levelup({'start' : 0, 'incrementer' : {'class' : 'fun_times'}});
$('#basic_5').levelup('increment', 10);
</pre>
<script>
$(function() {
$('#basic_5').levelup({'start' : 0,
'incrementer' : {'class' : 'fun_times'}});
$('#incrementBtn_5').on('click', function(event) {
$('#basic_5').levelup('increment', 10);
$(this).blur();
});
});
</script>
<h4>Controlling the thousands separator</h4>
<p>You can set the thousands separator as anything you want. It is off by default.</p>
<div class="btn-area">
<p>
<span id='basic_6'></span> -
<button id='incrementBtn_6' class="btn2">increment</button>
</p>
</div>
<pre class="prettyprint lang-js">
$('#basic_6').levelup({'start' : 1111, 'showThousands' : true});
$('#basic_6').levelup('increment', 5555);
</pre>
<script>
$(function() {
$('#basic_6').levelup({'start' : 1111, 'showThousands' : true});
$('#incrementBtn_6').on('click', function(event) {
$('#basic_6').levelup('increment', 5555);
$(this).blur();
});
});
</script>
<h4>Accumulator is not span - still must be inline display type</h4>
<p>If you don't use a span, which is inlined, you'll need to manually inline the type. This is
a temporary fix that relates to where it lines up the animation.</p>
<div class="btn-area">
<div>
<h3 id='basic_7' style='display:inline'></h3>
<button id='incrementBtn_7' class="btn2">increment</button>
</div>
</div>
<pre class="prettyprint lang-js">
$('#basic_7').levelup({'start' : 1111, 'showThousands' : true});
$('#basic_7').levelup('increment', 5555);
</pre>
<script>
$(function() {
$('#basic_7').levelup({'start' : 1111, 'showThousands' : true});
$('#incrementBtn_7').on('click', function(event) {
$('#basic_7').levelup('increment', 5555);
$(this).blur();
});
});
</script>
<h4>Value Accessor</h4>
<p>You'll want to use this to get the value instead of reading the text,
because the text could be out of date.</p>
<div class="btn-area">
<p>
<span id='basic_8'></span> -
<button id='incrementBtn_8' class="btn2">increment</button> -
<button id='readBtn_8' class="btn2">Get Value</button> :
<span id='valueResult_8'></span>
</p>
</div>
<pre class="prettyprint lang-js">$('#basic_8').levelup('get');</pre>
<script>
$(function() {
$('#basic_8').levelup({'start' : 0});
$('#incrementBtn_8').on('click', function(event) {
$('#basic_8').levelup('increment', 1);
$(this).blur();
});
$('#readBtn_8').on('click', function(event) {
var value = $('#basic_8').levelup('get');
$('#valueResult_8').text(value);
$(this).blur();
});
});
</script>
<h3>License</h3>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></p>
<footer class="site-footer">
<!-- <span class="site-footer-owner"><a href="https://github.com/pstrinkle/jquery-levelup">Jquery-levelup</a> is maintained by <a href="https://github.com/pstrinkle">pstrinkle</a>.</span> -->
<a href="https://twitter.com/YammyCozonac" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @YammyCozonac</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<a class="github-button" href="https://github.com/pstrinkle" data-style="mega" aria-label="Follow @pstrinkle on GitHub">Follow @pstrinkle</a>
<!-- <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span> -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</footer>
</section>
</body>
</html>