new Utils()
Methods
-
<static> readData(element, clazz)
-
Returns the data attributes of the specific element. Ignores "data-cmp-is-" and "data-cmp-hook-" attributes.
Parameters:
Name Type Description elementElement The element to read data attributes from.
clazzstring The class name.
Returns:
The data attributes.
- Type
- Object
-
<static> registerMutationObserver(formContainer, fieldCreator, fieldSelector, dataAttributeClass)
-
Registers the mutation observer for a form component.
Parameters:
Name Type Description formContainermodule:FormView~FormContainer The form container.
fieldCreatorfunction The function to create a field.
fieldSelectorstring The field selector.
dataAttributeClassstring The data attribute class.
-
<static> createFieldsForAddedElement(addedElement, formContainer)
-
Creates fields from all registered fieldCreators present inside addedElement, for given form container.
Parameters:
Name Type Description addedElementElement The added element.
formContainermodule:FormView~FormContainer The form container.
-
<static> setupField(fieldCreator, fieldSelector, fieldClass)
-
Execute a callback after the Form Container is initialized.
Parameters:
Name Type Description fieldCreatorfunction The function to return an instance of FormField.
fieldSelectorstring The CSS selector to identify the HTML element.
fieldClassstring The data attribute to read the field data from.
-
<static> removeFieldReferences(fieldView, formContainer)
-
Removes all references of field from views, Form Container.
Parameters:
Name Type Description fieldViewObject The field view.
formContainermodule:FormView~FormContainer The form container.
-
<static> updateId(htmlElement, oldId, newId)
-
Update the id inside the given html element.
Parameters:
Name Type Description htmlElementElement The HTML element.
oldIdstring The old ID.
newIdstring The new ID.
-
<static> setContextPath(contextPath)
-
API to set the context path. All external HTTP API calls would by default prefix with this context path.
Parameters:
Name Type Description contextPathstring The context path of the system.
-
<static> getContextPath()
-
API to get the context path.
Returns:
- The context path of the system.
- Type
- string
-
<static> registerClickHandler(parentElement, hook, handler)
-
Registers handler on elements on hook.
Parameters:
Name Type Description parentElementElement The parent element.
hookstring The hook.
handlerfunction The event handler.
-
<async, static> setupFormContainer(createFormContainer, formContainerSelector, formContainerClass)
-
Sets up the Form Container.
Parameters:
Name Type Description createFormContainerfunction The function to create a form container.
formContainerSelectorstring The CSS selector to identify the form container.
formContainerClassstring The form container class.
Fires:
-
<static> stripIfWrapped(prefillJson)
-
For backward compatibility with older data formats of prefill services like FDM.
Parameters:
Name Type Description prefillJsonobject The prefill JSON object.
Returns:
- The stripped prefill JSON object.
- Type
- object
-
<static> isUserAgent(agentName)
-
Checks if the current browser matches with the agentName passed.
Parameters:
Name Type Description agentNamestring The agent name to match with the browser's user agent.
Returns:
- True if the browser's user agent matches the agentName, otherwise false.
- Type
- boolean