Skip to main content

ensemble.base

ensemble#

ensemble~base#

A base class for ensemble components.

Kind: inner abstract class of ensemble

new base([element], options)#

Constructor method.

ParamTypeDescription
[element]ElementA valid element, could be used within the extending class
optionsobjectOptions object

Example

new base([, element], options)

base.defaults(defaults, options) โ‡’ object#

Creates an options Object from a defaults object of pre-defined properties.

Note it supports only the first level of depth.

Kind: instance method of base

ParamTypeDescription
defaultsobjectThe default options Object
optionsobjectAn options Object that would extends

base.compo(ns, [tag], [name]) โ‡’ mixed#

Shorthand method for ensemble.Compo class.

When passed the first argument it makes a new Compo instance, otherwise it returns a reference to the Compo class.

Kind: instance method of base
Returns: mixed - Instance of ensemble.Data -or- ensemble.Data class reference

ParamTypeDefaultDescription
nsstringComposition namespace
[tag]string"'div'"The [DOM] Element node tag -or- component name, empty for ensemble.Compo class reference
[name]mixedThe composition name, used for CSS className

base.data(obj) โ‡’ mixed#

Shorthand method for ensemble.Data class.

When passed the first argument it makes a new Data instance, otherwise it returns a reference to the Data class.

Kind: instance method of base
Returns: mixed - Instance of ensemble.Data -or- ensemble.Data class reference

ParamTypeDescription
objobjectA starter Object, empty for ensemble.Data class reference

base.event(obj) โ‡’ mixed#

Shorthand method for ensemble.Event class.

When the passed first argument is a string it makes a new Event instance, if you pass an Event as the first argument, a preventDefault and blur will be performed, otherwise it returns a reference to the Event class.

Kind: instance method of base

ParamTypeDescription
objobjectA starter Object, empty for ensemble.Event class reference

base.selector(query, node, all) โ‡’ mixed#

Shortcut to querySelectorAll() and querySelector() [DOM].

Kind: instance method of base
Returns: mixed - - Element -or- ElementCollection
See

  • Element.querySelectorAll()
  • Element.querySelector()
ParamTypeDefaultDescription
querystringA text query
nodeElementAn Element node where find
allbooleanfalseFind single or multiple elements

base.appendNode(parent, node) โ‡’ boolean#

Shortcut to appendChild() [DOM].

Kind: instance method of base
See: Element.appendChild()

ParamTypeDescription
parentElementAn Element parent
nodeElementAn Element node to append

base.prependNode(parent, node) โ‡’ boolean#

Shortcut to prependChild() [DOM].

Kind: instance method of base
See: Element.prependChild()

ParamTypeDescription
parentElementAn Element parent
nodeElementAn Element node to prepend

base.removeNode(parent, node) โ‡’ boolean#

Shortcut to cloneNode() [DOM].

Kind: instance method of base
See: Element.removeNode()

ParamTypeDescription
parentElementAn Element parent
nodeElementAn Element node to remove

base.cloneNode(node, deep) โ‡’ boolean#

Shortcut to Element.cloneNode() [DOM].

Kind: instance method of base
See: Element.cloneNode()

ParamTypeDefaultDescription
nodeElementAn Element node to clone
deepbooleanfalseClone also all children inside the Element node

base.hasAttr(node, attr) โ‡’ boolean#

Shortcut to Element.hasAttribute() [DOM].

Kind: instance method of base
See: Element.hasAttribute()

ParamTypeDescription
nodeElementAn Element node
attrstringAn attribute

base.getAttr(node, attr) โ‡’ string#

Shortcut to Element.getAttribute() [DOM].

Kind: instance method of base
See: Element.getAttribute()

ParamTypeDescription
nodeElementAn Element node
attrstringAn attribute

base.setAttr(node, attr, value)#

Shortcut to Element.setAttribute() [DOM].

Kind: instance method of base
See: Element.setAttribute()

ParamTypeDescription
nodeElementAn Element node
attrstringAn attribute
valuestringThe value

base.delAttr(node, attr)#

Shortcut to Element.removettribute() [DOM].

Kind: instance method of base
See: Element.removeAttribute()

ParamTypeDescription
nodeElementAn Element node
attrstringAn attribute

base.binds(method) โ‡’ function#

Creates a proxy function with bindings to instance and optionally an event.

Kind: instance method of base
Todo

  • untrusted method
ParamTypeDescription
methodfunctionA method from the current instance

base.delay(func, node, dtime)#

Provides a delay and executes a callback function

Kind: instance method of base
See: window.setTimeout()

ParamTypeDescription
funcfunctionA function callback
nodemixedAn Element node -or- an ensemble.Compo composition
dtimeintA default value of time in milliseconds

base.timing(node, prop) โ‡’ int#

Calculates a time, based on a time property of the style of an element

Kind: instance method of base
Returns: int - time - Number of time in milliseconds
See: window.getComputedStyle()

ParamTypeDefaultDescription
nodemixedAn Element node -or- an ensemble.Compo composition
propstring"transitionDuration"A style property