Class: ControllerClass

Widget. ControllerClass

new ControllerClass()

Instantiated as a controller object for each Widget instance. Contains methods for acquiring data, selecting elements within Widget, and relevant properties.

Source:

Members

<readonly> $element :jQuery

Reference to this Widget's containing element.

Type:
  • jQuery
Source:

<readonly> attributes :Object

Index of attributes provided via Widget tag or Widget.create parameters.

Type:
Source:
To Do:
  • Make these dynamic as attributes are modified.

<readonly> eventScope :String

Type:
Source:

<readonly> layout :String

Name of main layout template for this Widget, initially Widget.ControllerClass#prefix + '_'. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onReconnect :callbackGeneric

Developer callback. Fired on reestablishment of User Server XMPP connection. Use this event to refresh lists of data, and to reenable user interfaces that were disabled while offline. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onRun :callbackGeneric

Developer callback. Behavioral starting point, fired on successful initialization of Widget controller. This includes complete loading of templates and scripts, but not multimedia or styles. Will not be retriggered by network reconnection, see Widget.ControllerClass#onReconnect for this functionality. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletActive :callbackFrameworkEvent

Developer callback. Fired on change of whether Starlet has primary focus. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletFocused :callbackFrameworkEvent

Developer callback. Fired on change of whether Starlet's application window has focus. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletHidden :callbackFrameworkEvent

Developer callback. Fired on change of whether Starlet's application window is hidden. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletMinimized :callbackFrameworkEvent

Developer callback. Fired on change of whether Starlet's application window is minimized. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletMouse :callbackFrameworkEvent

Developer callback. Fired on change of whether Starlet's WebView contains the mouse pointer. Override in custom Widget definition.

Type:
Source:
See:

<abstract> onStarletVisible :callbackFrameworkEvent

Developer callback. Fired on change of visibility of Starlet to the user. Override in custom Widget definition.

Type:
Source:
See:

<readonly> prefix :String

Type:
Source:

<readonly> root :String

Path to directory of resources for this Widget type.

Type:
Source:

<readonly> type :String

Type of this Widget.

Type:
Source:

<readonly> uniqueId :Number

A numeric identifier by Widget type.

Type:
Source:

<readonly> uniqueName :String

Type:
Source:

Methods

ask(packet, meta) → {Object}

Request data with criteria, or send a data-related instruction expecting a result. Data on demand (action), future updates (subscribe), or both can be acquired via this single method.

Parameters:
Name Type Description
packet String

Name of OrionObjects.DataPacket being requested.

meta Object

Criteria and information about the request. Besides the properties defined below, each packet type expects varying additional criteria.

Properties
Name Type Argument Description
action String <optional>

Action to be performed immediately (e.g. 'list', 'get', etc.).

subscribe Boolean <optional>

Whether to receive future updates.

callback function <optional>

Function to respond to incoming data. May also be associated via the promise's then method, though it will only resolve once. Remember to specify the context of the callback or include a closure so it can access its controller.

Source:
See:
Returns:

promise

Type
Object
Examples
Bus.ask('users',
{
  'action'   : 'list',
  'subscribe': true,
  'callback' : controller.onUserData.bind(controller)
});
          
controller.ask('users', {'action': 'list'}).then(controller.onUserData.bind(controller));

broadcast(packetName, data) → {Object}

Emit data under a specific packet name to any Widget listening for it, regardless of this Widget type.

Parameters:
Name Type Description
packetName String

Topic to target specific listeners.

data Object | Array

The item to broadcast.

Source:
See:
Returns:
Type
Object

find(arguments) → {jQuery}

Wrapper method for jQuery's find, with context forced to Widget element.

Parameters:
Name Type Argument Description
arguments Mixed <repeatable>

Selectors to pass to jQuery's find method.

Source:
See:
Returns:

element(s)

Type
jQuery

ignore(widgetType, packetName) → {Object}

Stop listening for data from a specific Widget type and of a specific packet name.

Parameters:
Name Type Description
widgetType String

Type of Widget to stop listening for data from.

packetName String

Topic to stop listening for.

Source:
See:
Returns:
Type
Object

Opens a lightbox overlay with specific location and dimensions.

Parameters:
Name Type Description
name String

Framework name of new WebView.

url String

Location to open in lightbox.

width Number

Width at which to open lightbox.

height Number

Height at which to open lightbox.

Source:
See:
Returns:
Type
Object

Closes a lightbox overlay by name.

Parameters:
Name Type Description
name String

Framework name of WebView to close.

Source:
See:
Returns:
Type
Object

listen(widgetType, packetName, callback) → {Object}

Listen for data from a specific Widget type and of a specific packet name.

Parameters:
Name Type Description
widgetType String

Type of Widget to listen for data from.

packetName String

Topic to listen for.

callback function

Function to respond to incoming data.

Source:
See:
Returns:
Type
Object

Creates a Bootstrap modal dialog in a manner that forces a consistent z-index.

Parameters:
Name Type Argument Default Description
html String

Raw html to pass through to Bootstrap modal method.

options Object <optional>
{}

Additional options.

Properties
Name Type Argument Default Description
className String <optional>

Custom CSS class name to add to modal element.

backdrop Boolean | String <optional>
'static'

Whether to include backdrop, and to allow click to dismiss.

keyboard Boolean <optional>
true

Whether to allow esc to dismiss.

show Boolean <optional>
true

Whether to show immediately.

remote Boolean | String <optional>
false

Remote content URL.

Source:
See:
Returns:
Type
Object

Controls Bootstrap modal dialog.

Parameters:
Name Type Description
action String

Action (show|hide|toggle) to pass through to Bootstrap modal method.

Source:
See:
Returns:
Type
Object

on(arguments) → {Object}

Wrapper method for jQuery's on, with context forced to Widget element.

Parameters:
Name Type Argument Description
arguments Mixed <repeatable>

Selectors, event names, or event handlers to pass to jQuery's on method.

Source:
See:
Returns:
Type
Object

speak(packetName, data) → {Object}

Emit data under a specific packet name to any Widget listening for it and this Widget type.

Parameters:
Name Type Description
packetName String

Topic to target specific listeners.

data Object | Array

The item to broadcast.

Source:
See:
Returns:

Widget.CopntrollerClass

Type
Object

tell(packet, meta) → {Boolean}

Send a data-related instruction, expecting no result.

Parameters:
Name Type Description
packet String

Name of OrionObjects.DataPacket being requested.

meta Object

Criteria and information about the request. Besides action, each packet type expects varying additional criteria.

Properties
Name Type Argument Description
action String <optional>

Action to be performed (e.g. 'list', 'get', etc.).

Source:
See:
Returns:

true

Type
Boolean
Example
controller.tell('usergroups',
{
  'action': 'create',
  'name'  : 'Foo',
  'users' : [1, 2, 3]
});