Protected
addAdds elements that have a specific attribute which value is a selector pointing to one or several elements; the target element(s). The elements are grouped per target element pointed to.
A separate target list is used, so that multiple aTargetToSourceMap instances can be used that use the same target but point to different type of sources.
The allows for a single event handler. The event handlers should handle all the different types of sources pointing to the same target.
The attribute that contains the selector. The sources are the elements containing this attribute. The targets are the elements pointed to by the selector value of the attribute.
Target elements are added to this list. If the target is already in the list, it will not be added again.
A map that contains the source elements grouped per target element.
Optional event to listen for at the target element(s). It will be set only once at each target.
A handler that is called with the target element that triggered the event.
Event group to use. If empty, the event listener just gets added to the target.
Protected
getGets the target element(s).
Element to get the target element(s) from.
Either one of the predefined values or a selector.
list of elements (can be empty)
Initializes the helper. This will call the scan method once the DOM has been loaded.
Scans the current dom, update the dom and install listeners where necessary.
This method must support being called multiple times.
Protected
showShows an element by update the classes or display style. See the description of the UFHtmlHelper for details.
Defines class UFFormToggleHelper, a class to make html forms more dynamic by changing styles, visibility and enabled states based on input elements value and valid state.
Use a combination of
data-uf-toggle-XXXX
at an element. It alters the element depending on if one or more elements matches a condition or not.If a targeted form element is a radio button, this class will install listeners on all radio buttons. When a radio button fires a change event, the code will dispatch a change event to all other radio buttons in the same group. This fixes the issue that radio buttons do not fire a change event when they are unselected.
The following data attributes can be added:
data-uf-toggle-type
= 'auto' (default), 'value', 'valid', 'property'If the selector points to a form, the type is forced to 'valid' since a form does not have a value.
If 'auto' is used and the selector points to a checkbox or radio button and no values have been set, ['true'] is used for the values list.
data-uf-toggle-property
= string (default = 'checked') The property of the input element to get the value from. Withchecked
properties use"true"
and"false"
as values.data-uf-toggle-selector
= string (default = '') To select the element or elements to check. If multiple elements are selected, the first element is used in case any of the other options use 'auto'.Use empty text to select the parent form this element is contained in.
data-uf-toggle-change
= 'auto' (default), 'none', 'enable', 'visible'data-uf-toggle-required
= '' (default), 'match', 'no-match'data-uf-toggle-classes
= string (one or more css class names separated by a space) The css classes to add when the elements pointed to by the selector do not match the condition. When the elements match the condition, the css classes get removed.data-uf-toggle-classes-match
= string (one or more css class names separated by a space) The css classes to add when the elements pointed to by the selector do match the condition. When the elements no longer match the condition, the css classes get removed.data-uf-toggle-condition
= 'any', 'all' (default), 'none' Determines the condition the elements must match. With 'any' only one element must either be valid or be equal to the one of the specified values. With 'all' all elements must either be valid or be equal to one of the specified values. 'none' is the reverse of 'all', none of the elements must be valid or be equal to any of the specified values.data-uf-toggle-compare
=equal
(default),contain
,inside
,lt
,lte
,gt
,gte
Determines how to compare the value of an element with the values:equal
= the value of the element must be equal to one of the values.contain
= part of the value of the element must equal one of the values (case incentive).inside
= part of one of the values must equal the value of the element (case incentive).lt
= the value of the element must be less than one of the values (numeric).lte
= the value of the element must be less than or equal to one of the values (numeric).gt
= the value of the element must be greater than one of the values (numeric).gte
= the value of the element must be greater than or equal to one of the values (numeric).data-uf-toggle-value
= string (single value) Alias fordata-uf-toggle-values
. Ifdata-uf-toggle-values
is also specified, this attribute will be ignored.data-uf-toggle-values
= string Contains multiple values separated by the separator text as set bydata-uf-toggle-values-separator
. If bothdata-uf-toggle-value
anddata-uf-toggle-values
are not set and thechecked
property is tracked, the value"true"
is used.data-uf-toggle-values-separator
= string (default = ','). Separator string to split the value ofdata-uf-toggle-values
with.data-uf-toggle-target
= string (default = '') When specified, apply the toggle to the target element(s) instead of the element itself. Possible values: