Vue
by Niffler
HTML
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vuejs-datepicker"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<template>
<div id="app">
<h1>Datepicker Examples</h1>
<div class="example">
<h3>Default datepicker...</h3>
<datepicker placeholder="Select Date" />
<code>
<datepicker placeholder="Select Date"></datepicker>
</code>
</div>
<div class="example">
<h3>Typeable datepicker</h3>
<datepicker placeholder="Type or select date" :typeable="true" />
<code>
<datepicker placeholder="Type or select date" :typeable="true"></datepicker>
</code>
</div>
<div class="example">
<h3>Bootstrap styled datepicker</h3>
<datepicker
:bootstrapStyling="true"
:calendarButton="true"
:clearButton="true"
>
</datepicker>
<code>
<datepicker placeholder="Select Date"></datepicker>
</code>
</div>
<div class="example">
<h3>v-model datepicker</h3>
<datepicker placeholder="Select Date" v-model="vModelExample"></datepicker>
<code>
<datepicker placeholder="Select Date" v-model="vmodelexample"></datepicker>
</code>
<hr/>
<p>{{ vModelExample }}</p>
</div>
<div class="example">
<h3>Format datepicker</h3>
<datepicker :format="format"></datepicker>
<code>
<datepicker :format="format"></datepicker>
</code>
<div class="settings">
<h5>Settings</h5>
<div class="form-group">
<label>Format</label>
<select v-model="format">
<option value="d MMM yyyy" selected>d MMM yyyy - e.g 12 Feb 2016</option>
<option value="d MMMM yyyy">d MMMM yyyy - e.g 12 February 2016</option>
<option value="yyyy-MM-dd">yyyy-MM-dd - e.g...
CSS
body {
font-family: 'Helvetica Neue Light', Helvetica, sans-serif;
padding: 1em 2em 2em;
}
input, select {
padding: .75em .5em;
font-size: 100%;
border: 1px solid #ccc;
width: 100%
}
select {
height: 2.5em;
}
.example {
background: #f2f2f2;
border: 1px solid #ddd;
padding: 0em 1em 1em;
margin-bottom: 2em;
}
code,
pre {
margin: 1em 0;
padding: 1em;
border: 1px solid #bbb;
display: block;
background: #ddd;
border-radius: 3px;
}
.settings {
margin: 2em 0;
border-top : 1px solid #bbb;
background: #eee;
}
h5 {
font-size:100%;
padding: 0;
}
.form-group {
margin-bottom: 1em;
}
.form-group label {
font-size: 80%;
display: block;
}
Vue
const state = {
date1: new Date()
}
export default {
name: 'demo',
components: {
Datepicker
},
data () {
return {
styleInput: null,
format: 'd MMMM yyyy',
disabledDates: {},
openDate: null,
disabledFn: {
customPredictor (date) {
if (date.getDate() % 3 === 0) {
return true
}
}
},
highlightedFn: {
customPredictor (date) {
if (date.getDate() % 4 === 0) {
return true
}
}
},
highlighted: {},
eventMsg: null,
state: state,
vModelExample: null,
languages: lang,
language: 'en'
}
},
computed: {
getInputStyle () {
return this.styleInput
}
},
methods: {
highlightTo (val) {
if (typeof this.highlighted.to === 'undefined') {
this.highlighted = {
to: null,
daysOfMonth: this.highlighted.daysOfMonth,
from: this.highlighted.from
}
}
this.highlighted.to = val
},
highlightFrom (val) {
if (typeof this.highlighted.from === 'undefined') {
this.highlighted = {
to: this.highlighted.to,
daysOfMonth: this.highlighted.daysOfMonth,
from: null
}
}
this.highlighted.from = val
},
setHighlightedDays (elem) {
if (elem.target.value === 'undefined') {
return
}
let highlightedDays = elem.target.value.split(',').map(day => parseInt(day))
this.highlighted = {
from: this.highlighted.from,
to: this.highlighted.to,
daysOfMonth: highlightedDays
}
},
setDisabledDays (elem) {
if (elem.target.value === 'undefined') {
return
}
let disabledDays = elem.target.value.split(',').map(day => parseInt(day))
this.disabledDates = {
from: this.disabledDates.from,
to: this.disabledDates.to,
daysOfMonth: disabledDays
}
},
...