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:
- chat: State to indicate a willingness to chat
- available: State to indicate general availability; this state is represented in presence by NOT including a <show/> element.
- away: State to indicate temporarily away.
- xa: State to indicate extended away.
- dnd: State to indicate busy or do not disturb.
- unavaiable: State to indicate offline; this state is represented in presence via the type="unavailable" attribute.
This class provides the following events:
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.ui.SelfPresenceView(client, primaryPresence)
Creates a new SelfPresenceView with the given client. |
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 Attributes | Method Name and Description |
---|---|
createDOM(doc)
Creates the DOM to display. |
|
destroy()
Destroys this SelfPresenceView. |
|
getStatusChoices(show)
Retrieves the list of choices for the given show type. |
|
restoreDOM(doc)
Restore the DOM for a SelfPresenceView |
|
setStatusChoices(show, choices)
Changes or removes the list of choices for the given show type. |
|
update()
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
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
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.
The client to montior and affect for presence changes.
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"] }
An array stores presence status.
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
Destroys this SelfPresenceView. This method unbinds all callbacks before calling the superclass' implementation.
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
Restore the DOM for a SelfPresenceView
- Parameters:
- {Document} doc
- The document to use for creating content.
- Returns:
- {jQuery} The element containing the view.
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
Updates the display for this SelfPresenceView. This method does the following:
- Regenerates the status choices from {#link @getStatusChoices} into the DOM, for each registered show state
- Sets the active choice (adding it if not already present) in the <select/>
- Changes the <img/> src attribute to reflect the current show state
- 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