Merge branch '334-urgent-sheet-corrector-table-heading' into 328-formular-zum-kontakt-mit-kursteilnehmern
This commit is contained in:
commit
45ea84e663
@ -128,8 +128,10 @@
|
|||||||
* Selector for the input that this fieldset watches for changes
|
* Selector for the input that this fieldset watches for changes
|
||||||
* data-conditional-value: string
|
* data-conditional-value: string
|
||||||
* The value the conditional input needs to be set to for this fieldset to be shown
|
* The value the conditional input needs to be set to for this fieldset to be shown
|
||||||
|
* Can be omitted if conditionalInput is a checkbox
|
||||||
*
|
*
|
||||||
* Example usage:
|
* Example usage:
|
||||||
|
* ## example with text input
|
||||||
* <input id="input-0" type="text">
|
* <input id="input-0" type="text">
|
||||||
* <fieldset uw-interactive-fieldset data-conditional-input="#input-0" data-conditional-value="yes">...</fieldset>
|
* <fieldset uw-interactive-fieldset data-conditional-input="#input-0" data-conditional-value="yes">...</fieldset>
|
||||||
* <fieldset uw-interactive-fieldset data-conditional-input="#input-0" data-conditional-value="no">...</fieldset>
|
* <fieldset uw-interactive-fieldset data-conditional-input="#input-0" data-conditional-value="no">...</fieldset>
|
||||||
@ -139,6 +141,11 @@
|
|||||||
* <option value="1">One
|
* <option value="1">One
|
||||||
* <fieldset uw-interactive-fieldset data-conditional-input="#select-0" data-conditional-value="0">...</fieldset>
|
* <fieldset uw-interactive-fieldset data-conditional-input="#select-0" data-conditional-value="0">...</fieldset>
|
||||||
* <fieldset uw-interactive-fieldset data-conditional-input="#select-0" data-conditional-value="1">...</fieldset>
|
* <fieldset uw-interactive-fieldset data-conditional-input="#select-0" data-conditional-value="1">...</fieldset>
|
||||||
|
* ## example with checkbox
|
||||||
|
* <input id="checkbox-0" type="checkbox">
|
||||||
|
* <input id="checkbox-1" type="checkbox">
|
||||||
|
* <fieldset uw-interactive-fieldset data-conditional-input="#checkbox-0">...</fieldset>
|
||||||
|
* <fieldset uw-interactive-fieldset data-conditional-input="#checkbox-1">...</fieldset>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var INTERACTIVE_FIELDSET_UTIL_NAME = 'interactiveFieldset';
|
var INTERACTIVE_FIELDSET_UTIL_NAME = 'interactiveFieldset';
|
||||||
@ -171,7 +178,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// param conditionalValue
|
// param conditionalValue
|
||||||
if (!element.dataset.conditionalValue) {
|
if (!element.dataset.conditionalValue && !isCheckbox()) {
|
||||||
throw new Error('Interactive Fieldset needs a conditional value!');
|
throw new Error('Interactive Fieldset needs a conditional value!');
|
||||||
}
|
}
|
||||||
conditionalValue = element.dataset.conditionalValue;
|
conditionalValue = element.dataset.conditionalValue;
|
||||||
@ -198,7 +205,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateVisibility() {
|
function updateVisibility() {
|
||||||
formGroup.classList.toggle('hidden', conditionalInput.value !== conditionalValue);
|
element.classList.toggle('hidden', !matchesConditionalValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesConditionalValue() {
|
||||||
|
if (isCheckbox()) {
|
||||||
|
return conditionalInput.checked === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conditionalInput.value === conditionalValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCheckbox() {
|
||||||
|
return conditionalInput.getAttribute('type') === 'checkbox';
|
||||||
}
|
}
|
||||||
|
|
||||||
return init();
|
return init();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user