Class: Component

F. Component

new Component(options)

Generic component class
Parameters:
Name Type Argument Description
options Object <optional>
Component options
Properties
Name Type Argument Default Description
singly Boolean <optional>
false Whether this component will allow multiple sub-components to be visible at once. If true, only one component will be visible at a time.
visible Boolean <optional>
false If true, this component will be visible immediately.
debug Boolean <optional>
false If true, show debug messages for this component.
independent Boolean <optional>
false If true, the parent component will never be notified that this component has been shown. Useful for children of singly components that should not cause their siblings to be hidden when they are shown
Properties:
Name Type Description
options Object Default options for this component. These will be merged with options passed to the constructor.
Source:

Extends

Methods

addComponent(component, componentName) → {F.Component}

Add an instance of another component as a sub-component. this[subComponent.toString()] is used to reference the sub-component: this.List.show(); You can give a component an optional custom name as the second argument, then reference as such: this.myCustomComponent.show();
Parameters:
Name Type Argument Description
component F.Component Instance of component
componentName String <optional>
Optional custom name for this component
Source:
Returns:
The sub-component that was added
Type
F.Component

bind(name)

Binds a method to the execution scope of this instance
Parameters:
Name Type Description
name String The name of the method to bind. For example, to bind this.handleClick, you would use this.bind('handleClick')
Source:

bubble(componentName, evt) → {F.Component}

Set an event to bubble up the component chain by re-triggering it when the given sub-component triggers it
Parameters:
Name Type Description
componentName String Name of the component whose event to bubble
evt String Name of event to bubble up
Source:
Returns:
this, chainable
Type
F.Component

destruct()

Destroy this instance and free associated memory
Source:

handleRenderComplete()

Called when view rendering is complete
Source:

hide(options) → {F.Component}

Hide this component
Parameters:
Name Type Argument Description
options Object <optional>
Options object
Properties
Name Type Argument Default Description
silent Boolean <optional>
false If true, events will not be triggered
hideChildren Boolean <optional>
true If false, children will not be hidden automatically
Source:
Returns:
this, chainable
Type
F.Component

hideAllSubComponents(except) → {F.Component}

Hide all sub-components
Parameters:
Name Type Argument Description
except String[] <optional>
List of component names not to hide. These components will not be shown if they are already hidden
Source:
Returns:
this, chainable
Type
F.Component

inDebugMode() → {Boolean}

Check if this component, or F as a whole, is in debug mode and should output debug messages
Source:
Returns:
Component or F is in debug mode
Type
Boolean

init()

Performs initialization operations after all constructors have been called
Source:

isVisible() → {Boolean}

Check if this component is currently visible
Source:
Returns:
Component is visible
Type
Boolean

listenTo(other, event, callback)

An inversion-of-control version of on. Tell this object to listen to an event in another object keeping track of what it's listening to.
Parameters:
Name Type Description
other Object The object to listen to
event String Name of the event to listen to
callback Function Callback to execute when the event is triggered
Inherited From:
Source:

mergeOptions()

Merge options up the prototype chain. Options defined in the child class take precedence over those defined in the parent class.
Source:

off(event, callback, context)

Remove one or many callbacks. If context is null, removes all callbacks with that function. If callback is null, removes all callbacks for the event. If events is null, removes all bound callbacks for all events.
Parameters:
Name Type Argument Description
event String <optional>
Name of the event that is being listened to
callback Function <optional>
Callback to remove
context Object <optional>
Remove callbacks with the specified context
Inherited From:
Source:

on(event, callback, context)

Bind one or more space separated events, or an events map, to a callback function. Passing "all" will bind the callback to all events fired.
Parameters:
Name Type Argument Description
event String Event to listen to
callback Function Callback to execute when the event is triggered
context Object <optional>
The value of this when the callback runs
Inherited From:
Source:

once(event, callback, context)

Bind events to only be triggered a single time. After the first time the callback is invoked, it will be removed.
Parameters:
Name Type Argument Description
event String Name of the event to listen to
callback Function Callback to execute when the event is triggered
context Object <optional>
The value of this when the callback runs
Inherited From:
Source:

removeComponent(componentName) → {F.Component}

Remove and destroy a sub-component
Parameters:
Name Type Description
componentName String Component name
Source:
Returns:
this, chainable
Type
F.Component

removeComponents() → {F.Component}

Remove and destroy all sub-components
Source:
Returns:
this, chainable
Type
F.Component

render() → {F.Component}

Render the view associated with this component, if it has one
Source:
Returns:
this, chainable
Type
F.Component

setName(componentName) → {F.Component}

Set a custom name for this component. Only useful before passing to F.Component.addComponent
Parameters:
Name Type Description
componentName String Component name
Source:
Returns:
this, chainable
Type
F.Component

setPropsFromOptions(options, props) → {F.Component}

Set properties of this instance from an options object, then remove the properties from the options object
Parameters:
Name Type Description
options Object Options object with many properties
props String[] Properties to copy from options object
Source:
Returns:
this, chainable
Type
F.Component

setup()

Perform setup operations before this component is shown for the first time, such as adding sub-components
Source:

show(options) → {F.Component}

Show this component and emit an event so parent components can show themselves.
Parameters:
Name Type Argument Description
options Object <optional>
Options object
Properties
Name Type Argument Default Description
silent Boolean <optional>
false If true, events will not be triggered
Source:
Returns:
this, chainable
Type
F.Component

showAllSubComponents(except) → {F.Component}

Show all sub-components
Parameters:
Name Type Argument Description
except String[] <optional>
List of component names not to show. These components will not be hidden if they are already shown
Source:
Returns:
this, chainable
Type
F.Component

stopListening(other, event, callback)

Tell this object to stop listening to either specific events or to every object it's currently listening to.
Parameters:
Name Type Argument Description
other Object <optional>
The object that is being listened to
event String <optional>
Name of the event that is being listened to
callback Function <optional>
Callback to remove
Inherited From:
Source:

teardown()

Perform tear-down operations after this component is hidden, such as removing sub-components. This method will not be called unless the setup() method is defined and the component has been shown previously
Source:

teardownIfSetup()

Calls teardown() if necessary
Source:

toString() → {String}

Get this component's name
Source:
Returns:
Component's name; either a custom name given when added with F.Component.addComponent, or toString method or string from prototype
Type
String

trigger(event, args)

Trigger one or many events, firing all bound callbacks. Callbacks are passed the same arguments as trigger is, apart from the event name (unless you're listening on "all", which will cause your callback to receive the true name of the event as the first argument).
Parameters:
Name Type Argument Description
event String Name of the event to trigger
args Mixed <optional>
<repeatable>
Arguments to pass to callback functions
Inherited From:
Source:

unbubble(componentName, evt) → {F.Component}

Discontinue bubbling of a given event
Parameters:
Name Type Description
componentName String Name of the component whose event to stop bubbling
evt String Name of event that was set to bubble
Source:
Returns:
this, chainable
Type
F.Component

Events

component:hidden

Triggered when this component is hidden
Parameters:
Name Type Description
evt Object Event object
Properties
Name Type Description
name String This component's name
component F.Component This component
Source:

component:shown

Triggered when this component is shown
Parameters:
Name Type Description
evt Object Event object
Properties
Name Type Description
name String This component's name
component F.Component This component
Source: