From 04c14b37ecd35539e9fa1988f1258700e846a7b9 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 25 Aug 2021 09:53:49 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9pare=20la=20fermeture=20du=20datepicker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/static/vendor/datetimepicker/picker.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/shared/static/vendor/datetimepicker/picker.js b/shared/static/vendor/datetimepicker/picker.js index 34f96b5..be17471 100644 --- a/shared/static/vendor/datetimepicker/picker.js +++ b/shared/static/vendor/datetimepicker/picker.js @@ -43,10 +43,11 @@ class DateTimePicker { throw TypeError('Selector required to construct a DateTimePicker'); } - this.target = document.querySelector(selector); + this.target = _$(selector, document, false); if (!this.target) { throw Error(`The selector '{selector}' doesn't give any results`); } + this.target.addEventListener('click', () => { document.documentElement.classList.add('is-clipped'); this.modal.classList.add('is-active'); @@ -67,9 +68,10 @@ class DateTimePicker { // Création du modal this.modal = document.createElement('div'); + this.modal.id = `modal-${this.target.id}`; this.modal.classList.add('modal'); - this.modal.innerHTML = ``; - let _controls = this.modal.querySelectorAll('header a.button'); + this.modal.innerHTML = ``; + let _controls = _$('header a.button', this.modal); this._leftArrow = _controls[0]; this._menu = _controls[1]; this._rightArrow = _controls[2]; @@ -113,7 +115,7 @@ class DateTimePicker { } }); - let _selects = this.modal.querySelectorAll('footer select'); + let _selects = _$('footer select', this.modal); this._hour = _selects[0]; this._minutes = _selects[1]; @@ -154,7 +156,7 @@ class DateTimePicker { this._menu.innerHTML = `${months[_beginning.getMonth()]} ${_beginning.getFullYear()}`; - const _body = this.modal.querySelector('.modal-card section .column'); + const _body = _$('.modal-card section .column', this.modal, false); _body.innerHTML = `
${days[0]}${days[1]}${days[2]}${days[3]}${days[4]}${days[5]}${days[6]}
`; // Création du tableau