This repository has been archived by the owner on May 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
468 lines (376 loc) · 20 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
465
466
467
468
<!DOCTYPE html>
<!-- saved from url=(0073)http://jquerytimepicker.local/render-index.php?codekitCB=404921296.853070 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>timePicker jQuery plugin</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="http://jquerytimepicker.local/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" type="text/css" media="all" href="./index_files/jquery.timepicker.css">
<style>
.BSDatePicker {margin-bottom: 1em;}
.BSDatePickerPrev,
.BSDatePickerNext {cursor: pointer; display: inline-block; font-size: 3em; text-align: center; vertical-align: middle;
-webkit-user-select: none; /* webkit (safari, chrome) browsers */
-moz-user-select: none; /* mozilla browsers */
-khtml-user-select: none; /* webkit (konqueror) browsers */
-ms-user-select: none; /* IE10+ */
}
.BSDatePickerDate {cursor: pointer; display: inline-block; margin-right: .236em; padding: 1em; text-align: center; width: 5em;}
.BSDatePickerDate small {display: block;}
.BSDatePickerDate b {display: block; font-size: 2em;}
.BSTimePickerTime {display: inline-block; margin-right: .236em; padding: .236em 1em; text-align: center;}
.BSTimePickerTime small {display: block;}
.BSTimePickerTime b {display: block; font-size: 2em;}
.BSTimePickerTime select { margin-top: .618em; width: 100%;}
#dl-settings {margin-bottom: 5em;}
#dl-settings dl {line-height: 1em; margin: 0;}
#dl-settings dt {font-size: 1.382em;}
#dl-settings dd {margin-left: 4em;}
#dl-settings i {color: #999; font-size: .82em; font-weight: normal;}
</style>
<style>[touch-action="none"]{ -ms-touch-action: none; touch-action: none; }[touch-action="pan-x"]{ -ms-touch-action: pan-x; touch-action: pan-x; }[touch-action="pan-y"]{ -ms-touch-action: pan-y; touch-action: pan-y; }[touch-action="scroll"],[touch-action="pan-x pan-y"],[touch-action="pan-y pan-x"]{ -ms-touch-action: pan-x pan-y; touch-action: pan-x pan-y; }</style></head>
<body style="">
<div class="container">
<h1>TimePicker plugin for jQuery</h1>
<p class="lead">Built by <a href="http://gelform.com/" target="_blank">Gelform</a></p>
<p>
This plugin is for letting a user choose dates and then corresponding times. I built it to allow users to let me know when they're available for phone calls.
</p>
<p>
The time pickers return an array of dates containing a date (in yyyy-mm-dd format) and 24-hour time (hh:mm), by default. Here's what it would look like in PHP:
</p><pre><code>
$schedule = array (
"1381107061051" => array (
"date" => "2013-10-06",
"time" => "07:00"
),
"1381193461051" => array (
"date" => "2013-10-07",
"time" => "15:00"
),
"1381279861051" => array (
"date" => "2013-10-08",
"time" => "16:00"
)
);
</code></pre>
<p></p>
<p>
<a href="https://github.com/coreymaass/timePicker" target="_blank" class="btn btn-primary">Download it from Github</a>
</p>
<hr>
<h2>Examples:</h2>
<h3>Basic</h3>
<p>Here's a basic example:</p>
<div class="well" id="basic"><div class="TPDatePicker" data-tp-role="datePicker"><p class="TPDatePickerHtmlBefore" data-tp-role="datePickerHtmlBefore">First, choose three dates:</p><span class="TPDatePickerPrev" data-tp-role="datePickerPrev">◀</span><span class="TPDatePickerDates" data-tp-role="datePickerDates"><span class="TPDatePickerDate" data-date="1383231870049" data-tp-role="datePickerDate"><small>Oct</small> <b>31</b> <small>Thu</small></span><span class="TPDatePickerDate" data-date="1383318270049" data-tp-role="datePickerDate"><small>Nov</small> <b>1</b> <small>Fri</small></span><span class="TPDatePickerDate" data-date="1383404670049" data-tp-role="datePickerDate"><small>Nov</small> <b>2</b> <small>Sat</small></span><span class="TPDatePickerDate" data-date="1383494670049" data-tp-role="datePickerDate"><small>Nov</small> <b>3</b> <small>Sun</small></span><span class="TPDatePickerDate" data-date="1383581070049" data-tp-role="datePickerDate"><small>Nov</small> <b>4</b> <small>Mon</small></span></span><span class="TPDatePickerNext" data-tp-role="datePickerNext">▶</span></div><div class="TPTimePicker" data-tp-role="timePicker"><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span></div></div>
<p>All this requires is:</p>
<pre><code>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/jquery.timepicker.css" />
</head>
<body>
<div id="basic"></div>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="js/jquery.timepicker.min.js"></script>
<script>
$(document).ready(function(){
$('#basic').timePicker();
});
</script>
</body>
</html> </code></pre>
<hr>
<h3>Bootstrap</h3>
<p>Here's a bootstrap integration example:</p>
<div class="well" id="bootstrap"><div class="BSDatePicker" data-tp-role="datePicker"><p class="TPDatePickerHtmlBefore" data-tp-role="datePickerHtmlBefore">First, choose three dates:</p><span class="BSDatePickerPrev" data-tp-role="datePickerPrev">◀</span><span class="btn-group BSDatePickerDates" data-toggle="buttons-checkbox" data-tp-role="datePickerDates"><button type="button" class="btn BSDatePickerDate" data-date="1383836670072" data-tp-role="datePickerDate"><small>Nov</small> <b>7</b> <small>Thu</small></button><button type="button" class="btn BSDatePickerDate" data-date="1383923070072" data-tp-role="datePickerDate"><small>Nov</small> <b>8</b> <small>Fri</small></button><button type="button" class="btn BSDatePickerDate" data-date="1384009470072" data-tp-role="datePickerDate"><small>Nov</small> <b>9</b> <small>Sat</small></button><button type="button" class="btn BSDatePickerDate" data-date="1384095870072" data-tp-role="datePickerDate"><small>Nov</small> <b>10</b> <small>Sun</small></button><button type="button" class="btn BSDatePickerDate" data-date="1384182270072" data-tp-role="datePickerDate"><small>Nov</small> <b>11</b> <small>Mon</small></button></span><span class="BSDatePickerNext" data-tp-role="datePickerNext">▶</span></div><div class="TPTimePicker" data-tp-role="timePicker"></div></div>
<p>
We'll change a few things to make this work. First, we'll make the dates wrapper a button group, and each date a button. Similarly, we'll make each time picker a Bootstrap well. We could've also just changed the class.
</p>
<p>
The gotcha is changing the "selectedClassName" (the class added to each date when it's selected) to "active" to match Bootstrap. FInally we want to set "addSelectedClassOnClick" to false. Bootstrap will automatically add the class "active" to a clicked button, so we don't want our plugin to toggle it, which will turn it off.
</p>
<pre><code>
// get today
var today = new Date();
// set a start date a week from now
var todayPlus7 = new Date(today.getTime() + (24 * 60 * 60 * 1000)*7);
$('#bootstrap').timePicker({
datePicker: {
startDate: todayPlus7,
dates: {
html: '<span class=" btn-group" data-toggle="buttons-checkbox" />',
},
date: {
html: '<button type="button" class="btn" />',
selectedClassName: 'active',
addSelectedClassOnClick: false
}
},
timePicker: {
showPlaceholders: false,
time: {
html: '<span class="well" />',
}
}
}); </code></pre>
<p>These settings are available like this, too:</p>
<pre><code>
$.fn.timePicker.defaults.datePicker.startDate = todayPlus7;
$.fn.timePicker.defaults.datePicker.date.html = '<button type="button" class="btn" />';
$.fn.timePicker.defaults.datePicker.date.selectedClassName = 'active';
$.fn.timePicker.defaults.datePicker.date.addSelectedClassOnClick = false;
$.fn.timePicker.defaults.timePicker.time.html = '<span class="well" />';
$.fn.timePicker.defaults.timePicker.showPlaceholders = false;
$('#bootstrap').timePicker(); </code></pre>
<hr>
<h3>Callback</h3>
<p>Here's a callback example:</p>
<div class="well">
<p id="callback"><div class="TPDatePicker" data-tp-role="datePicker"><p class="TPDatePickerHtmlBefore" data-tp-role="datePickerHtmlBefore">First, choose three dates:</p><span class="TPDatePickerPrev" data-tp-role="datePickerPrev">◀</span><span class="TPDatePickerDates" data-tp-role="datePickerDates"><span class="TPDatePickerDate" data-date="1383231870049" data-tp-role="datePickerDate"><small>Oct</small> <b>31</b> <small>Thu</small></span><span class="TPDatePickerDate" data-date="1383318270049" data-tp-role="datePickerDate"><small>Nov</small> <b>1</b> <small>Fri</small></span><span class="TPDatePickerDate" data-date="1383404670049" data-tp-role="datePickerDate"><small>Nov</small> <b>2</b> <small>Sat</small></span><span class="TPDatePickerDate" data-date="1383494670049" data-tp-role="datePickerDate"><small>Nov</small> <b>3</b> <small>Sun</small></span><span class="TPDatePickerDate" data-date="1383581070049" data-tp-role="datePickerDate"><small>Nov</small> <b>4</b> <small>Mon</small></span></span><span class="TPDatePickerNext" data-tp-role="datePickerNext">▶</span></div><div class="TPTimePicker" data-tp-role="timePicker"><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span><span class="TPTimePickerPlaceholder" data-tp-role="timePickerPlaceholder"><small>Please</small><small>Pick</small> <b>3</b></span></div></p>
<p>
<button id="btn-callback" type="button" disabled="disabled" class="btn btn-large">Disabled until 3 are selected</button>
</p>
</div>
<p>For this we need a timepicker (in this case #callback) and a disabled button:</p>
<pre><code>
<!-- our html, including a disabled button -->
<p id="callback"></p>
<p>
<button id="btn-callback" type="button" disabled="disabled">Disabled until 3 are selected</button>
</p> </code></pre>
<p>Then we define our callback when we instantiate our time picker:</p>
<pre><code>
// instantiate the timepicker
$('#callback').timePicker({
datePicker: {
date: {
// trigger this whenever a date item is clicked
finished: function(){
// get our whole date picker element
var $wrapper = $('#callback');
// get the timepickers element
var $timePickers = $('[data-tp-role=timePickerTime]', $wrapper);
// if there are 3 of them, we're good!
if ( $timePickers.length >= 3 )
{
// enable our button, and change the text
$('#btn-callback')
.prop('disabled', '')
.text('3 selected!');
}
else
{
// not enough dates selected, change the button back
$('#btn-callback')
.prop('disabled', 'disabled')
.text('Disabled until 3 are selected');
}
}
}
}
}); </code></pre>
<hr>
<h2>Settings:</h2>
<p>Here's an explaination of the available settings:</p>
<dl id="dl-settings">
<dt>numberOfTimes <i>Int</i></dt>
<dd>The number of times you want to allow people to select. default: 3</dd>
<dt>fieldName <i>Str</i></dt>
<dd>The name of the array passed when the form gets submitted. default: schedule</dd>
<dt>datePicker:</dt>
<dd>
The element that contains the prev, next buttons, and the calendar boxes
<dl>
<dt>startDate <i>Date Obj</i></dt>
<dd>A date object of the date you want to start from. default: new Date()</dd>
<dt>numOfDates <i>Int</i></dt>
<dd>How many calendar boxes to show between the prev and next buttons. default: 5</dd>
<dt>allowPastDates <i>Bool</i></dt>
<dd>Set to true if you want to allow users to choose dates before today. default: false</dd>
<dt>wrapper:</dt>
<dd>
<dl>
<dt>htmlBefore <i>Html</i></dt>
<dd>A message that appears above the date picker. Use this like a label. NOTE: MUST BE HTML, NOT JUST TEXT. default: <p>First, choose three dates:</p></dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should wrap the date picker elements. default: <div /></dd>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the date picker element, for styling. default: TPDatePicker</dd>
</dl>
</dd><dt>prev:</dt>
<dd>
This is the button that moves the dates back a day.
<dl>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the prev element, for styling. default: TPDatePickerPrev</dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should the button be. default: <span /></dd>
<dt>text <i>Html</i></dt>
<dd>What html or text should be in the prev element. default: &#9664;</dd>
<dt>clicked <i>Func</i></dt>
<dd>A callback triggerd when the prev element has been clicked, but BEFORE the dates are rendered. this = the $datePickerPrev element</dd>
<dt>finished <i>Func</i></dt>
<dd>A callback triggered after the new dates have been rendered. this = the $datePickerPrev just clicked</dd>
</dl>
</dd>
<dt>dates:</dt>
<dd>
<dl>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the element, for styling. default: TPDatePickerDates</dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should the dates wrapper be. default: <span /></dd>
<dt>added <i>Func</i></dt>
<dd>A callback function triggered after the dates element have been added (only happens once). this = a jQuery array of the date elements just added</dd>
</dl>
</dd>
<dt>date:</dt>
<dd>
<dl>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the element, for styling. default: TPDatePickerDate</dd>
<dt>selectedClassName <i>Str</i></dt>
<dd>What class should be applied to each calendar box when it's selected. default: selected</dd>
<dt>addSelectedClassOnClick <i>Bool</i></dt>
<dd>For bootstrap and other frameworks. The selected class will only be applied when the prev or next buttons are clicked, but not when the element itself is clicked. Bootstrap already adds this class when it's clicked, so we don't want to toggle it again. default: true</dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should each calendar box be. default: <span /></dd>
<dt>text <i>Html</i></dt>
<dd>What html or text should be in each calendar box element. This uses the built in "template" function, which will populate the following variables: monthName, shortMonthName, dayName, shortDayName and date. default: <small>shortMonthName</small> <b>date</b> <small>shortDayName</small></dd>
<dt>Clicked <i>Func</i></dt>
<dd>A callback function triggered after the calendar box has been clicked, before anything else has happened. this = the $datePickerDate just clicked</dd>
<dt>Finished <i>Func</i></dt>
<dd>A callback function triggered after the corresponding time chooser box has been added. this = the $datePickerDate just clicked</dd>
</dl>
</dd>
<dt>next:</dt>
<dd>
<dl>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the element, for styling. default: TPDatePickerNext</dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should the button be. default: <span /></dd>
<dt>text <i>Html</i></dt>
<dd>What html or text should be in the next element. default: &#9654;</dd>
<dt>clicked <i>Func</i></dt>
<dd>A callback triggerd when the next element has been clicked, but BEFORE the dates are rendered. this = the $datePickerNext element</dd>
<dt>finished <i>Func</i></dt>
<dd>A callback triggered after the new dates have been rendered. this = the $datePickerNext just clicked</dd>
</dl>
</dd>
</dl>
</dd>
<dt>timePicker:</dt>
<dd>
<dl>
<dt>wrapper:</dt>
<dd>
<dl>
<dt>htmlBefore <i>Html</i></dt>
<dd>A message that appears above the times picker. Use this like a label. NOTE: MUST BE HTML, NOT JUST TEXT. default: <p>Now, please select your available times:</p></dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should the times wrapper be. default: <div /></dd>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the element, for styling. default: TPTimePicker</dd>
</dl>
</dd>
<dt>time:</dt>
<dd>
<dl>
<dt>className <i>Str</i></dt>
<dd>The class name that will be added to the element, for styling. default: TPTimePickerTime</dd>
<dt>preSelected <i>Str</i></dt>
<dd>What default time should be selected when a time chooser is added. default: 7:00am</dd>
<dt>startTime <i>Str</i></dt>
<dd>In 24h. The earliest time a user can choose. default: 6:00</dd>
<dt>endTime <i>Str</i></dt>
<dd>in 24h. The latest time a user can choose. default: 19:00</dd>
<dt>interval <i>Int</i></dt>
<dd>The interval between times, in minutes. (i.e. 15 = 7:15, 7:30, 7:45...) default: 15</dd>
<dt>selectFieldName <i>Str</i></dt>
<dd>The actually name attribute of the time select element <select name="time".... This is what gets submitted when the form gets submitted. default: time</dd>
<dt>html <i>Html</i></dt>
<dd>What kind of html element should each time box be. default: <span /></dd>
<dt>text <i>Html</i></dt>
<dd>What html or text should be in each time box element. This uses the built in "template" function, which will populate the following variables: monthName, shortMonthName, dayName, shortDayName and date. default: <small>shortMonthName</small> <b>date</b> <small>shortDayName</small></dd>
<dt>added <i>Func</i></dt>
<dd>A callback when a time chooser box has been added. this = the $timePickerTime just added.</dd>
<dt>removed <i>Func</i></dt>
<dd>A callback when a time chooser box has been removed. this = the $timePicker wrapper</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</div><!-- container -->
<script src="./index_files/jquery-1.10.1.min.js"></script>
<script src="./index_files/bootstrap.min.js"></script>
<script src="./index_files/jquery.timepicker.min.js"></script>
<script>
$(document).ready(function(){
$('#basic').timePicker();
var today = new Date();
// set a start date a week from now
var todayPlus7 = new Date(today.getTime() + (24 * 60 * 60 * 1000)*7);
$('#bootstrap').timePicker({
datePicker: {
startDate: todayPlus7,
wrapper: {
className: 'BSDatePicker'
},
prev: {
className: 'BSDatePickerPrev'
},
dates: {
html: '<span class=" btn-group" data-toggle="buttons-checkbox" />',
className: 'BSDatePickerDates'
},
date: {
html: '<button type="button" class="btn" />',
className: 'BSDatePickerDate',
selectedClassName: 'active',
addSelectedClassOnClick: false
},
next: {
className: 'BSDatePickerNext'
}
},
timePicker: {
showPlaceholders: false,
time: {
html: '<span class="well" />',
className: 'BSTimePickerTime'
},
placeholder: {
html: '<span class="well" />',
className: 'BSTimePickerPlaceholder'
}
}
});
$('#callback').timePicker({
datePicker: {
date: {
finished: function(){
var $wrapper = $('#callback');
var $timePickers = $('[data-tp-role=timePickerTime]', $wrapper);
if ( $timePickers.length >= 3 )
{
$('#btn-callback')
.prop('disabled', '')
.text('3 selected!');
}
else
{
$('#btn-callback')
.prop('disabled', 'disabled')
.text('Disabled until 3 are selected');
}
}
}
}
});
});
</script>
</body></html>