Class Index | Minimal

Classes


Class jabberwerx.ui.SelfPresenceView


Extends jabberwerx.ui.JWView.

View for displaying and modifying the client's presence.

The show states used by SelfPresenceView are a superset of what is valid according to RFC 3921. Except where noted, the values are content in the <show/> element of the presence. The value used are:

  1. chat: State to indicate a willingness to chat
  2. available: State to indicate general availability; this state is represented in presence by NOT including a <show/> element.
  3. away: State to indicate temporarily away.
  4. xa: State to indicate extended away.
  5. dnd: State to indicate busy or do not disturb.
  6. unavaiable: State to indicate offline; this state is represented in presence via the type="unavailable" attribute.

This class provides the following events:

Class Summary
Constructor Attributes Constructor Name and Description
 
jabberwerx.ui.SelfPresenceView(client, primaryPresence)

Creates a new SelfPresenceView with the given client.

Field Summary
Field Attributes Field Name and Description
 

Flag to indicate if the "unavailable" selection group is an allowed selection choice.

 

The client to montior and affect for presence changes.

<static>  
jabberwerx.ui.SelfPresenceView.default_status_choices

The mapping of default status choices.

<static>  
jabberwerx.ui.SelfPresenceView.sortedShows

An array stores presence status.

Fields borrowed from class jabberwerx.ui.JWView:
jq
Method Summary
Method Attributes Method Name and Description
 
createDOM(doc)

Creates the DOM to display.

 

Destroys this SelfPresenceView.

 

Retrieves the list of choices for the given show type.

 

Restore the DOM for a SelfPresenceView

 
setStatusChoices(show, choices)

Changes or removes the list of choices for the given show type.

 

Updates the display for this SelfPresenceView.

Methods borrowed from class jabberwerx.ui.JWView:
destroyDOM, dimensions, height, hide, parent, persistOptions, remove, render, restoreRender, restoreUpdate, shouldBeSavedWithGraph, show, wasUnserialized, width, willBeSerialized
Methods borrowed from class jabberwerx.JWModel:
applyEvent, event
Methods borrowed from class jabberwerx.JWBase:
getClassName, graphUnserialized, init, invocation, shouldBeSerializedInline, toString
Class Detail
jabberwerx.ui.SelfPresenceView(client, primaryPresence)

Creates a new SelfPresenceView with the given client.

Parameters:
{jabberwerx.Client} client
The client
{Boolean} primaryPresence Optional
This optional flag dictates if the self presence shown in this view should be the resource presence for this client, or the primary presence of this client. It defaults to false (i.e. presence shown is resource presence).
Throws:
{TypeError}
If {client} is not valid
Field Detail
{Boolean} allowUnavailable

Flag to indicate if the "unavailable" selection group is an allowed selection choice.

NOTE: If this flag is true, it is the responsibility of the API user to handle the connection and updating presence.


{jabberwerx.Client} client

The client to montior and affect for presence changes.


<static> jabberwerx.ui.SelfPresenceView.default_status_choices

The mapping of default status choices. The choices are:

{
 "available":["Available", "Ready to Chat!"],
 "away": ["Away", "Stepped Out", "Out to Lunch"],
 "dnd": ["Do Not Disturb", "Busy", "In a Meeting"],
 "unavailable": ["Offline"]
}

<static> {String[]} jabberwerx.ui.SelfPresenceView.sortedShows

An array stores presence status.

Method Detail
{Element} createDOM(doc)

Creates the DOM to display. This method creates the following DOM:

<div class="jabberwerx self presence status">
     <img style="position:absolute"/>
     <select style="width:100%;"/>
</div>

It also binds a callback for "change" events on the <select/> element.

Parameters:
{Document} doc
The document to use for creating content.
Returns:
{Element} The generated element to display

destroy()

Destroys this SelfPresenceView. This method unbinds all callbacks before calling the superclass' implementation.


{String[]} getStatusChoices(show)

Retrieves the list of choices for the given show type.

Parameters:
{String} show
The "show" state to retrieve (one of: "available", "chat", "away", "xa", "dnd", "unavailable")
Throws:
{TypeError}
if {show} is not valid
Returns:
{String[]} The array of choices, or [] (empty array) if none.
See:
#constructor

{jQuery} restoreDOM(doc)

Restore the DOM for a SelfPresenceView

Parameters:
{Document} doc
The document to use for creating content.
Returns:
{jQuery} The element containing the view.

setStatusChoices(show, choices)

Changes or removes the list of choices for the given show type.

If {choices} is null, undefined, or [], then the choices for {show} are removed. Otherwise the list is updated to the given array. #update is called once the choices have been changed/removed.

Parameters:
{String} show
The "show" state to retrieve (one of: "available", "chat", "away", "xa", "dnd", "unavailable")
{String[]} choices
The array of choices, or {null|undefined|[]} to remove.
Throws:
{TypeError}
if {show} is not valid
See:
#constructor

{Boolean} update()

Updates the display for this SelfPresenceView. This method does the following:

  1. Regenerates the status choices from {#link @getStatusChoices} into the DOM, for each registered show state
  2. Sets the active choice (adding it if not already present) in the <select/>
  3. Changes the <img/> src attribute to reflect the current show state
  4. Triggeres a "viewRendered" event

If #allowUnavailable is true (and an array of status choices for "unavailable" is registered), it is added to the <select/>.

Returns:
{Boolean} true if this SelfPresenceView is updatable

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:43 GMT-0600 (MDT)