Skip to content

Commit 83af96a

Browse files
committed
Added functionality to go to today with API
1 parent 59656ec commit 83af96a

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ For example: <FunctionalCalendar ref="Calendar"></FunctionalCalendar>
159159
✅ this.$refs.Calendar.NextMonth(); //Call method implementation to go to next month
160160
✅ this.$refs.Calendar.PreYear(); //Call method implementation to go to previous year
161161
✅ this.$refs.Calendar.NextYear(); //Call method implementation to go to next year
162+
✅ this.$refs.Calendar.ChooseDate('today'); //Call method implementation to go to today
162163
✅ this.$refs.Calendar.ChooseDate('2018-12-12'); //Call method implementation to go to a date
163164
````
164165
___

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"name": "vue-functional-calendar",
88
"description": "A style-uninstallable datepicker component for Vue.js",
9-
"version": "2.3.2",
9+
"version": "2.3.3",
1010
"license": "MIT",
1111
"repository": {
1212
"type": "git",
@@ -58,20 +58,20 @@
5858
"vue": "^2.5.21"
5959
},
6060
"devDependencies": {
61-
"@babel/core": "^7.2.2",
62-
"@vue/babel-preset-app": "^3.3.0",
63-
"@vue/cli-plugin-babel": "^3.0.5",
64-
"@vue/cli-plugin-eslint": "^3.0.5",
65-
"@vue/cli-service": "^3.0.5",
66-
"babel-loader": "^8.0.4",
61+
"@babel/core": "^7.4.4",
62+
"@vue/babel-preset-app": "^3.7.0",
63+
"@vue/cli-plugin-babel": "^3.7.0",
64+
"@vue/cli-plugin-eslint": "^3.7.0",
65+
"@vue/cli-service": "^3.7.0",
66+
"babel-loader": "^8.0.6",
6767
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
6868
"css-loader": "^1.0.1",
6969
"grunt": ">=0.4.0",
7070
"grunt-coveralls": "^2.0.0",
7171
"jest": "^16.0.1",
7272
"less": "^3.8.1",
7373
"less-loader": "^4.1.0",
74-
"node-sass": "^4.9.4",
74+
"node-sass": "^4.12.0",
7575
"sass-loader": "^7.1.0",
7676
"sass-resources-loader": "^1.3.4",
7777
"stylus": "^0.54.5",

src/Demo.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<template>
22
<div>
33
<functional-calendar class="demo-calendar"
4+
ref="Calendar"
45
v-model="calendarData2"
56
:sunday-start="true"
6-
:is-modal="true"
7+
:is-modal="false"
78
:date-format="'dd.mm.yyyy'"
89
:change-month-function="true"
910
:is-typeable="true"
@@ -16,6 +17,7 @@
1617
:hidden-elements="['leftAndRightDays']"
1718
></functional-calendar>
1819

20+
<button @click="$refs.Calendar.ChooseDate('today')">Today</button>
1921
<!--<functional-calendar class="demo-calendar2"-->
2022
<!--v-model="calendarData"-->
2123
<!--:sunday-start="true"-->

src/components/FunctionalCalendar.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,13 @@
606606
this.$emit('changedYear', this.calendar.currentDate);
607607
},
608608
ChooseDate(date) {
609-
this.calendar.currentDate = helpCalendar.getDateFromFormat(date);
609+
let newDate = helpCalendar.getDateFromFormat(date);
610+
611+
if(date === 'today'){
612+
newDate = new Date();
613+
}
614+
615+
this.calendar.currentDate = newDate;
610616
this.initCalendar();
611617
},
612618
openMonthPicker() {

0 commit comments

Comments
 (0)