-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdocs.html
executable file
·782 lines (660 loc) · 33.4 KB
/
docs.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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="The pure JavaScript ultimate datepicker">
<meta name="author" content="MTR Design">
<meta name="keywords" content="datepicker, mtr datepicker, mtr design, pure javascript, javascript datepicker, js datepicker">
<title>Docs | MTR Datepicker - The pure JavaScript datepicker library</title>
<meta property="og:title" content="MTR Datepicker | Documentation - The pure JavaScript datepicker library" />
<meta property="og:description" content="MTR Datepicker is a library written in pure JavaScript which allows you to create great looking and lightweight datepickers for you web apps. It is supported by all of the modern internet browsers and comes with a few customizable themes." />
<meta property="og:url" content="http://mtrdesign.github.io/mtr-datepicker" />
<meta property="og:image" content="http://mtrdesign.github.io/mtr-datepicker/images/mtr-datepicker-screen.png" />
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="libs/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="demo/flatly.bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="libs/highlightjs/styles/xcode.css">
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="demo/jumbotron-narrow.css" />
<link rel="stylesheet" type="text/css" href="demo/blog.css" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=yyxxeK88Mx">
<link rel="icon" type="image/png" href="/images/favicons/favicon-32x32.png?v=yyxxeK88Mx" sizes="32x32">
<link rel="icon" type="image/png" href="/images/favicons/favicon-16x16.png?v=yyxxeK88Mx" sizes="16x16">
<link rel="manifest" href="/images/favicons/manifest.json?v=yyxxeK88Mx">
<link rel="mask-icon" href="/images/favicons/safari-pinned-tab.svg?v=yyxxeK88Mx" color="#5bbad5">
<link rel="shortcut icon" href="/images/favicons/favicon.ico?v=yyxxeK88Mx">
<meta name="apple-mobile-web-app-title" content="MTR Datepicker">
<meta name="application-name" content="MTR Datepicker">
<meta name="msapplication-config" content="/images/favicons/browserconfig.xml?v=yyxxeK88Mx">
<meta name="theme-color" content="#ffffff">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#navbar-scrollspy" data-offset="90">
<!-- Fork me button -->
<a href="https://github.com/mtrdesign/mtr-datepicker">
<img style="position: fixed; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" class="github-corner" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://mtrdesign.github.io/mtr-datepicker/">MTR Datepicker</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li role="presentation"><a href="demo.html#demo">Demo</a></li>
<li role="presentation" class="active"><a href="docs.html">Docs</a></li>
<li role="presentation"><a href="https://github.com/mtrdesign/mtr-datepicker" target="_blank">GitHub</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-10 col-sm-9 blog-main">
<div id="about" class="blog-post">
<h2 class="blog-post-title">About</h2>
<p>
MTR Datepicker is a library written in pure JavaScript which allows you to create great looking and lightweight datepickers for you web apps. It is supported by all of the modern internet browsers and comes with a few customizable themes.<br />
<br />
Use these docs to learn how to use it. If you are interested in that "How it is made?"
you can check the <a href="docs/MtrDatepicker.html" target="_blank">jsdocs</a> or directly dive into the
<a href="https://github.com/mtrdesign/mtr-datepicker/blob/master/scripts/mtr-datepicker.js" target="_blank">code</a>. We appreciate your feedback so you can contact us
always in the <a href="https://github.com/mtrdesign/mtr-datepicker/issues" target="_blank">issues</a> section. And don't forget to check the
<a href="#contribute">Contributions guide</a>, maybe you can help us to make the datepicker better.
</p>
</div><!-- /.blog-post about-->
<div id="installation" class="blog-post">
<h2 class="blog-post-title">Installation</h2>
<br />
<h3 id="installation-get-the-code">Get the code</h3>
<p>
There are two possible ways to include the mtr-datepicker library in your project.
You can <a href="https://github.com/mtrdesign/mtr-datepicker">download</a> the latest
stable release form the official site and include it in your templates. <br />
<br />
Or if you prefer to be up-to-date with our latest releases with a package manager you
can use <a href="http://npmjs.com/" target="_blank">NPM</a> or <a href="https://classic.yarnpkg.com/en/" target="_blank">Yarn</a>, just type in your
Terminal or CMD the following command:<br />
<pre><code>npm install --save mtr-datepicker</code></pre>
or
<pre><code>yarn add mtr-datepicker</code></pre>
</p>
<br />
<h3 id="installation-load-the-library">Load the library</h3>
<p>
First you need to load the styles of the datepicker. Put the following lines in
the <code>head</code> section of your html file or template:
</p>
<pre><code class="html">
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.min.css">
<link rel="stylesheet" type="text/css" href="dist/mtr-datepicker.default-theme.min.css">
</code></pre>
<p>Then you should load the JavaScript, we suggest you to put the lines at the bottom of the <code>body</code> section of your html file or template. That is all, now you are ready to initialize your first datepicker.</p>
<pre><code class="html">
<script type="text/javascript" src="dist/mtr-datepicker.min.js"></script>
</code></pre>
</div><!-- /.blog-post installation -->
<div id="how-to-use" class="blog-post">
<h2 class="blog-post-title">How to use</h2>
<p>
To use the loaded scripts just add an element with specific id to your html and then
tell the library to make it a datepicker. Here is a simple example:
</p>
<pre><code>
<div id="first-mtr-datepicker"></div>
<script>
var config = {
target: 'first-mtr-datepicker'
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<p>
You can use more advanced datepickers and customize their behavior.
To learn how, you should go and read more from the <a href="api">API</a> section of the docs.
</p>
</div><!-- /.blog-post getting-started -->
<div id="api" class="blog-post">
<h2 class="blog-post-title">API</h2>
<br />
<h2 id="api-init">Init</h2>
<br />
<p>
The datepicker comes with a rich configuration properties. This allows you to make it work the way you want.
You can pass an object with configuration settings on initialization of every of your datepickers.
And the cool part is that you can use the options combined, here is a list of all of them and their
default values. Read the docs to learn more about every one of them.
</p>
<pre><code>
var config = {
target: 'id-element', // ID of HTML element
timestamp: CURRENT_TIMESTAMP, // Starting date
future: false, // Only dates in the future,
smartHours: false, // Make a smart switch from AM to PM
animations: true, // NOTE: thew version with disabled animations is not stable
months: {
min: 0,
max: 11,
step: 1
},
minutes: {
min: 0,
max: 50,
step: 10
}
years: {
min: 2000,
max: 2030,
step: 1
}
};
var myDatepicker = new MtrDatepicker(config);
</code></pre>
<br />
<h3 id="api-init-default">Default</h3>
<p>
If you want to initialize the datepicker with its default behavior you don't have to do anything special.
Just refer to the <a href="#how-to-use">How to use</a> section.
</p>
<br />
<h3 id="api-init-starting-date">Set starting date</h3>
<p>
The default initialization behavior of the datepicker sets the current date as starting one.
If you want you can change this and make it to start with custom date simply by adding a timestamp.
Take a look at the example:
</p>
<pre><code>
<div id="start-date-mtr-datepicker"></div>
<script>
var initDate = new Date(2010, 10, 21);
var config = {
target: 'start-date-mtr-datepicker',
timestamp: initDate.getTime()
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-only-future-dates">Only future dates</h3>
<p>
Sometimes you need the users to be able to select only dates in the future.
Don't worry, mtr-datepicker has build-in feature for this, just pass the <code>future</code> parameter
during the initialization and it is done.
</p>
<pre><code>
<div id="only-future-dates-mtr-datepicker"></div>
<script>
var config = {
target: 'only-future-dates-mtr-datepicker',
future: true
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-smart-ampm">Smart AM/PM switching</h3>
<p>
Maybe you have noticed that when the hours are changing the AM/PM switch is not affected.
Make your datepicker smarter and initialize it with the <code>smartHours</code> parameter and
the AM/PM switch will change automatically with changes of the hours slider.
</p>
<pre><code>
<div id="smart-hours-mtr-datepicker"></div>
<script>
var config = {
target: 'smart-hours-mtr-datepicker',
smartHours: true
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-disable-ampm">Disable AM/PM (use 24 hours time format)</h3>
<p>
If you want to use the full 24 hours time format you can disable the AM/PM behavior easily.
Just initialize your datepicker with the <code>disableAmPm</code> parameter and
the AM/PM switch will be not present anymore.
</p>
<pre><code>
<div id="disable-ampm-mtr-datepicker"></div>
<script>
var config = {
target: 'disable-ampm-mtr-datepicker',
disableAmPm: true
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-disable-datepicker">Disable date picker</h3>
<p>
If you want to use only the time fields you can disable the Date Picker behavior easily.
Just initialize your datepicker with the <code>datepicker</code> parameter and
control the visibility of the date related fields.
</p>
<pre><code>
<div id="disable-datepicker-mtr-datepicker"></div>
<script>
var config = {
target: 'disable-datepicker-mtr-datepicker',
datepicker: false
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-reorder-datepicker">Change date picker order</h3>
<p>
If you want you can change the order of the Date Picker fields easily.
Just initialize your datepicker with the <code>datepicker</code> parameter and
control provide the date related fields in the exact order you want to be rendered.
</p>
<pre><code>
<div id="reorder-datepicker-mtr-datepicker"></div>
<script>
var config = {
target: 'reorder-datepicker-mtr-datepicker',
datepicker: ['dates', 'months', 'years']
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h3 id="api-init-disable-timepicker">Disable time picker</h3>
<p>
If you want to use only the date fields you can disable the Time Picker behavior easily.
Just initialize your datepicker with the <code>timepicker</code> parameter and
control the visibility of the time related fields.
</p>
<pre><code>
<div id="disable-timepicker-mtr-datepicker"></div>
<script>
var config = {
target: 'disable-timepicker-mtr-datepicker',
timepicker: false
};
var myDatepicker = new MtrDatepicker(config);
</script>
</code></pre>
<br />
<h2 id="api-output">Output</h2>
<p>
Now, when you already know how to init the datepicker in the way you want we should
show you how to get the selected date in the best format for you. The datepicker is written
in JavaScript and because of this we support all of the default methods for getting output of a date.
Here is a complete list with all of the function which you can use and of course a simple example:
<ul>
<li><code>toDateString()</code> - Wed Sep 23 2015</li>
<li><code>toGMTString()</code> - Wed, 23 Sep 2015 08:43:47 GMT</li>
<li><code>toISOString()</code> - 2015-09-23T08:43:47.284Z</li>
<li><code>toLocaleDateString()</code> - 9/23/2015</li>
<li><code>toLocaleString()</code> - 9/23/2015, 11:43:47 AM</li>
<li><code>toLocaleTimeString()</code> - 11:43:47 AM</li>
<li><code>toString()</code> - Wed Sep 23 2015 11:43:47 GMT+0300 (EEST)</li>
<li><code>toTimeString()</code> - 11:43:47 GMT+0300 (EEST)</li>
<li><code>toUTCString()</code> - Wed, 23 Sep 2015 08:43:47 GMT</li>
</ul>
</p>
<pre><code>
<script>
var config = {
target: 'mtr-datepicker',
};
var myDatepicker = new MtrDatepicker(config);
var datepickerOutput = myDatepicker.toLocaleString();
console.log(datepickerOutput);
</script>
</code></pre>
<br />
<h3 id="api-output-format">format()</h3>
<p>
If you need more specific data from the datepicker you can use the <code>format()</code> method.
Maybe you are familiar with it from other languages and libraries. You can specify the format of the output data, just pass it as a string. Here is a list of all supported parameters and their meaning:
<ul>
<li>Months</li>
<ul>
<li><code>M</code> - month without leading zero (1-12)</li>
<li><code>MM</code> - month with leading zero (01-12)</li>
<li><code>MMM</code> - month name (Jan-Dec)</li>
</ul>
<li>Dates</li>
<ul>
<li><code>D</code> - date without leading zero (1-31)</li>
<li><code>DD</code> - month with leading zero (01-31)</li>
</ul>
<li>Years</li>
<ul>
<li><code>Y, YYYY</code> - year with 4 digits</li>
<li><code>YY</code> - year with 2 digits</li>
</ul>
<li>Hours</li>
<ul>
<li><code>h</code> - hour without leading zero (1-12)</li>
<li><code>hh</code> - hour with leading zero (01-12)</li>
</ul>
<li>Minutes</li>
<ul>
<li><code>m</code> - minutes without leading zero (0-59)</li>
<li><code>mm</code> - minutes with leading zero (00-59)</li>
</ul>
<li>AM/PM</li>
<ul>
<li><code>a</code> - am/pm</li>
<li><code>A</code> - AM/PM</li>
</ul>
</ul>
Here are some simple examples how to use the <code>format()</code> function:
</p>
<pre><code>
<script>
var config = {
target: 'mtr-datepicker',
};
var myDatepicker = new MtrDatepicker(config);
var datepickerOutput = myDatepicker.format('D.M.Y h:m A');
console.log(datepickerOutput);
</script>
</code></pre>
<br />
<h2 id="api-events">Events</h2>
<br />
<h3 id="api-events-on-change">On change</h3>
<p>
Sometimes you want to be notified when the datepicker values are changing.
For this purpose the datepicker comes with build-in events and you can use them easy. <br />
You can register event listeners on change of the following properties.
<ul>
<li>hour</li>
<li>minute</li>
<li>ampm</li>
<li>time</li>
<li>day</li>
<li>month</li>
<li>year</li>
<li>date</li>
<li>all</li>
</ul>
Here is an example how to listen for changes on all of the time fields.
</p>
<pre><code>
<script>
var config = {
target: 'mtr-datepicker',
};
var demoDatepicker = new MtrDatepicker(config);
demoDatepicker.onChange('time', function() {
// put you code here
});
</script>
</code></pre>
<br />
<h3 id="api-events-before-change">Before change</h3>
<p>
If you want you can listen for changes just before they are made to the datepicker fields.
You can listen for the same properties in the <a href="#api-events-on-change">onChange</a> event.
Here is a simple example how to add your listeners for changes in all date fields:
</p>
<pre><code>
<script>
var config = {
target: 'mtr-datepicker',
};
var demoDatepicker = new MtrDatepicker(config);
demoDatepicker.beforeChange('date', function() {
// put you code here
});
</script>
</code></pre>
</div><!-- /.API -->
<div id="plugins" class="blog-post">
<h2 class="blog-post-title">Plugins</h2>
<p>
Sometimes you need more flexibility and powerful features in order to use the datepicker in your project.
Here comes our plugins - developed to extend the datepicker with new features which are not built by default.
For now we don't offer rich choice but the number of our plugins will increase in the future.
</p>
<br />
<h2 id="plugins-timezones">Timezones</h2>
<p>
Our timezones plugin extends the datepicker in order to use it
with different timezones. As you already may know - JavaScript doesn't
support timezones at all.. or it support some type of a timezones behavior
but it's not what you expect. The idea of our datepicker is to use
only pure JS so we cannot use any third party libraries and we have done the tricky
job with this plugin.
</p>
<h3 id="plugins-timezones-how-to-use">How to use</h3>
<p>
In order to use our timezones plugin you should load it before the
datepicker itself. Then you can use the datepicker constructor to
set the required timezone. To do that you have 3 different ways described
bellow. Just to be sure that you loaded the plugin the correct way -
here is a brief example:
</p>
<pre><code>
<script type="text/javascript" src="dist/mtr-datepicker-timezones.min.js"></script>
<script type="text/javascript" src="dist/mtr-datepicker.min.js"></script>
<script>
datepicker = new MtrDatepicker({
target: 'datepicker',
utcTimezone: 'Europe/London'
});
</script>
</code></pre>
<h3 id="plugins-timezones-utc-init">UTC Init</h3>
<p>
On of the ways to init the datepicker to work with a specific timezone
is to pass its UTC string representation to the constructor using the
<code>utcTimezone</code> parameter. Here is a brief example how to do that:
</p>
<pre><code>
<script>
datepicker = new MtrDatepicker({
target: 'datepicker',
utcTimezone: 'DST'
});
</script>
</code></pre>
<h3 id="plugins-timezones-timezone-init">Timezone init</h3>
<p>
You can use a string representation of the timezone too, again combinate it
with the <code>utcTimezone</code> parameter:
</p>
<pre><code>
<script>
datepicker = new MtrDatepicker({
target: 'datepicker',
utcTimezone: 'Europe/Sofia'
});
</script>
</code></pre>
<h3 id="plugins-timezones-utc-offset-init">UTC offset init</h3>
<p>
The <code>utcTimezone</code> can accept one more input type - a number
representation of the timezone offset according to UTC:
</p>
<pre><code>
<script>
datepicker = new MtrDatepicker({
target: 'datepicker',
utcTimezone: -6
});
</script>
</code></pre>
</div>
<div id="contribute" class="blog-post">
<h2 class="blog-post-title">Contribute</h2>
<p>
We will appreciate it if you want to support our project and contribute to make it better.
You can read our <a href="" target="_blank">contribution guide</a> in GitHub or refer to this one here
in the docs. In order to change the source of the datepicker you have to install the following software to your PC or Mac:
<ul>
<li><a href="https://nodejs.org/en/" target="_blank">Node.js and npm</a></li>
<li><a href="http://gruntjs.com/" target="_blank">Grunt</a></li>
<li><a href="http://lesscss.org/" target="_blank">Less</a></li>
</ul>
</p>
<br />
<h2 id="our-guidelines">Our guidelines</h2>
<p>
Please, if you want to contribute to our project be sure that your code comply with these guidelines:
<ul>
<li>2 spaces for indentation, not tabs please.</li>
<li>Please check that your code will pass jshint code standards, grunt jshint will run this for you.</li>
<li>Please ensure you're changing the individual files in /scripts or /styles/less, not the concatenated outputs in /dist directory</li>
<li>Please keep pull requests concise, and document new functionality with jsdocs and usage docs</li>
<li>Consider whether your changes are useful for all users</li>
</ul>
</p>
<br />
<h2 id="how-to-build">How to build</h2>
<br />
<h3 id="how-to-build-get-the-source">Get the source</h3>
<p>
To prepare your environment you should follow these simple steps
First you need to fork our <a href="https://github.com/mtrdesign/mtr-datepicker" target="_blank">repository</a> in GitHub and then clone it to your PC or Mac with the GitHub app for your platform or type the following command in your Terminal or CMD.
</p>
<pre><code>
git clone https://github.com/[YOUR-USERNAME]/mtr-datepicker.git
</code></pre>
<p class="alert alert-warning">WARNING: Fix the url and place your username when you start cloning your forked repository.</p>
<p class="alert alert-info">NOTE: We don't obligate you to fork our repo. You can just download the code but if you want to submit your changes later it will be easy for you to send us a pull request. Because of this we suggest you to fork our repository.</p>
<br />
<h3 id="how-to-build-setup-packages">Setup packages</h3>
<p>
Download the required development packages with npm. Just type the following command in your Terminal or CMD. It will take a while to download all of the packages so don't terminate it and be patient.
</p>
<pre><code>npm install</code></pre>
<br />
<h3 id="contribute-lets-build-the-code">Lets build the code</h3>
<p>
That's all, you are ready to make changes in the code. Probably you'll want to build the source and see in action
the changes which you made. As we said in the beginning, the datepicker is build with Grunt and comes with a setup for this.
Just type the following command in your Terminal or CMD and then open <a href="http://localhost:8080/demo.html" target="_blank">http://localhost:8080/demo.html</a> in your browser.
</p>
<pre><code>
grunt
Running "connect:server" (connect) task
Started connect web server on http://localhost:8080
Running "watch" task
Waiting...
</code></pre>
<br />
<h3 id="how-to-build-run-the-tests">Run the tests</h3>
<p>
Yup, the datepicker has some tests and it will be good to run them after finishing your changes, we don't
want to break the build. So to run the test you just have to type the following command in your Terminal or CMD.
</p>
<pre><code>node_modules/karma/bin/karma start karma.conf.js --single-run</code></pre>
<br />
<h3 id="how-to-build-write-some-tests">Write some tests</h3>
<p>
If you want you can add more tests and increase the code coverage of the project, it will be great.
We are using the <a href="http://jasmine.github.io/" target="_blank">Jasmine</a> framework and running the tests on all
supported browsers with the <a href="http://karma-runner.github.io/0.13/index.html" target="_blank">Karma</a> runner.
Everything is setup and ready for use but if you are not familiar with writing tests with these tools we suggest you
to read something about them before you start. <br />
<br />
When you write some tests you can check their execution on the following url <a href="http://localhost:8080/tests/SpecRunner.html" target="_blank">http://localhost:8080/tests/SpecRunner.html</a>.
</p>
<p class="alert alert-warning">
NOTE: Be sure that you have started the server with Grunt before trying to visit the web tests runner.
<a href="#contribute-lets-build-the-code">How to start Grunt?</a>
</p>
<br />
<h2 id="license">License</h2>
<p>MTR Datepicker is open source and available under the GPL license.</p>
</div><!-- /.contribute -->
<!-- Template -->
<!-- <div id="scrollspy-about" class="blog-post">
<h2 class="blog-post-title">About</h2>
</div> -->
</div><!-- /.blog-main -->
<div class="col-md-2 col-sm-3 blog-sidebar">
<div id="navbar-scrollspy" class="sidebar-module">
<h4>Getting Started</h4>
<ol class="nav nav-pills nav-stacked list-unstyled">
<li><a href="#about">About</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#how-to-use">How to use</a></li>
</ol>
<h4>API</h4>
<ol class="nav nav-pills nav-stacked list-unstyled">
<li><a href="#api-init">Init</a></li>
<li><a href="#api-init-default"> Default</a></li>
<li><a href="#api-init-starting-date"> Set starting date</a></li>
<li><a href="#api-init-only-future-dates"> Only future dates</a></li>
<li><a href="#api-init-smart-ampm"> Smart AM/PM switching</a></li>
<li><a href="#api-init-disable-ampm"> Disable AM/PM (24 hours time format)</a></li>
<li><a href="#api-init-disable-datepicker"> Disable date picker</a></li>
<li><a href="#api-init-reorder-datepicker"> Change date picker order</a></li>
<li><a href="#api-init-disable-timepicker"> Disable time picker</a></li>
<li><a href="#api-output">Output</a></li>
<li><a href="#api-output-format"> format()</a></li>
<li><a href="#api-events">Events</a></li>
<li><a href="#api-events-on-change"> On Change</a></li>
<li><a href="#api-events-before-change"> Before Change</a></li>
</ol>
<h4>Plugins</h4>
<ol class="nav nav-pills nav-stacked list-unstyled">
<li><a href="#plugins-timezones">Timezones</a></li>
<li><a href="#plugins-timezones-how-to-use"> How to use</a></li>
<li><a href="#plugins-timezones-utc-init"> UTC init</a></li>
<li><a href="#plugins-timezones-timezone-init"> Timezone init</a></li>
<li><a href="#plugins-timezones-utc-offset-init"> UTC offset init</a></li>
</ol>
<h4>Contribute</h4>
<ol class="nav nav-pills nav-stacked list-unstyled">
<li><a href="#our-guidelines">Our guidelines</a></li>
<li><a href="#how-to-build">How to build</a></li>
<li><a href="#how-to-build-get-the-source"> Get the source</a></li>
<li><a href="#how-to-build-run-the-tests"> Run the tests</a></li>
<li><a href="#how-to-build-write-some-tests"> Write some tests</a></li>
<li><a href="#license">License</a></li>
</ol>
</div>
</div><!-- /.blog-sidebar -->
</div><!-- /.row -->
<footer class="footer">
<a href="http://mtr-design.com/" class="pull-right" target="_blank"><img src="images/mtr_logo.png" /></a>
<p class="pull-left">MTR Datepicker is open source and available under the GPL license.</p>
<div class="clearfix"></div>
<p class="pull-left">Powered by <a href="http://www.mtr-design.com" target="_blank">MTR Design</a> © 2015 - 2020</p>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="libs/bootstrap/js/bootstrap.min.js"></script>
<script src="libs/highlightjs/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="libs/anchorjs/anchor.min.js"></script>
<script type="text/javascript" src="demo/docs.js"></script>
<!-- -->
<script type="text/javascript">
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-72115428-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>