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
-
'.widget_' + Widget.ControllerClass#prefix + Widget.ControllerClass#uniqueId
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:
-
- Widget.define
- Widget.onRun
-
<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:
-
- Widget.define
- Widget.onReconnect
-
<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
-
Widget.ControllerClass#type + '_'.
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 packetString Name of OrionObjects.DataPacket being requested.
metaObject Criteria and information about the request. Besides the properties defined below, each packet type expects varying additional criteria.
Properties
Name Type Argument Description actionString <optional>
Action to be performed immediately (e.g. 'list', 'get', etc.).
subscribeBoolean <optional>
Whether to receive future updates.
callbackfunction <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 packetNameString Topic to target specific listeners.
dataObject | 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 argumentsMixed <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 widgetTypeString Type of Widget to stop listening for data from.
packetNameString Topic to stop listening for.
- Source:
- See:
Returns:
- Type
- Object
-
lightbox(name, url, width, height) → {Object}
-
Opens a lightbox overlay with specific location and dimensions.
Parameters:
Name Type Description nameString Framework name of new WebView.
urlString Location to open in lightbox.
widthNumber Width at which to open lightbox.
heightNumber Height at which to open lightbox.
- Source:
- See:
Returns:
- Type
- Object
-
lightbox(name) → {Object}
-
Closes a lightbox overlay by name.
Parameters:
Name Type Description nameString 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 widgetTypeString Type of Widget to listen for data from.
packetNameString Topic to listen for.
callbackfunction Function to respond to incoming data.
- Source:
- See:
Returns:
- Type
- Object
-
modal(html, options) → {Object}
-
Creates a Bootstrap modal dialog in a manner that forces a consistent z-index.
Parameters:
Name Type Argument Default Description htmlString Raw html to pass through to Bootstrap modal method.
optionsObject <optional>
{} Additional options.
Properties
Name Type Argument Default Description classNameString <optional>
Custom CSS class name to add to modal element.
backdropBoolean | String <optional>
'static' Whether to include backdrop, and to allow click to dismiss.
keyboardBoolean <optional>
true Whether to allow esc to dismiss.
showBoolean <optional>
true Whether to show immediately.
remoteBoolean | String <optional>
false Remote content URL.
- Source:
- See:
Returns:
- Type
- Object
-
modal(action) → {Object}
-
Controls Bootstrap modal dialog.
Parameters:
Name Type Description actionString 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 argumentsMixed <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 packetNameString Topic to target specific listeners.
dataObject | 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 packetString Name of OrionObjects.DataPacket being requested.
metaObject Criteria and information about the request. Besides action, each packet type expects varying additional criteria.
Properties
Name Type Argument Description actionString <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] });