Material Datepicker
Include the JavaScript file and Stylesheet in your html page.
This plugin works with moment.js.
There are two methods to include the Material-Datepicker.
Method 1
When you have included moment.js already.
<script type="text/javascript" src="https://momentjs.com/downloads/moment-with-locales.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/FreddyFY/material-datepicker/1.0.9/dist/material-datepicker.css">
<script type="text/javascript" src="https://cdn.rawgit.com/FreddyFY/material-datepicker/1.0.9/dist/material-datepicker.min.js"></script>
Method 2
When you don’t need moment.js itself.
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/FreddyFY/material-datepicker/1.0.9/dist/material-datepicker.css">
<script type="text/javascript" src="https://cdn.rawgit.com/FreddyFY/material-datepicker/1.0.9/dist/material-datepicker-with-moment-js.min.js"></script>
It’s better to download the files, instead of using the rawgit cdn server.
In its simplest case, Material-Picker can be initialised with a single line of Javascript.
You will probably also specify some options while applying the plugin.
var monthpicker = new MaterialDatepicker('input');
var monthpicker = new MaterialDatepicker('input', {
type: 'month',
lang: 'de',
orientation: 'portrait'
});
closeAfterClick (default: true) [string] - Close the picker after choose a date or not
date (default: today or string inside input) [type: Date Object] - The initial date of the Picker
sitePickerFormat (default: date “MMMM YYYY”; month “YYYY”) [string] - Date format in the site picker bar
onLoad (default: none) [function] - Function called when picker is loaded
var monthpicker = new MaterialDatepicker('input', {
lang: 'de',
orientation: 'portrait',
theme: 'dark',
color: 'red',
date: new Date(861999834000),
outputFormat: 'd-mm-yyyy',
inputFormat: 'ddmmyyyy',
outputElment: '.month',
onChange: function() {
alert('Date Changed!!')
},
onNewDate: function() {
alert('New Date Chosen!!')
}
});
.open()
.close()
.newDate( new Date(861999834000) )
set new Date
.date
returns the current date
.element
returns the choosen element
.picker
returns the picker element
git clone https://github.com/FreddyFY/material-datepicker.git
npm install
npm start
npm run build
dist/