Class: UWA.Controls.Abstract

UWA/Controls/Abstract. UWA.Controls.Abstract

new UWA.Controls.Abstract(options)

This Class provides the foundation for all custom Controls Classes. All of the other Controls Classes inherit from this one.

This abstract class CANNOT be instanciate.

Available Events
Event Description
onPreInject Triggered before inject
onPostInject Triggered after inject
onResize Invoked when control needs to resize
onInjected Triggered asynchronously when the content gets injected in the DOM
onRemoved Triggered asynchronously when the content gets removed from the DOM

The onInjected and onRemoved events are debounced (if the content gets injected then removed then injected, only onInjected will be triggered) and will be triggered with an object as argument. This object will hold three properties informing on the position of the content in the DOM before it was removed (in the onRemoved case) or after it has been injected (in the onInjected case):

  • previousSibling: the previous sibling of the content or null if it was the first child
  • nextSibling: the next sibling of the content or null if it was the last child
  • parentNode: the parent node of the content.

Warning: the onRemoved event may be triggered because someone did destroy the elements recursively in a parent node. Elements of the control may be destroyed: detached from the DOM recursively and events removed.

Example
var newcontrol = UWA.Controls.Abstract.extend({
    // Your Control Implementation
});
Parameters
Name Type Description
options Object

options hash or a option/value pair

Mixes In

Index

Members

<protected> elements :Object

The current control elements.

Type
  • Object

Methods

inject(element, where) → {this}

Inject control in the dom.

Parameters
Name Type Argument Description
element HTMLelement

Dom target

where String <optional>

Where to inject

Returns
Type
this

remove() → {this}

Remove the control from the dom

Returns
Type
this

getContent() → {HTMLelement}

Returns control content.

Returns

Control container.

Type
HTMLelement

getClassNames(suffixes) → {String}

Generate a CSS class name based on the class name property, its parent classes, and the options "className". It should be used internally (in the control).

Example
var Input = UWA.Controls.Abstract.extend({
   name: 'uwa-input',

   options: {
       className: '',
   },

   buildSkeleton: function () {
       this.elements.container = UWA.createElement('div', { 'class': this.getClassNames() });
       this.elements.content = UWA.createElement('div', { 'class': this.getClassNames('-content') });
   }
});

var Radio = Input.extend({
   name: 'uwa-inputradio'
});

new Radio({
    className: 'toto black'
});
// container will have the class 'toto black uwa-inputradio uwa-input'
// content will have the class 'toto black uwa-inputradio-content uwa-input-content'
Parameters
Name Type Description
suffixes String

All parameters should be strings, used as suffix to append to the UWA.Class names of the inheritance chain.

Returns

The generated CSS class name.

Type
String

hide()

Hide control content.

show()

Show control content.

destroy()

Destroy the control elements and its children. Remove all events and remove the element from the dom. This control and its children should not be used after this.