Class: BaseControl

hcje/domTools~BaseControl(className, config)

Base control. A control in this context is some Element and an associated label held within a containing HTMLDivElement. The basic structure is shown below. Controls are expected to return a value by overriding the module:hcje/domTools~BaseControl#getValue method. Creates the control hierachy of

  • Container div
    • Label div
    • Control element

Constructor

new BaseControl(className, config)

Construct the base control.

Parameters:
Name Type Description
className string

Class name to add to the outer containing element.

config string
Properties
Name Type Description
label string

Label for the control.

parentElement module:hcje/domTools~ElementWrapper | HTMLElement

Element to which the control is appended.

Source:

Extends

Members

(protected, readonly) _element :Element

The wrapped element. This is protected and is only intended for use by the domTools module.

Type:
  • Element
Overrides:
Source:

(readonly) classList :DOMTokenList

The classList.

Type:
  • DOMTokenList
Overrides:
Source:
See:

className :string

The class name.

Type:
  • string
Overrides:
Source:
See:

(readonly) offsetHeight :number

Element's offset height.

Type:
  • number
Overrides:
Source:

(readonly) offsetWidth :number

Element's offset width.

Type:
  • number
Overrides:
Source:

(readonly) parentElement :string

The parent element.

Type:
  • string
Overrides:
Source:
See:

(readonly) style :CSSStyleProperties

Element's style.

Type:
  • CSSStyleProperties
Overrides:
Source:
See:

Methods

(protected) _appendControlElement(controlElement)

Add a control element. Although multiple control elements can be added, only one is expected. This method adds it after the label.

Parameters:
Name Type Description
controlElement Element | module:hcje/domTools~ElementWrapper

Control to add.

Source:

(protected) _prependControlElement(controlElement)

Add a control element. Although multiple control elements can be added, only one is expected. This adds it before the label.

Parameters:
Name Type Description
controlElement Element | module:hcje/domTools~ElementWrapper

Control to add.

Source:

addEventListener(eventType, listener, optionsOrUseCapture)

Add event listener.

Parameters:
Name Type Description
eventType string

Event type to listen to

listener function | Object

Handler of the event

optionsOrUseCapture Object | boolean

Additional options

Overrides:
Source:
See:

appendChild(child)

Append child.

Parameters:
Name Type Description
child Element | ElementWrapper

Element to append

Overrides:
Source:
See:

appendTo(parentElement)

Append to a parent element. Note, if it is already a child, this call is ignored. This method is provided to allow callers to adust hierarchies without needing access to the protected wrapped element. Note that the method will silently return if parentElement is not provided.

Parameters:
Name Type Description
parentElement module:hcje/domTools~ElementWrapper | HTMLElement

The element to which the wrapped element should be appended.

Overrides:
Source:

blur()

Remove the element's focus.

Overrides:
Source:

focus()

Give the element focus.

Overrides:
Source:

getValue() → {undefined}

Get the control's value. This is expected to be overridden;

Source:
Returns:
Type
undefined

remove()

Remove the element from the DOM. The instance wrapping the element still exists if a reference to it is maintained.

Overrides:
Source:

removeAllChildren()

Remove all children.

Overrides:
Source: