Skip to content
Snippets Groups Projects
Commit 8c91f589 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

set aria-disabled as well on helper attributes [data-(de)activates], fixes #1200

Closes #1200

Merge request studip/studip!711
parent cb468f1a
No related branches found
No related tags found
No related merge requests found
......@@ -98,11 +98,13 @@ $(document).on('change', '[data-activates],[data-deactivates]', function() {
var state = $(this).prop('checked') || $(this).prop('indeterminate') || false;
$(selector).each(function() {
var condition = $(this).data(`${type}Condition`),
toggle = state && (!condition || $(condition).length > 0);
$(this)
.attr('disabled', type === 'activates' ? !toggle : toggle)
.trigger('update.proxy');
const condition = $(this).data(`${type}Condition`);
const toggle = state && (!condition || $(condition).length > 0);
const disabled = type === 'activates' ? !toggle : toggle;
$(this).attr({
disabled: disabled,
'aria-disabled': disabled ? 'true' : 'false'
}).trigger('update.proxy');
});
});
});
......@@ -115,9 +117,12 @@ STUDIP.ready((event) => {
// element. Define element to disable if select has a value different from
// an empty string by a css selector in attribute "data-activates".
$(document).on('change update.proxy', 'select[data-activates]', function() {
var activates = $(this).data('activates'),
disabled = $(this).is(':disabled') || $(this).val().length === 0;
$(activates).attr('disabled', disabled);
const activates = $(this).data('activates');
const disabled = $(this).is(':disabled') || $(this).val().length === 0;
$(activates).attr({
disabled: disabled,
'aria-disabled': disabled ? 'true' : 'false'
});
});
STUDIP.ready((event) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment