mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
add altField option
This commit is contained in:
parent
a0d00a6e20
commit
45fedcb04e
17
dist/js/datepicker.js
vendored
17
dist/js/datepicker.js
vendored
@ -19,6 +19,8 @@ var Datepicker;
|
||||
firstDay: '',
|
||||
weekends: [6, 0],
|
||||
dateFormat: '',
|
||||
altField: '',
|
||||
altFieldDateFormat: '@',
|
||||
toggleSelected: true,
|
||||
|
||||
position: 'bottom left',
|
||||
@ -101,6 +103,10 @@ var Datepicker;
|
||||
this.elIsInput = true;
|
||||
}
|
||||
|
||||
if (this.opts.altField) {
|
||||
this.$altField = typeof this.opts.altField == 'string' ? $(this.opts.altField) : this.opts.altField;
|
||||
}
|
||||
|
||||
this.inited = false;
|
||||
this.visible = false;
|
||||
this.silent = false; // Need to prevent unnecessary rendering
|
||||
@ -290,6 +296,8 @@ var Datepicker;
|
||||
d = Datepicker.getParsedDate(date);
|
||||
|
||||
switch (true) {
|
||||
case /@/.test(result):
|
||||
result = result.replace(/@/, date.getTime());
|
||||
case /dd/.test(result):
|
||||
result = result.replace(/\bdd\b/, d.fullDate);
|
||||
case /d/.test(result):
|
||||
@ -457,9 +465,18 @@ var Datepicker;
|
||||
_setInputValue: function () {
|
||||
var _this = this,
|
||||
format = this.loc.dateFormat,
|
||||
altFormat = this.opts.altFieldDateFormat,
|
||||
value = this.selectedDates.map(function (date) {
|
||||
return _this.formatDate(format, date)
|
||||
}),
|
||||
altValues;
|
||||
|
||||
if (this.$altField) {
|
||||
altValues = this.selectedDates.map(function (date) {
|
||||
return _this.formatDate(altFormat, date)
|
||||
});
|
||||
this.$altField.val(altValues);
|
||||
}
|
||||
|
||||
value = value.join(this.opts.multipleDatesSeparator);
|
||||
|
||||
|
||||
2
dist/js/datepicker.min.js
vendored
2
dist/js/datepicker.min.js
vendored
File diff suppressed because one or more lines are too long
@ -19,6 +19,8 @@ var Datepicker;
|
||||
firstDay: '',
|
||||
weekends: [6, 0],
|
||||
dateFormat: '',
|
||||
altField: '',
|
||||
altFieldDateFormat: '@',
|
||||
toggleSelected: true,
|
||||
|
||||
position: 'bottom left',
|
||||
@ -101,6 +103,10 @@ var Datepicker;
|
||||
this.elIsInput = true;
|
||||
}
|
||||
|
||||
if (this.opts.altField) {
|
||||
this.$altField = typeof this.opts.altField == 'string' ? $(this.opts.altField) : this.opts.altField;
|
||||
}
|
||||
|
||||
this.inited = false;
|
||||
this.visible = false;
|
||||
this.silent = false; // Need to prevent unnecessary rendering
|
||||
@ -290,6 +296,8 @@ var Datepicker;
|
||||
d = Datepicker.getParsedDate(date);
|
||||
|
||||
switch (true) {
|
||||
case /@/.test(result):
|
||||
result = result.replace(/@/, date.getTime());
|
||||
case /dd/.test(result):
|
||||
result = result.replace(/\bdd\b/, d.fullDate);
|
||||
case /d/.test(result):
|
||||
@ -457,9 +465,18 @@ var Datepicker;
|
||||
_setInputValue: function () {
|
||||
var _this = this,
|
||||
format = this.loc.dateFormat,
|
||||
altFormat = this.opts.altFieldDateFormat,
|
||||
value = this.selectedDates.map(function (date) {
|
||||
return _this.formatDate(format, date)
|
||||
}),
|
||||
altValues;
|
||||
|
||||
if (this.$altField) {
|
||||
altValues = this.selectedDates.map(function (date) {
|
||||
return _this.formatDate(altFormat, date)
|
||||
});
|
||||
this.$altField.val(altValues);
|
||||
}
|
||||
|
||||
value = value.join(this.opts.multipleDatesSeparator);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user