-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.jquery.html
More file actions
257 lines (223 loc) · 7.58 KB
/
example.jquery.html
File metadata and controls
257 lines (223 loc) · 7.58 KB
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
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css">
<link rel="stylesheet" href="build/jquery.countdown.css" />
<style>
/* RESET */
html, body, div, span, h1, h2, h3, h4, h5, h6, p, blockquote, a,
font, img, dl, dt, dd, ol, ul, li, legend, table, tbody, tr, th, td
{margin:0px;padding:0px;border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;list-style:none;}
a img {border: none;}
ol li {list-style: decimal outside;}
fieldset {border:0;padding:0;}
body { font-family: sans-serif; font-size: 1em; }
div#container { width: 780px; margin: 0 auto; padding: 1em 0; }
p { margin: 1em 0; max-width: 700px; }
h1 + p { margin-top: 0; }
h1, h2 { font-family: Georgia, Times, serif; }
h1 { font-size: 2em; margin-bottom: .75em; }
h2 { font-size: 1.5em; margin: 2.5em 0 .5em; border-bottom: 1px solid #999; padding-bottom: 5px; }
h3 { font-weight: bold; }
ul li { list-style: disc; margin-left: 1em; }
ol li { margin-left: 1.25em; }
div.side-by-side { width: 100%; margin-bottom: 1em; }
div.side-by-side > div { float: left; width: 50%; }
div.side-by-side > div > em { margin-bottom: 10px; display: block; }
a { color: #666; text-decoration: underline; }
.faqs em { display: block; }
pre.prettyprint, code.prettyprint {
margin-right: 10px;
border: none;
font-family: Monaco, monospace;
font-size: 12px;
padding: 3px 4px ;
border-radius: 3px;
border: 1px solid #CCC;
}
pre.prettyprint{
padding: 5px 6px ;
}
.lit { color: darkred }
.com { color: grey }
code .keyword { font-weight: bold }
code .string, code .regexp { color: green }
code .class, code .special { color: blue }
.clearfix:after {
content: "\0020";
display: block;
height: 0;
clear: both;
overflow: hidden;
visibility: hidden;
}
footer {
margin-top: 2em;
border-top: 1px solid #666;
padding-top: 5px;
}
/*
Custom Display
*/
.countdown.custom .digit{
border-radius: 3px;
background: #990000;
}
.countdown.custom .overlay{
height: 43px;
width: 263px;
position: absolute;
top: 0;
left: 0;
background-image: -webkit-gradient(linear, left bottom, left top,
color-stop(0, rgba(255,255,255,0)),
color-stop(0.50, rgba(255,255,255,.4)),
color-stop(1, rgba(255,255,255,0))
);
}
</style>
</head>
<body>
<div id="container">
<h1>Countdown</h1>
<p>Countdown is a JavaScript plugin to easily create counters and countdowns without images. For more information (including usage, explanation and faqs), check out <a href="http://github.com/fetch/countdown/">the project on GitHub</a>.</p>
<h2>Autostarting Countdowns</h2>
<div class=" clearfix">
<p>Countdowns can be any size. Options can be set through data-attributes or by an options object passed to the constructor.</p>
<div>
<div class="countdown" id="countdown-1" data-digits="20" data-duration="2000000" data-animate-to="1000000"></div>
<p><strong>With data-attributes:</strong></p>
<pre class="prettyprint">
<div class="countdown" data-digits="20" data-duration="2000000" data-animate-to="1000000"></div>
<script>
$('.countdown').countdown();
</script>
</pre>
<p><strong>With object in constructor:</strong></p>
<pre class="prettyprint">
<div class="countdown"></div>
<script>
$('.countdown').countdown({
digits: 20,
duration: 2000000,
animateTo: 1000000
});
</script>
</pre>
</div>
</div>
<h2>Manual starting Countdowns</h2>
<div class="side-by-side clearfix">
<p>Countdowns can be initiated with a number and target number.</p>
<div>
<div class="countdown" id="countdown-3" data-number="1000" data-duration="10000" ></div>
<p>Click to update the Countdown to <a href="javascript:;" data-target="countdown-3" data-animate-to="0">0</a> or <a href="javascript:;" data-target="countdown-3" data-animate-to="2000">2000</a></p>
<p><strong>Code:</strong></p>
<pre class="prettyprint">
$('a').on('click', function(){
$('.countdown').countdown('animateTo', 0);
});
</pre>
</div>
<div>
<div class="countdown" id="countdown-4" data-number="0" data-duration="1000" ></div>
<p>Click to <a href="javascript:;" data-target="countdown-4" data-animate-to="++1234">add 1234 to</a> or <a href="javascript:;" data-target="countdown-4" data-animate-to="--1234">substract 1234 from</a> the countdown</a></p>
<p><strong>Code:</strong></p>
<pre class="prettyprint">
$('a').on('click', function(){
$('.countdown').countdown('animateTo', '+1234');
});
</pre>
</div>
</div>
<h2>Countdown with callback</h2>
<div class="clearfix">
<div>
<div class="countdown countdown-revert" data-number="1000" data-duration="4000" data-animate-to="0" ></div>
<p><strong>Code:</strong></p>
<pre class="prettyprint">
$('.countdown').countdown().on('countdown:finished', function(event, data){
var _this = this;
setTimeout(function(){
// Pause for 1 second and then revert to previous value
$(_this).countdown('animateTo', data.old_value);
}, 1000);
});
</pre>
</div>
</div>
<h2>Countdown with custom display</h2>
<div class="clearfix">
<p>Customizing the looks of Countdown is very easy, just use CSS.</p>
<div>
<div class="countdown custom" ><div class="overlay"></div></div>
<p><strong>Code:</strong></p>
<pre class="prettyprint">
<div class="countdown custom">
<div class="overlay"></div>
</div>
<style>
.countdown .digit{
border-radius: 3px;
background: #990000;
}
.countdown .overlay{
height: 43px;
width: 263px;
position: absolute;
top: 0;
left: 0;
background-image: -webkit-gradient(linear, left bottom, left top,
color-stop( 0, rgba(255, 255, 255, 0)),
color-stop( .5, rgba(255, 255, 255, .4)),
color-stop( 1, rgba(255, 255, 255, 0))
);
}
</style>
</pre>
</div>
</div>
<h2>Change / Update Events</h2>
<div class="side-by-side clearfix">
<ul>
<li>
<h3>Countdown Finished</h3>
<p><code class="prettyprint">$('.countdown').countdown().on('countdown:finished', function(event, data){ … } );</code></p>
</li>
<li>
<h3>Countdown Stopped</h3>
<p><code class="prettyprint">$('.countdown').countdown().on('countdown:stopped', function(event, data){ … } );</code></p>
</li>
</ul>
</div>
<h2>Setup (for jQuery)</h2>
<p>Using Countdown is easy as can be.</p>
<ol>
<li>Download the plugin and copy the countdown files to your app.</li>
<li>Activate the plugin on any div of your choice: <code class="prettyprint">$('.countdown').countdown()</code></li>
<li>Modify countdown/countdown.css to change the look of your countdown.</li>
</ol>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript" ></script>
<script src="build/jquery.countdown.js" type="text/javascript"></script>
<script>
$(function(){
$('[data-target]').bind('click', function(event){
event.preventDefault();
var data = $(this).data();
data.animateTo = typeof data.animateTo == 'string' ? data.animateTo.replace('++', '+').replace('--', '-') : data.animateTo;
$('#' + data.target).countdown('animateTo', data.animateTo);
});
$('.countdown-revert').bind('countdown:finished', function(event, data){
var _this = this;
setTimeout(function(){
$(_this).countdown('animateTo', data.old_value);
}, 1000);
});
$('.countdown').countdown();
prettyPrint();
});
</script>
</body>
</html>