Skip to content

Commit 99b02a5

Browse files
committed
implement today button in day view
1 parent 77df181 commit 99b02a5

File tree

14 files changed

+116
-34
lines changed

14 files changed

+116
-34
lines changed

dist/locale/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/locale/translations/de.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/locale/translations/en.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuejs-datepicker.common.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,14 @@ function _nonIterableRest() {
111111
var Language =
112112
/*#__PURE__*/
113113
function () {
114-
function Language(language, months, monthsAbbr, days) {
114+
function Language(language, months, monthsAbbr, days, today) {
115115
_classCallCheck(this, Language);
116116

117117
this.language = language;
118118
this.months = months;
119119
this.monthsAbbr = monthsAbbr;
120120
this.days = days;
121+
this.today = today;
121122
this.rtl = false;
122123
this.ymd = false;
123124
this.yearSuffix = '';
@@ -176,7 +177,7 @@ function () {
176177
return Language;
177178
}(); // eslint-disable-next-line
178179

179-
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']) // eslint-disable-next-line
180+
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 'Today') // eslint-disable-next-line
180181
;
181182

182183
var utils = {
@@ -918,7 +919,8 @@ var script$1 = {
918919
* Translation of 'today'
919920
* @return {String}
920921
*/
921-
todayText: function todayText() {// return this.translation.
922+
todayText: function todayText() {
923+
return this.translation.today;
922924
}
923925
},
924926
methods: {
@@ -1151,6 +1153,12 @@ var script$1 = {
11511153
*/
11521154
isDefined: function isDefined(prop) {
11531155
return typeof prop !== 'undefined' && prop;
1156+
},
1157+
selectToday: function selectToday() {
1158+
this.selectDate({
1159+
timestamp: Math.max(Math.min(new Date().getTime(), this.disabledDates.from.getTime()), this.disabledDates.to.getTime()),
1160+
isDisabled: false
1161+
});
11541162
}
11551163
} // eslint-disable-next-line
11561164

@@ -1263,11 +1271,22 @@ var __vue_render__$1 = function() {
12631271
2
12641272
),
12651273
_vm._v(" "),
1266-
_c("div", { staticClass: "today-button" }, [
1267-
_c("span", { staticStyle: { "text-align": "center" } }, [
1268-
_vm._v(_vm._s(_vm.todayText))
1269-
])
1270-
])
1274+
_c(
1275+
"div",
1276+
{
1277+
staticClass: "today-button",
1278+
on: {
1279+
click: function($event) {
1280+
return _vm.selectToday()
1281+
}
1282+
}
1283+
},
1284+
[
1285+
_c("span", { staticStyle: { "text-align": "center" } }, [
1286+
_vm._v(_vm._s(_vm.todayText))
1287+
])
1288+
]
1289+
)
12711290
],
12721291
2
12731292
)

dist/vuejs-datepicker.esm.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ function _nonIterableRest() {
109109
var Language =
110110
/*#__PURE__*/
111111
function () {
112-
function Language(language, months, monthsAbbr, days) {
112+
function Language(language, months, monthsAbbr, days, today) {
113113
_classCallCheck(this, Language);
114114

115115
this.language = language;
116116
this.months = months;
117117
this.monthsAbbr = monthsAbbr;
118118
this.days = days;
119+
this.today = today;
119120
this.rtl = false;
120121
this.ymd = false;
121122
this.yearSuffix = '';
@@ -174,7 +175,7 @@ function () {
174175
return Language;
175176
}(); // eslint-disable-next-line
176177

177-
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']) // eslint-disable-next-line
178+
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 'Today') // eslint-disable-next-line
178179
;
179180

180181
var utils = {
@@ -916,7 +917,8 @@ var script$1 = {
916917
* Translation of 'today'
917918
* @return {String}
918919
*/
919-
todayText: function todayText() {// return this.translation.
920+
todayText: function todayText() {
921+
return this.translation.today;
920922
}
921923
},
922924
methods: {
@@ -1149,6 +1151,12 @@ var script$1 = {
11491151
*/
11501152
isDefined: function isDefined(prop) {
11511153
return typeof prop !== 'undefined' && prop;
1154+
},
1155+
selectToday: function selectToday() {
1156+
this.selectDate({
1157+
timestamp: Math.max(Math.min(new Date().getTime(), this.disabledDates.from.getTime()), this.disabledDates.to.getTime()),
1158+
isDisabled: false
1159+
});
11521160
}
11531161
} // eslint-disable-next-line
11541162

@@ -1261,11 +1269,22 @@ var __vue_render__$1 = function() {
12611269
2
12621270
),
12631271
_vm._v(" "),
1264-
_c("div", { staticClass: "today-button" }, [
1265-
_c("span", { staticStyle: { "text-align": "center" } }, [
1266-
_vm._v(_vm._s(_vm.todayText))
1267-
])
1268-
])
1272+
_c(
1273+
"div",
1274+
{
1275+
staticClass: "today-button",
1276+
on: {
1277+
click: function($event) {
1278+
return _vm.selectToday()
1279+
}
1280+
}
1281+
},
1282+
[
1283+
_c("span", { staticStyle: { "text-align": "center" } }, [
1284+
_vm._v(_vm._s(_vm.todayText))
1285+
])
1286+
]
1287+
)
12691288
],
12701289
2
12711290
)

dist/vuejs-datepicker.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@
115115
var Language =
116116
/*#__PURE__*/
117117
function () {
118-
function Language(language, months, monthsAbbr, days) {
118+
function Language(language, months, monthsAbbr, days, today) {
119119
_classCallCheck(this, Language);
120120

121121
this.language = language;
122122
this.months = months;
123123
this.monthsAbbr = monthsAbbr;
124124
this.days = days;
125+
this.today = today;
125126
this.rtl = false;
126127
this.ymd = false;
127128
this.yearSuffix = '';
@@ -180,7 +181,7 @@
180181
return Language;
181182
}(); // eslint-disable-next-line
182183

183-
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']) // eslint-disable-next-line
184+
var en = new Language('English', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 'Today') // eslint-disable-next-line
184185
;
185186

186187
var utils = {
@@ -922,7 +923,8 @@
922923
* Translation of 'today'
923924
* @return {String}
924925
*/
925-
todayText: function todayText() {// return this.translation.
926+
todayText: function todayText() {
927+
return this.translation.today;
926928
}
927929
},
928930
methods: {
@@ -1155,6 +1157,12 @@
11551157
*/
11561158
isDefined: function isDefined(prop) {
11571159
return typeof prop !== 'undefined' && prop;
1160+
},
1161+
selectToday: function selectToday() {
1162+
this.selectDate({
1163+
timestamp: Math.max(Math.min(new Date().getTime(), this.disabledDates.from.getTime()), this.disabledDates.to.getTime()),
1164+
isDisabled: false
1165+
});
11581166
}
11591167
} // eslint-disable-next-line
11601168

@@ -1267,11 +1275,22 @@
12671275
2
12681276
),
12691277
_vm._v(" "),
1270-
_c("div", { staticClass: "today-button" }, [
1271-
_c("span", { staticStyle: { "text-align": "center" } }, [
1272-
_vm._v(_vm._s(_vm.todayText))
1273-
])
1274-
])
1278+
_c(
1279+
"div",
1280+
{
1281+
staticClass: "today-button",
1282+
on: {
1283+
click: function($event) {
1284+
return _vm.selectToday()
1285+
}
1286+
}
1287+
},
1288+
[
1289+
_c("span", { staticStyle: { "text-align": "center" } }, [
1290+
_vm._v(_vm._s(_vm.todayText))
1291+
])
1292+
]
1293+
)
12751294
],
12761295
2
12771296
)

dist/vuejs-datepicker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuejs-datepicker",
3-
"version": "1.7.0-conntac",
3+
"version": "1.8.0-conntac",
44
"description": "A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations",
55
"keywords": [
66
"vue",
@@ -16,7 +16,9 @@
1616
"dist"
1717
],
1818
"author": "Charlie Kassel <[email protected]>",
19-
"contributors": ["Tim Neubert <[email protected]>"],
19+
"contributors": [
20+
"Tim Neubert <[email protected]>"
21+
],
2022
"repository": {
2123
"type": "git",
2224
"url": "https://github.com/charliekassel/vuejs-datepicker"

src/components/PickerDay.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
v-html="dayCellContent(day)"
2525
@click="selectDate(day)"></span>
2626
</div>
27+
<div class="today-button" @click="selectToday()">
28+
<span style="text-align: center">{{ todayText }}</span>
29+
</div>
2730
</div>
2831
</template>
2932
<script>
@@ -160,6 +163,13 @@ export default {
160163
return this.isRtl
161164
? this.isPreviousMonthDisabled(this.pageTimestamp)
162165
: this.isNextMonthDisabled(this.pageTimestamp)
166+
},
167+
/**
168+
* Translation of 'today'
169+
* @return {String}
170+
*/
171+
todayText () {
172+
return this.translation.today
163173
}
164174
},
165175
methods: {
@@ -375,6 +385,11 @@ export default {
375385
*/
376386
isDefined (prop) {
377387
return typeof prop !== 'undefined' && prop
388+
},
389+
selectToday () {
390+
this.selectDate({timestamp: Math.max(Math.min(new Date().getTime(),
391+
this.disabledDates.from.getTime()), this.disabledDates.to.getTime()),
392+
isDisabled: false})
378393
}
379394
}
380395
}

0 commit comments

Comments
 (0)