Class: Enhancer

sync.formctrls. Enhancer


new Enhancer(formControl, editingSupport)

The base class used for form controls enhancers.

It is used to enhance the rendering created by the server-side code. It can also register event handlers in order to provide editing capability.

Parameters:
Name Type Description
formControl HTMLElement The HTML element to enhance.
editingSupport sync.api.EditingSupport The editing support of the containing editor.

Members


<static> ACTIVE_CLASS :string

Class to be added to the form control when it is active but it does not have focus.
Type:
  • string

editingSupport :sync.api.EditingSupport

The editing support of the containing editor.
Type:

formControl :HTMLElement

The HTML element to enhance.
Type:
  • HTMLElement

Methods


enhanceDom()

Method called to enhance an HTML element that wraps the form control.

This should be implemented in subclasses.

This method may be called on another instance of the form control than the two other methods, enterDocument & exitDocument.


enterDocument(controller)

Method called to initialize the HTML element after it entered the DOM. This method should be implemented in subclasses to register event handlers on the form-control.

IMPORTANT: It is advisable to call the 'super' method in your implementation. See explanation below.

The editor that embeds the form controls usually calls preventDefault on any browser event on the 'bubble' phase.

However, the default implementation of this method, listens to these events and calls 'stopPropagation' on them on the 'bubble' phase, so that the editor's listener which calls 'preventDefault' does not run. This enables the form control to benefit from native input events: typing, mouse clicks, drag&drop, etc.

Parameters:
Name Type Description
controller Controller The document controller.

exitDocument()

Method called to before the form-control is removed from the document.

This should be implemented in subclasses to remove all the listeners on that element, and to reset any global state that refers to that element.

The default implementation un-registers all the listeners on the form-control registered using the Closure library.


getParentNode()

Returns the XML node on which the form control is placed.
Returns:
the node on which the form control is placed.
Type
Node

isDisabled()

Getter for the 'disabled' state of the form control.

By default, the form control is disabled when is in read-only context.

A read-only context may be:

  • a non-editable node when the '-oxy-editable' CSS rule is used
  • a XML node deleted with change tracking enabled
  • the whole 'Editor' when 'sync.api.ReadOnlyState' mark it as read-ony
  • Returns:
    true if the form control is disabled, false otherwise.
    Type
    Boolean

    <abstract> recycleFor(newRendering)

    Recycle the enhancer for the new server-side rendering of the form control
    Parameters:
    Name Type Description
    newRendering HTMLElement The new server-side rendering.
    Returns:
    true if the enhancer can be recycled.
    Type
    boolean