Release 1.5.16
This commit is contained in:
@@ -353,6 +353,25 @@
|
||||
var rowKeyInput = form.querySelector('[name="row_key"]');
|
||||
var dayCheckboxes = form.querySelectorAll('[name="schedule_days"]');
|
||||
|
||||
function getDayButton(checkbox) {
|
||||
return checkbox && checkbox.id ? form.querySelector('label[for="' + checkbox.id + '"]') : null;
|
||||
}
|
||||
|
||||
function syncDayButtonState(checkbox) {
|
||||
var button = getDayButton(checkbox);
|
||||
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
button.classList.toggle('active', Boolean(checkbox.checked));
|
||||
button.setAttribute('aria-pressed', checkbox.checked ? 'true' : 'false');
|
||||
}
|
||||
|
||||
function syncAllDayButtonStates() {
|
||||
Array.prototype.forEach.call(dayCheckboxes, syncDayButtonState);
|
||||
}
|
||||
|
||||
function clearScheduleValidity() {
|
||||
[startDateInput, endDateInput, startTimeInput, endTimeInput].forEach(function (input) {
|
||||
if (input) {
|
||||
@@ -412,7 +431,20 @@
|
||||
}
|
||||
});
|
||||
Array.prototype.forEach.call(dayCheckboxes, function (checkbox) {
|
||||
checkbox.addEventListener('change', clearScheduleValidity);
|
||||
checkbox.addEventListener('change', function () {
|
||||
syncDayButtonState(checkbox);
|
||||
clearScheduleValidity();
|
||||
});
|
||||
|
||||
var button = getDayButton(checkbox);
|
||||
if (button) {
|
||||
button.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
checkbox.checked = !checkbox.checked;
|
||||
checkbox.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
checkbox.focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
select.addEventListener('change', clearScheduleValidity);
|
||||
|
||||
@@ -436,6 +468,7 @@
|
||||
|
||||
select.addEventListener('change', updateVisibility);
|
||||
updateVisibility();
|
||||
syncAllDayButtonStates();
|
||||
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user