Class jabberwerx.ui.RosterView
Extends
jabberwerx.ui.JWView.
View over an EntitySet (oftimes referred to as a "roster").
This class provides the following events:
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.ui.RosterView(cache, mode)
Creates a new RosterView with the given cache and mode. |
Field Attributes | Field Name and Description |
---|---|
The EntitySet cache this RosterView is a view for. |
|
<static> |
jabberwerx.ui.RosterView.groupmode_collapsed
Mode for a collapsed grouping. |
<static> |
jabberwerx.ui.RosterView.groupmode_expanded
Mode for an expanded grouping. |
<static> |
jabberwerx.ui.RosterView.groupmode_single
Mode for a "single-mode" grouping. |
- Fields borrowed from class jabberwerx.ui.JWView:
- jq
Method Attributes | Method Name and Description |
---|---|
addFilter(filter)
Adds a filter for the contents of the RosterView. |
|
Removes all of the filters. |
|
createDOM(doc)
Creates the DOM for this RosterView. |
|
destroy()
Destroys this RosterView. |
|
destroyDOM(doc)
Destroys the DOM for this RosterView. |
|
filterByActive(entity)
Function that can be used to filter entities that aren't online. |
|
filterByContacts(entity)
Function that can be used to filter entities that aren't contacts (i.e. |
|
Retrieves the default grouping display name. |
|
groupByGroups(entity)
Retrieves the groups for this Entity |
|
grouping(name)
Retrieves the grouping for the given name. |
|
removeFilter(filter)
Removes a filter from the RosterView. |
|
setDefaultGroupingName(name)
Changes the default grouping display name. |
|
setSort(sort)
Sets the sort function for the entities. |
|
sortByDisplayName(a, b)
Compare two entities by display Name |
|
sortEntityByDisplayName(a, b)
Function that can be used for sorting to compare two entites by display name. |
|
update()
Updates this RosterView's display. |
- Methods borrowed from class jabberwerx.ui.JWView:
- dimensions, height, hide, parent, persistOptions, remove, render, restoreDOM, restoreRender, restoreUpdate, shouldBeSavedWithGraph, show, wasUnserialized, width, willBeSerialized
- Methods borrowed from class jabberwerx.JWModel:
- applyEvent, event
- Methods borrowed from class jabberwerx.JWBase:
- getClassName, init, invocation, shouldBeSerializedInline, toString
Creates a new RosterView with the given cache and mode. If {mode} is .groupmode_single, then the display is effectively a flat list of all entities. Otherewise, the display consists of zero or more groupings that contain entities.
- Parameters:
- {jabberwerx.EntitySet} cache
- The cache
- {Number} mode Optional
- The default group mode (one of jabberwerx.ui.RosterView.groupmode_collapsed, jabberwerx.ui.RosterView.groupmode_expanded, or jabberwerx.ui.RosterView.groupmode_single)
- Throws:
- {TypeError}
- If {cache} is not an instance of EntitySet; or if {mode} is not an accepted value
The EntitySet cache this RosterView is a view for.
Mode for a collapsed grouping.
Mode for an expanded grouping.
Mode for a "single-mode" grouping.
Adds a filter for the contents of the RosterView. Multiple filters can be applied. If one filter says an entry should be hidden, the entry becomes hidden. Another filter cannot override that.
- Parameters:
- {function} filter
- A function that takes an Entity and returns false if the entry should be hidden.
- Throws:
- {TypeError}
- If {filter} is not a function
Removes all of the filters.
Creates the DOM for this RosterView. This method creates the following basic structure:
<div class='jabberwerx roster'></div>
If #cache contains any groupings, each is rendered and appended to the container <div/>.
- Parameters:
- {Document} doc
- The owning document
- Returns:
- {Element} The DOM for this RosterView
Destroys this RosterView. This method unbinds all callbacks before calling the superclass' implementation.
Destroys the DOM for this RosterView. This implementation iterates through all the groupings, calling jabberwerx.ui.RosterView.Grouping#destroy.
- Parameters:
- doc
Function that can be used to filter entities that aren't online.
- Parameters:
- {jabberwerx.Entity} entity
- The contact/roster
- Returns:
- {Boolean} true if {entity} is active
Function that can be used to filter entities that aren't contacts (i.e. local user and the server).
- Parameters:
- {jabberwerx.Entity} entity
- The contact/roster
- Returns:
- {Boolean} true if {entity} is an instance of jabberwerx.Contact
Retrieves the default grouping display name. This is the value displayed in the DOM for the "" grouping.
This is not linked to jabberwerx.RosterController.defaultGroup.
- Returns:
- {String} The default grouping name
Retrieves the groups for this Entity
- Parameters:
- {jabberwerx.Entity} entity
- The Entity
- Returns:
- {String[]} The array of groups
Retrieves the grouping for the given name.
- Parameters:
- {String} name
- The grouping name (or "" for the default grouping name).
- Returns:
- {jabberwerx.ui.RosterView.Grouping} The grouping for the given name, or {null} if not found
Removes a filter from the RosterView.
- Parameters:
- {function} filter
- The function that was passed into jabberwerx.ui.RosterView#addFilter that should be removed.
Changes the default grouping display name. If {name} is not equal to the current value, it is changed to {name} and the default grouping (if any) is updated.
- Parameters:
- {String} name
- The new default grouping name
- Throws:
- {TypeError}
- If {name} is not a valid non-empty string.
Sets the sort function for the entities. Pass in nothing if you want to clear the sort function.
- Parameters:
- {function} sort
- The function called to compare two entities. The function takes two parameters, both entities, and returns -1 if the first one is less than the second one, 1 if the first one is greater than the second one and 0 if they are equal.
- Throws:
- {TypeError}
- If {sort} is not a function or null
Compare two entities by display Name
- Parameters:
- {jabberwerx.Entity} a
- The contact/roster
- {jabberwerx.Entity} b
- The contact/roster
- Returns:
- {Number} Returns 0 if {a}={b}; 1 if {a}>{b}; otherwise returns -1
Function that can be used for sorting to compare two entites by display name.
- Parameters:
- {jabberwerx.Entity} a
- The contact/roster
- {jabberwerx.Entity} b
- The contact/roster
- Returns:
- {Number} Returns 0 if equals; 1 if greater; -1 if less
Updates this RosterView's display. This implementation walks the current groupings, inserting any missing into this RosterView's DOM, then calling jabberwerx.ui.RosterView.Grouping#update.
- Returns:
- {Boolean} true if this RosterView is updatable