API Docs for:
Show:

LS.ComponentContainer Class

Module: LS

ComponentContainer class allows to add component based properties to any other class

Constructor

LS.ComponentContainer

()

Methods

addComponent

(
  • component
)
Object

Adds a component to this node. (maybe attach would been a better name)

Parameters:

  • component Object

Returns:

Object:

component added

broadcastMessage

(
  • method_name
  • params
)

executes the method with a given name in all the components and its children

Parameters:

  • method_name String

    the name of the function to execute in all components (in string format)

  • params Array

    array with every parameter that the function may need

configureComponents

(
  • info
)

Adds a component to this node.

Parameters:

  • info Object

    object containing all the info from a previous serialization

findComponent

(
  • component
)
Array

Returns a list of components matching the search, it search in the node and child nodes

Parameters:

  • component Class | String

    the component class or the class name

Returns:

Array:

an array with all the components of the same class

getComponent

(
  • component_class
  • index
)

Returns the first component of this container that is of the same class

Parameters:

  • component_class Object | String

    the class to search a component from (could be the class or the name)

  • index Number

    [optional] if you want the Nth component of this class

getComponentByIndex

(
  • component
)

Returns the component at index position

Parameters:

  • component Object

getComponentByUId

(
  • uid
)

Returns the component with the given uid

Parameters:

  • uid String

    the uid to search

getComponents

() Array

returns an array with all the components

Returns:

Array:

all the components

getIndexOfComponent

(
  • position
)

Returns the position in the components array of this component

Parameters:

  • position Number

    in the array, -1 if not found

hasComponent

(
  • component_class
  • search_missing
)

Returns if the container has a component of this class

Parameters:

  • component_class String | Class

    the component to search for, could be a string or the class itself

  • search_missing Boolean

    [optional] true if you want to search in the missing components too

processActionInComponents

(
  • method_name
  • params
  • skip_scripts
)

executes the method with a given name in all the components

Parameters:

  • method_name String

    the name of the function to execute in all components (in string format)

  • params Array

    array with every parameter that the function may need

  • skip_scripts Boolean

    [optional] skip scripts

removeAllComponents

(
  • component
)

Removes all components from this node.

Parameters:

  • component Object

removeComponent

(
  • component
)

Removes a component from this node.

Parameters:

  • component Object

requireComponent

(
  • component_class
  • data
)
Component

Ensures this node has a component of the specified class, if not it creates one and attaches it

Parameters:

  • component_class Object | String

    the class to search a component from (could be the class or the name)

  • data Object

    [optional] the object to configure the component from

Returns:

Component:

the component found or created

requireScript

(
  • url
)
Component

Ensures this node has a ScriptFromFile component of the specified script url, if not it creates one and attaches it

Parameters:

  • url String

    the url to the script

Returns:

Component:

the ScriptFromFile component found or created

serializeComponents

(
  • o
)

Adds a component to this node.

Parameters:

  • o Object

    container where the components will be stored

setComponentIndex

(
  • component
)

Changes the order of a component

Parameters:

  • component Object