forked from weareoutman/clockpicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
464 lines (446 loc) · 12.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
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ClockPicker</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="dist/bootstrap-clockpicker.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/github.min.css">
<style type="text/css">
.navbar h3 {
color: #f5f5f5;
margin-top: 14px;
}
.hljs-pre {
background: #f8f8f8;
padding: 3px;
}
.footer {
border-top: 1px solid #eee;
margin-top: 40px;
padding: 40px 0;
}
.input-group {
width: 110px;
margin-bottom: 10px;
}
.pull-center {
margin-left: auto;
margin-right: auto;
}
@media (min-width: 768px) {
.container {
max-width: 730px;
}
}
@media (max-width: 767px) {
.pull-center {
float: right;
}
}
</style>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<ul class="nav navbar-nav pull-right">
<li><a href="https://github.com/weareoutman/clockpicker">Fork me on GitHub</a></li>
</ul>
<h3>ClockPicker</h3>
</div>
</div>
<div class="container">
<p class="lead">
A clock-style timepicker for Bootstrap (or jQuery).
<a href="https://travis-ci.org/weareoutman/clockpicker"><img src="https://travis-ci.org/weareoutman/clockpicker.svg" alt="Build Status" data-canonical-src="https://travis-ci.org/weareoutman/clockpicker.svg" style="max-width:100%;"></a>
</p>
<p>
<a href="https://github.com/weareoutman/clockpicker/archive/gh-pages.zip" class="btn btn-lg btn-default" target="_blank">
<span class="glyphicon glyphicon-cloud-download"></span> Download ZIP
</a>
CSS < 6KB, JS < 9KB, after minified.
</p>
<h3>Browser support</h3>
<p>
All major browsers are supported, including IE 9+. It should look and behave well enough in IE 8.
</p>
<h3>Device support</h3>
<p>
Both desktop and mobile device are supported. It also works great in touch screen device.
</p>
<h3>Dependencies</h3>
<p>
ClockPicker was designed for Bootstrap in the beginning. So Bootstrap (and jQuery) is the only dependency(s).
</p>
<p>
Since it only used <code>.popover</code> and some of <code>.btn</code> styles of Bootstrap, I picked these styles to build a jQuery plugin.
Feel free to use <code>jquery-*</code> files instead of <code>bootstrap-*</code> , for non-bootstrap project.
</p>
<p>
<a href="jquery.html">See ClockPicker for jQuery</a>.
</p>
<h3>Examples</h3>
<a href="http://jsfiddle.net/weareoutman/YkvK9/">Try it on jsfiddle</a>
<div class="form-group">
<h4>Default: </h4>
<div class="input-group clockpicker">
<input type="text" class="form-control" value="09:30">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<pre class="hljs-pre"><code class="html"><div class="input-group clockpicker">
<input type="text" class="form-control" value="09:30">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<script type="text/javascript">
$('.clockpicker').clockpicker();
</script></code></pre>
</div>
<div class="form-group">
<h4>Place at left, align the arrow to top, auto close:</h4>
<div class="clearfix">
<div class="input-group clockpicker pull-center" data-placement="left" data-align="top" data-autoclose="true">
<input type="text" class="form-control" value="13:14">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<pre class="hljs-pre"><code class="html"><div class="input-group clockpicker" data-placement="left" data-align="top" data-autoclose="true">
<input type="text" class="form-control" value="13:14">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<script type="text/javascript">
$('.clockpicker').clockpicker();
</script></code></pre>
</div>
<div class="form-group">
<h4>Set options in javascript, instead of <code>data-*</code> :</h4>
<div class="input-group clockpicker" data-placement="top" data-align="left" data-donetext="Done">
<input type="text" class="form-control" value="18:00">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<pre class="hljs-pre"><code class="html"><div class="input-group clockpicker">
<input type="text" class="form-control" value="18:00">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<script type="text/javascript">
$('.clockpicker').clockpicker({
placement: 'top',
align: 'left',
donetext: 'Done'
});
</script></code></pre>
</div>
<div class="form-group">
<h4>Set default value, input without addon, and manual operations:</h4>
<div class="clearfix">
<div class="pull-center clearfix" style="margin-bottom:10px;">
<button type="button" class="btn btn-default pull-right" id="check-minutes">Check the minutes</button>
<input class="form-control pull-right" id="single-input" value="" placeholder="Now" style="width:80px;margin-right:20px;">
</div>
</div>
<pre class="hljs-pre"><code class="html"><input class="form-control" id="single-input" value="" placeholder="Now">
<button type="button" id="check-minutes">Check the minutes</button>
<script type="text/javascript">
var input = $('#single-input').clockpicker({
placement: 'bottom',
align: 'left',
autoclose: true,
'default': 'now'
});
// Manually toggle to the minutes view
$('#check-minutes').click(function(e){
// Have to stop propagation here
e.stopPropagation();
input.clockpicker('show')
.clockpicker('toggleView', 'minutes');
});
</script></code></pre>
</div>
<div class="form-group">
<h4>Callbacks:</h4>
<div class="clearfix">
<div class="input-group clockpicker-with-callbacks">
<input type="text" class="form-control" value="10:10">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
<pre class="hljs-pre">
<code class="html">
<input class="form-control" id="single-input" value="" placeholder="Now">
<script type="text/javascript">
var input = $('.clockpicker-with-callbacks').clockpicker({
donetext: 'Done',
init: function() {
console.log("colorpicker initiated");
},
beforeShow: function() {
console.log("before show");
},
afterShow: function() {
console.log("after show");
},
beforeHide: function() {
console.log("before hide");
},
afterHide: function() {
console.log("after hide");
},
beforeHourSelect: function() {
console.log("before hour selected");
},
afterHourSelect: function() {
console.log("after hour selected");
},
beforeDone: function() {
console.log("before done");
},
afterDone: function() {
console.log("after done");
}
});
// Manually toggle to the minutes view
$('#check-minutes').click(function(e){
// Have to stop propagation here
e.stopPropagation();
input.clockpicker('show')
.clockpicker('toggleView', 'minutes');
});
</script>
</code>
</pre>
</div>
<h3>Options</h3>
<table class="table table-bordered table-striped">
<thead><tr>
<th>Name</th>
<th>Default</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td>default</td>
<td>''</td>
<td>default time, 'now' or '13:14' e.g.</td>
</tr>
<tr>
<td>placement</td>
<td>'bottom'</td>
<td>popover placement</td>
</tr>
<tr>
<td>align</td>
<td>'left'</td>
<td>popover arrow align</td>
</tr>
<tr>
<td>donetext</td>
<td>'完成'</td>
<td>done button text</td>
</tr>
<tr>
<td>autoclose</td>
<td>false</td>
<td>auto close when minute is selected</td>
</tr>
<tr>
<td>vibrate</td>
<td>true</td>
<td>vibrate the device when dragging clock hand</td>
</tr>
<tr>
<td>fromnow</td>
<td>0</td>
<td>set default time to * milliseconds from now (using with default = 'now')</td>
</tr>
<tr>
<td>init</td>
<td></td>
<td>callback function triggered after the colorpicker has been initiated</td>
</tr>
<tr>
<td>beforeShow</td>
<td></td>
<td>callback function triggered before popup is shown</td>
</tr>
<tr>
<td>afterShow</td>
<td></td>
<td>callback function triggered after popup is shown</td>
</tr>
<tr>
<td>beforeHide</td>
<td></td>
<td>callback function triggered before popup is hidden<br/>
<b>Note:</b> <i>will be triggered between a beforeDone and afterDone</i>
</td>
</tr>
<tr>
<td>afterHide</td>
<td></td>
<td>callback function triggered after popup is hidden<br/>
<b>Note:</b> <i>will be triggered between a beforeDone and afterDone</i>
</td>
</tr>
<tr>
<td>beforeHourSelect</td>
<td></td>
<td>callback function triggered before user makes an hour selection</td>
</tr>
<tr>
<td>afterHourSelect</td>
<td></td>
<td>callback function triggered after user makes an hour selection</td>
</tr>
<tr>
<td>beforeDone</td>
<td></td>
<td>callback function triggered before time is written to input</td>
</tr>
<tr>
<td>afterDone</td>
<td></td>
<td>callback function triggered after time is written to input</td>
</tr>
</tbody>
</table>
<h3>Operations</h3>
<table class="table table-bordered table-striped">
<thead><tr>
<th>operation</th>
<th>Arguments</th>
<th>Description</th>
</tr></thead>
<tbody>
<tr>
<td>show</td>
<td></td>
<td>show the clockpicker</td>
</tr>
<tr>
<td>hide</td>
<td></td>
<td>hide the clockpicker</td>
</tr>
<tr>
<td>remove</td>
<td></td>
<td>remove the clockpicker (and event listeners)</td>
</tr>
<tr>
<td>toggleView</td>
<td>'hours' or 'minutes'</td>
<td>toggle to hours or minutes view</td>
</tr>
</tbody>
</table>
<h3>What's included</h3>
<pre class="hljs-pre"><code class="bash">clockpicker/
├── dist/
│ ├── bootstrap-clockpicker.css # full code for bootstrap
│ ├── bootstrap-clockpicker.js
│ ├── bootstrap-clockpicker.min.css # compiled and minified files for bootstrap
│ ├── bootstrap-clockpicker.min.js
│ ├── jquery-clockpicker.css # full code for jquery
│ ├── jquery-clockpicker.js
│ ├── jquery-clockpicker.min.css # compiled and minified files for jquery
│ └── jquery-clockpicker.min.js
└── src/ # source code
├── clockpicker.css
├── clockpicker.js
└── standalone.css # some styles picked from bootstrap</code></pre>
<h3>License</h3>
<p>MIT</p>
</div>
<div class="container">
<div class="footer">
<p>
© Wang Shenwei.
<a href="https://github.com/weareoutman/clockpicker">Fork me on GitHub</a>
</p>
</div>
</div>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="dist/bootstrap-clockpicker.min.js"></script>
<script type="text/javascript">
$('.clockpicker').clockpicker()
.find('input').change(function(){
console.log(this.value);
});
var input = $('#single-input').clockpicker({
placement: 'bottom',
align: 'left',
autoclose: true,
'default': 'now'
});
$('.clockpicker-with-callbacks').clockpicker({
donetext: 'Done',
init: function() {
console.log("colorpicker initiated");
},
beforeShow: function() {
console.log("before show");
},
afterShow: function() {
console.log("after show");
},
beforeHide: function() {
console.log("before hide");
},
afterHide: function() {
console.log("after hide");
},
beforeHourSelect: function() {
console.log("before hour selected");
},
afterHourSelect: function() {
console.log("after hour selected");
},
beforeDone: function() {
console.log("before done");
},
afterDone: function() {
console.log("after done");
}
})
.find('input').change(function(){
console.log(this.value);
});
// Manually toggle to the minutes view
$('#check-minutes').click(function(e){
// Have to stop propagation here
e.stopPropagation();
input.clockpicker('show')
.clockpicker('toggleView', 'minutes');
});
if (/mobile/i.test(navigator.userAgent)) {
$('input').prop('readOnly', true);
}
</script>
<script type="text/javascript" src="assets/js/highlight.min.js"></script>
<script type="text/javascript">
hljs.configure({tabReplace: ' '});
hljs.initHighlightingOnLoad();
</script>
</body>
</html>