DTpicker update
This commit is contained in:
parent
5afe2df78c
commit
9e37b9f0ae
1 changed files with 13 additions and 12 deletions
25
shared/static/vendor/datetimepicker/picker.js
vendored
25
shared/static/vendor/datetimepicker/picker.js
vendored
|
@ -39,6 +39,7 @@ class DateTimePicker {
|
||||||
this.target.addEventListener('click', () => {
|
this.target.addEventListener('click', () => {
|
||||||
document.documentElement.classList.add('is-clipped');
|
document.documentElement.classList.add('is-clipped');
|
||||||
this.modal.classList.add('is-active');
|
this.modal.classList.add('is-active');
|
||||||
|
this.target.blur();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!['fr', 'en'].includes(config.lang)) {
|
if (!['fr', 'en'].includes(config.lang)) {
|
||||||
|
@ -86,19 +87,19 @@ class DateTimePicker {
|
||||||
} else {
|
} else {
|
||||||
this._beginning.setMonth(this._beginning.getMonth() - 1, 1);
|
this._beginning.setMonth(this._beginning.getMonth() - 1, 1);
|
||||||
}
|
}
|
||||||
case 'months':
|
break;
|
||||||
this._beginning.setFullYear(this._beginning.getFullYear() - 1);
|
case 'months':
|
||||||
break;
|
this._beginning.setFullYear(this._beginning.getFullYear() - 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._menu.addEventListener('click', () => {
|
this._menu.addEventListener('click', () => {
|
||||||
let _index = DateTimePicker.views.indexOf(this._view);
|
if (this._view == 'days') {
|
||||||
_index = Math.min(2, _index + 1);
|
this._view = 'months';
|
||||||
this._view = DateTimePicker.views[_index];
|
this.refreshView();
|
||||||
this.refreshView();
|
}
|
||||||
console.log(this._view, _index);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let _selects = this.modal.querySelectorAll('footer select');
|
let _selects = this.modal.querySelectorAll('footer select');
|
||||||
|
@ -147,11 +148,11 @@ class DateTimePicker {
|
||||||
|
|
||||||
// Création du tableau
|
// Création du tableau
|
||||||
const _dayLength = 86400000;
|
const _dayLength = 86400000;
|
||||||
var day = new Date(_beginning.getTime() - _dayLength * ((_beginning.getDay() + 6) % 7));
|
let day = new Date(_beginning.getTime() - _dayLength * ((_beginning.getDay() + 6) % 7));
|
||||||
|
|
||||||
const _tbody = _body.querySelector('tbody');
|
const _tbody = _body.querySelector('tbody');
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
if (i == 0 || day.getMonth() <= _beginning.getMonth()) {
|
if (i == 0 || (day.getMonth() <= _beginning.getMonth()) && day.getFullYear() <= _beginning.getFullYear()) {
|
||||||
let row = document.createElement('tr');
|
let row = document.createElement('tr');
|
||||||
for (let j = 0; j < 7; j++) {
|
for (let j = 0; j < 7; j++) {
|
||||||
let cell = document.createElement('td');
|
let cell = document.createElement('td');
|
||||||
|
@ -197,7 +198,7 @@ class DateTimePicker {
|
||||||
const months = _months[this.config.lang];
|
const months = _months[this.config.lang];
|
||||||
|
|
||||||
this._menu.innerHTML = `<b>${_beginning.getFullYear()}</b>`;
|
this._menu.innerHTML = `<b>${_beginning.getFullYear()}</b>`;
|
||||||
var _body = this.modal.querySelector('.modal-card section .column');
|
let _body = this.modal.querySelector('.modal-card section .column');
|
||||||
_body.innerHTML = `<table class="table"><tbody></tbody></table>`;
|
_body.innerHTML = `<table class="table"><tbody></tbody></table>`;
|
||||||
|
|
||||||
const _tbody = _body.querySelector('tbody');
|
const _tbody = _body.querySelector('tbody');
|
||||||
|
@ -259,7 +260,7 @@ class DateTimePicker {
|
||||||
}
|
}
|
||||||
|
|
||||||
static dateValue(value) {
|
static dateValue(value) {
|
||||||
let _real = new Date(value.getTime() - 60000 * value.getTimezoneOffset());
|
const _real = new Date(value.getTime() - 60000 * value.getTimezoneOffset());
|
||||||
return _real.toISOString().replace('T', ' ').replace(/:\d{2}\.\d{3}Z/, '');
|
return _real.toISOString().replace('T', ' ').replace(/:\d{2}\.\d{3}Z/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue