Class: El

El

Creates an HTML element and wraps it with convenience methods.


new El(type, attrs, children)

El class constructor.

Parameters:
Name Type Description
type String

Type of element to create.

attrs Object

Attributes to set.

children Array

Child elements to nest.

Source:

Members


<static> Extender :Object

Type:
  • Object
Source:

_animationSpeed

Set default animation speed

Source:

_attributes :Object

Type:
  • Object
Source:

children :Array

Type:
  • Array
Source:

element :Object

Type:
  • Object
Source:

events :Array

Type:
  • Array
Source:

extenders :Array

Type:
  • Array
Source:

type :String

Type:
  • String
Source:

Methods


<static> addExtenders(extenders)

Add custom extenders

Parameters:
Name Type Description
extenders Array.<Object>

Array of extender configurations

Properties
Name Type Description
name String

Name of custom extender

action function

Action of the custom extender

Source:

<static> isArray(item)

Simple array check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is array.

Type
Boolean

<static> isBoolean(item)

Simple boolean check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is boolean.

Type
Boolean

<static> isDate(item)

Simple date check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is date.

Type
Boolean

<static> isFunction(item)

Simple function check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is function.

Type
Boolean

<static> isNumber(item)

Simple number check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is number.

Type
Boolean

<static> isObject(item)

Simple object check. Arrays not included.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is object.

Type
Boolean

<static> isString(item)

Simple string check.

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is string.

Type
Boolean

<static> isTruthy(item)

Simple truthy check - only used for setting attribute values. Eliminates null, undefined and Infinity. Zero's are considered truthy (useful for setting attributes), as well as empty strings (used for setting blank attributes) and false (again, for setting attributes).

Parameters:
Name Type Description
item

Item to check.

Source:
Returns:

Is truthy.

Type
Boolean

<static> setAnimationSpeed(animationSpeed)

Set default animation speed

Parameters:
Name Type Description
animationSpeed Number

Default animation speed

Source:

<static> toQueryString(obj)

Convert an object to a query string.

Parameters:
Name Type Description
obj Object

JS object to encode.

Source:
Returns:

URL encoded query string.

Type
String

_prepend()

Prepend without pushing to children array

Source:

addClass(myClass)

Adds a class or classes to an element.

Parameters:
Name Type Description
myClass String | Array

ClassName(s) to add. Can be a space-separated string or an array.

Source:
Returns:

El class instance.

Type
Object

after(el)

Insert an element after another.

Parameters:
Name Type Description
el Object

El class instance.

Source:
Returns:

El class instance.

Type
Object

appear()

Show an element with visibility: visible.

Source:
Returns:

El class instance.

Type
Object

appearFor( [interval])

Show an element with appear() for x number of milliseconds.

Parameters:
Name Type Argument Default Description
interval Number <optional>
200

Interval in milliseconds.

Source:
Returns:

El class instance.

Type
Object

append(el)

Append an element or text node.

Parameters:
Name Type Description
el Object | String

Element to append or string to become text node to append.

Source:
Returns:

El class instance.

Type
Object

appendHTML(html)

Append HTML

Parameters:
Name Type Description
html String

HTML to append.

Source:
Returns:

El class instance.

Type
Object

appendText(text)

Append text content to an element.

Parameters:
Name Type Description
text String

Text to append.

Source:
Returns:

El class instance.

Type
Object

blur()

Blur element (just a wrapper for the .blur DOM method).

Source:
Returns:

El class instance.

Type
Object

click()

Simulate an element click (just a wrapper for the .click DOM method).

Source:
Returns:

El class instance.

Type
Object

disable( [shouldDisable])

Disable an element by attribute and class.

Parameters:
Name Type Argument Default Description
shouldDisable Boolean <optional>
true

Conditionally disable.

Source:
Returns:

El class instance.

Type
Object

disappear()

Hide an element with visibility: hidden.

Source:
Returns:

El class instance.

Type
Object

disappearFor( [interval])

Hide an element with disappear() for x number of milliseconds.

Parameters:
Name Type Argument Default Description
interval Number <optional>
200

Interval in milliseconds.

Source:
Returns:

El class instance.

Type
Object

empty()

Empty an element's html content.

Source:
Returns:

El class instance.

Type
Object

enable( [shouldEnable])

Enable an element by attribute and class.

Parameters:
Name Type Argument Default Description
shouldEnable Boolean <optional>
true

Conditionally enable.

Source:
Returns:

El class instance.

Type
Object

encode()

Convert field value to URL encoded query string.

Source:
Returns:

URL encoded query string.

Type
String

fadeIn( [interval] [, display])

Fade in element.

Parameters:
Name Type Argument Default Description
interval Number <optional>
200

Transition interval (in milliseconds).

display String <optional>
block

CSS display property to set after element is faded in. Is only necessary if the CSS display property is set to 'none'.

Source:

fadeInFor( [speed] [, interval])

Show an element with fadeIn() for x number of milliseconds.

Parameters:
Name Type Argument Default Description
speed Number <optional>
2000

Interval in milliseconds (shown interval).

interval Number <optional>
200

Interval in milliseconds (animation speed).

Source:
Returns:

El class instance.

Type
Object

fadeOut( [interval] [, hide])

Fade out element.

Parameters:
Name Type Argument Default Description
interval Number <optional>
200

Transition interval (in milliseconds).

hide Boolean <optional>
true

Set to false to prevent element from being hidden after the animation.

Source:

fadeOutFor( [speed] [, interval])

Hide an element with fadeOut() for x number of milliseconds.

Parameters:
Name Type Argument Default Description
speed Number <optional>
2000

Interval in milliseconds (hidden interval).

interval Number <optional>
200

Interval in milliseconds (animation speed).

Source:
Returns:

El class instance.

Type
Object

focus()

Set focus on element.

Source:
Returns:

El class instance.

Type
Object

get($key)

Retrieve a child element.

Parameters:
Name Type Default Description
$key String null

Child identifying $key.

Source:
Returns:

El class instance.

Type
Object

getAttribute(attr)

Gets an attribute.

Parameters:
Name Type Description
attr String

Attribute name to get.

Source:
Returns:

Attribute value.

Type
String

getClassList()

Gets the list of classes applied to the element.

Source:
Returns:

DOMTokenList or array of classes (depending on ClassList support).

Type
Object | Array

getHTML()

Gets the html content.

Source:
Returns:

Html content.

Type
String

getText()

Gets the text content.

Source:
Returns:

Text content.

Type
String

getValue()

Gets the value.

Source:
Returns:

Element value.

Type
String

hasAttribute(attrToCheck)

Check for existence of an attribute.

Parameters:
Name Type Description
attrToCheck String

Attribute to check.

Source:
Returns:

Has attribute.

Type
Booolean

hasClass(classToCheck)

Check for class existence.

Parameters:
Name Type Description
classToCheck String

Classname to check.

Source:
Returns:

Class exists.

Type
Boolean

hasValue()

Check if an element has a value.

Source:
Returns:

Element has value.

Type
Boolean

hide()

Hide element with display rule.

Source:
Returns:

El class instance.

Type
Object

hideFor( [speed])

Call hide method, then show after x amount of ms.

Parameters:
Name Type Argument Default Description
speed Number <optional>
200

Interval to hide.

Source:
Returns:

El class instance.

Type
Object

next()

Return the next sibling element

Source:
Returns:

node

Type
Object

off(eventName, handler [, options] [, options])

Detach event handler. If only the eventName parameter is given, all events of that event type will be detached. If no arguments are given, all events will be detached.

Parameters:
Name Type Argument Default Description
eventName String

Name of event.

handler function

Function reference.

options Object <optional>

Event options.

Properties
Name Type Argument Description
capture Boolean <optional>

Event capture option.

options Boolean <optional>
false

Event capture option.

Source:
Returns:

El class instance.

Type
Object

on(eventsToBind, handler, options)

Listen for events.

Parameters:
Name Type Description
eventsToBind String | Array

Name of event(s) to bind. Can be either space-separated string or array.

handler function

Function handler reference.

options Object | Boolean

event options.

Properties
Name Type Description
capture Boolean

event capture option.

once Boolean

event once option.

passive Boolean

event passive option.

Source:
Returns:

El class instance.

Type
Object

parent()

Return the parent element.

Source:
Returns:

Parent element.

Type
Object

prepend(el)

Prepend an element or text node.

Parameters:
Name Type Description
el Object | String

Element to prepend or string to become text node to prepend.

Source:
Returns:

El class instance.

Type
Object

prependHTML(html)

Prepend HTML

Parameters:
Name Type Description
html String

HTML string to prepend.

Source:
Returns:

El class instance.

Type
Object

prependText(text)

Prepend Text

Parameters:
Name Type Description
text String

Text string to prepend.

Source:
Returns:

El class instance.

Type
Object

remove()

Completely remove an element.

Source:

removeAttribute(attr)

Remove single attribute.

Parameters:
Name Type Description
attr String

Attribute name to remove.

Source:
Returns:

El class instance.

Type
Object

removeClass(myClass)

Removes a class. Accepts a space-separated string or an array.

Parameters:
Name Type Description
myClass String | Array

ClassName(s) to remove.

Source:
Returns:

El class instance.

Type
Object

serialize( [returnType])

Transform an element value.

Parameters:
Name Type Argument Default Description
returnType String <optional>
object

The type of returned value. Either 'object', 'array', or 'string'.

Source:
Returns:

The transformed value.

Type
Object | Array | String

setAttribute(attr, attrValue)

Set single attribute.

Parameters:
Name Type Description
attr String

Attribute name to set.

attrValue String

Attribute value.

Source:
Returns:

El class instance.

Type
Object

setHTML(html)

Sets the html content.

Parameters:
Name Type Description
html String

Html to set.

Source:
Returns:

El class instance.

Type
Object

setKey($key)

Set the unique $key for an element.

Parameters:
Name Type Description
$key String

$Key to set.

Source:
Returns:

El class instance.

Type
Object

setStyles(styles)

Set styles.

Parameters:
Name Type Description
styles Object

Styles to set.

Source:
Returns:

El class instance.

Type
Object

setText(text)

Sets the text content.

Parameters:
Name Type Description
text String

Text to set.

Source:
Returns:

El class instance.

Type
Object

setValue(val)

Sets the value property.

Parameters:
Name Type Description
val String

value to set

Source:
Returns:

El class instance.

Type
Object

show()

Show element with display rule.

Source:
Returns:

El class instance.

Type
Object

showFor( [speed])

Call show method, then hide for x amount of ms.

Parameters:
Name Type Argument Default Description
speed Number <optional>
200

Interval to show.

Source:
Returns:

El class instance.

Type
Object

toggleCheck(state)

Toggles the checked state of the element.

Parameters:
Name Type Description
state Boolean

Desired check state.

Source:
Returns:

El class instance.

Type
Object

trigger(eventName [, params])

Trigger an event and dispatch it. Convenient for custom events.

Parameters:
Name Type Argument Description
eventName String

Event to trigger.

params Object <optional>

Event options.

Source:
Returns:

El class instance.

Type
Object

unbindEvents()

Unbind all events associated with an element.

Source:
Returns:

El class instance.

Type
Object