Class: Enhancer


new Enhancer(formControl, editor)

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.

Name Type Description
formControl HTMLElement The HTML element to enhance.
editor sync.api.Editor is the editor


(abstract) 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.


(abstract) 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.

Name Type Description
controller sync.ctrl.Controller The document controller.

(abstract) 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() → {sync.api.dom.Node}

Returns the XML node on which the form control is placed.
the node on which the form control is placed.