2016-11-02 15:31:58 +01:00
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
<div id="banner"><a href="https://github.com/jcbrand/converse.js/blob/master/docs/source/theming.rst">Edit me on GitHub</a></div>
|
|
|
|
|
2016-12-20 10:31:11 +01:00
|
|
|
.. _`events-API`:
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Events and promises
|
|
|
|
===================
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-29 12:03:49 +02:00
|
|
|
Converse and its plugins emit various events which you can listen to via the
|
2017-08-09 12:16:47 +02:00
|
|
|
:ref:`listen-grouping`.
|
2016-11-02 15:31:58 +01:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Some of these events are also available as `ES2015 Promises <http://es6-features.org/#PromiseUsage>`_,
|
|
|
|
although not all of them could logically act as promises, since some events
|
|
|
|
might be fired multpile times whereas promises are to be resolved (or
|
|
|
|
rejected) only once.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
The core events, which are also promises are:
|
|
|
|
|
|
|
|
* `cachedRoster`_
|
|
|
|
* `chatBoxesFetched`_
|
2017-09-16 18:11:31 +02:00
|
|
|
* `controlboxInitialized`_ (only via the `converse-controlbox` plugin)
|
2017-08-09 12:16:47 +02:00
|
|
|
* `pluginsInitialized`_
|
2017-09-16 18:11:31 +02:00
|
|
|
* `roomsPanelRendered`_ (only via the `converse-muc` plugin)
|
2017-08-09 12:16:47 +02:00
|
|
|
* `rosterContactsFetched`_
|
|
|
|
* `rosterGroupsFetched`_
|
|
|
|
* `rosterInitialized`_
|
2017-09-16 18:11:31 +02:00
|
|
|
* `roster`_
|
2017-08-09 12:16:47 +02:00
|
|
|
* `statusInitialized`_
|
|
|
|
|
|
|
|
For more info on how to use (or add promises), you can read the
|
|
|
|
:ref:`promises-grouping` in the API documentation.
|
|
|
|
|
|
|
|
Below we will now list all events and also specify whether they are available
|
|
|
|
as promises.
|
|
|
|
|
2018-04-08 19:44:53 +02:00
|
|
|
List of global events (and promises)
|
|
|
|
------------------------------------
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-04-18 19:24:49 +02:00
|
|
|
Hooking into events that Converse.js emits is a great way to extend or
|
|
|
|
customize its functionality.
|
|
|
|
|
|
|
|
From version 3.0.0 and up, it's only possible to register event handlers inside
|
|
|
|
a plugin, by using the closured ``_converse`` object. When writing a plugin,
|
|
|
|
remember that it will also have to be whitelisted, before it will be loaded.
|
|
|
|
Refer to the :ref:`whitelisted_plugins` setting.
|
|
|
|
|
|
|
|
Here follows the different events that are emitted:
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-07-21 15:01:35 +02:00
|
|
|
afterMessagesFetched
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
Emitted whenever a chatbox has fetched its messages from ``sessionStorage`` and
|
2017-07-21 15:01:35 +02:00
|
|
|
**NOT** from the server.
|
|
|
|
|
|
|
|
This event is listened to by the ``converse-mam`` plugin to know when it can
|
|
|
|
fetch archived messages from the server.
|
|
|
|
|
|
|
|
The event handler is passed the ``Backbone.View`` instance of the relevant chat
|
|
|
|
box.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('afterMessagesFetched', function (chatboxview) { ... });``
|
2017-07-21 15:01:35 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`cachedRoster`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
cachedRoster
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The contacts roster has been retrieved from the local cache (`sessionStorage`).
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('cachedRoster', function (items) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('cachedRoster').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2017-04-18 19:24:49 +02:00
|
|
|
See also the `roster`_ event further down.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
callButtonClicked
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a call button (i.e. with class .toggle-call) on a chatbox has been clicked.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('callButtonClicked', function (connection, model) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`chatBoxesFetched`:
|
|
|
|
|
|
|
|
chatBoxesFetched
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
Any open chatboxes (from this current session) has been retrieved from the local cache (`sessionStorage`).
|
2017-08-09 12:16:47 +02:00
|
|
|
|
|
|
|
You should wait for this event or promise before attempting to do things
|
2018-02-09 11:55:53 +01:00
|
|
|
related to open chatboxes.
|
2017-08-09 12:16:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxesFetched', function (items) { ... });``
|
2017-08-09 12:16:47 +02:00
|
|
|
|
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('chatBoxesFetched').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
chatBoxInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a chatbox has been initialized. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxInitialized', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxOpened
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a chatbox has been opened. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxOpened', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatRoomOpened
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a chatroom has been opened. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatRoomOpened', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxClosed
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a chatbox has been closed. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxClosed', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxFocused
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When the focus has been moved to a chatbox. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxFocused', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxToggled
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
When a chatbox has been minimized or maximized. Relevant to converse-chatview.js plugin.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('chatBoxToggled', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-18 12:44:27 +02:00
|
|
|
clearSession
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Called when the user is logging out and provides the opportunity to remove session data.
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
connected
|
|
|
|
~~~~~~~~~
|
|
|
|
|
|
|
|
After connection has been established and converse.js has got all its ducks in a row.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('connected', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
contactRequest
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Someone has requested to subscribe to your presence (i.e. to be your contact).
|
|
|
|
|
2018-05-07 10:58:58 +02:00
|
|
|
The `Backbone.Model <http://backbonejs.org/#Model>`_ instance representing the
|
|
|
|
roster contact is passed to the event listener.
|
|
|
|
|
|
|
|
``_converse.api.listen.on('contactRequest', function (contact) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
contactRemoved
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The user has removed a contact.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('contactRemoved', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
|
2018-05-22 16:44:58 +02:00
|
|
|
contactPresenceChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-22 16:44:58 +02:00
|
|
|
When a chat buddy's presence status has changed.
|
|
|
|
The presence status is either `online`, `offline`, `dnd`, `away` or `xa`.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-22 16:44:58 +02:00
|
|
|
``_converse.api.listen.on('contactPresenceChanged', function (presence) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
contactStatusMessageChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat buddy's custom status message has changed.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('contactStatusMessageChanged', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-09-16 18:11:31 +02:00
|
|
|
controlboxInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Called when the controlbox has been initialized and therefore exists.
|
|
|
|
|
|
|
|
The controlbox contains the login and register forms when
|
|
|
|
the user is logged out and a list of the user's contacts and group chats when
|
|
|
|
logged in.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('controlboxInitialized', function () { ... });``
|
2017-09-16 18:11:31 +02:00
|
|
|
|
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('controlboxInitialized').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2017-07-21 15:01:35 +02:00
|
|
|
discoInitialized
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Emitted once the ``converse-disco`` plugin has been initialized and the
|
|
|
|
``_converse.disco_entities`` collection will be available and populated with at
|
|
|
|
least the service discovery features of the user's own server.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('discoInitialized', function () { ... });``
|
2017-07-21 15:01:35 +02:00
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
disconnected
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
After converse.js has disconnected from the XMPP server.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('disconnected', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
initialized
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
Once converse.js has been initialized.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('initialized', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
See also `pluginsInitialized`_.
|
|
|
|
|
2016-11-02 08:42:24 +01:00
|
|
|
logout
|
|
|
|
~~~~~~
|
|
|
|
|
|
|
|
The user has logged out.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('logout', function () { ... });``
|
2016-11-02 08:42:24 +01:00
|
|
|
|
2017-04-20 21:25:58 +02:00
|
|
|
messageAdded
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
2018-02-09 11:55:53 +01:00
|
|
|
Once a message has been added to a chatbox. The passed in data object contains
|
|
|
|
a `chatbox` attribute, referring to the chatbox receiving the message, as well
|
2017-04-20 21:25:58 +02:00
|
|
|
as a `message` attribute which refers to the Message model.
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. code-block:: javascript
|
2017-05-03 09:16:01 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
_converse.api.listen.on('messageAdded', function (data) {
|
2017-04-20 21:25:58 +02:00
|
|
|
// The message is at `data.message`
|
2018-02-09 11:55:53 +01:00
|
|
|
// The original chatbox is at `data.chatbox`.
|
2017-04-20 21:25:58 +02:00
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
messageSend
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a message will be sent out.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('messageSend', function (messageText) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
noResumeableSession
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When keepalive=true but there aren't any stored prebind tokens.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('noResumeableSession', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`pluginsInitialized`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
pluginsInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Emitted once all plugins have been initialized. This is a useful event if you want to
|
2016-10-21 16:33:47 +02:00
|
|
|
register event handlers but would like your own handlers to be overridable by
|
|
|
|
plugins. In that case, you need to first wait until all plugins have been
|
|
|
|
initialized, so that their overrides are active. One example where this is used
|
|
|
|
is in `converse-notifications.js <https://github.com/jcbrand/converse.js/blob/master/src/converse-notification.js>`.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('pluginsInitialized', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('pluginsInitialized').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2018-05-30 17:16:26 +02:00
|
|
|
privateChatsAutoJoined
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Emitted once any private chats have been automatically joined as specified by
|
|
|
|
the _`auto_join_private_chats` settings.
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.listen.on('privateChatsAutoJoined', function () { ... });
|
|
|
|
|
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_.
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('privateChatsAutoJoined').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-11-23 15:50:28 +01:00
|
|
|
reconnecting
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Fired once converse.js has determined that it will attempt to reconnect (and
|
|
|
|
each subsequent time, if it attempts repeatedly).
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
reconnected
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
After the connection has dropped and converse.js has reconnected.
|
|
|
|
Any Strophe stanza handlers (as registered via `converse.listen.stanza`) will
|
|
|
|
have to be registered anew.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.listen.on('reconnected', function () { ... });
|
|
|
|
|
2018-05-30 17:16:26 +02:00
|
|
|
registeredGlobalEventHandlers
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2018-05-02 17:07:57 +02:00
|
|
|
|
2018-05-30 17:16:26 +02:00
|
|
|
Called once Converse has registered its global event handlers (for events such
|
|
|
|
as window resize or unload).
|
2018-05-02 17:07:57 +02:00
|
|
|
|
2018-05-30 17:16:26 +02:00
|
|
|
Plugins can listen to this event as cue to register their own global event
|
|
|
|
handlers.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-09-29 00:07:16 +02:00
|
|
|
roomsAutoJoined
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Emitted once any rooms that have been configured to be automatically joined,
|
|
|
|
specified via the _`auto_join_rooms` setting, have been entered.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.listen.on('roomsAutoJoined', function () { ... });
|
2017-09-29 00:07:16 +02:00
|
|
|
|
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('roomsAutoJoined').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
roomInviteSent
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
After the user has sent out a direct invitation, to a roster contact, asking them to join a room.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('roomInvite', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
roomInviteReceived
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
After the user has sent out a direct invitation, to a roster contact, asking them to join a room.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('roomInvite', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`roomsPanelRendered`:
|
|
|
|
|
2017-05-01 12:41:16 +02:00
|
|
|
roomsPanelRendered
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Emitted once the "Rooms" panel in the control box has been rendered.
|
|
|
|
Used by `converse-bookmarks` and `converse-roomslist` to know when they can
|
|
|
|
render themselves in that panel.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('roomsPanelRendered', function (data) { ... });``
|
2017-05-01 12:41:16 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('roomsPanelRendered').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
|
|
|
.. _`roster`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
roster
|
|
|
|
~~~~~~
|
|
|
|
|
|
|
|
When the roster has been received from the XMPP server.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('roster', function (items) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('roster').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
See also the `cachedRoster` event further up, which gets called instead of
|
|
|
|
`roster` if its already in `sessionStorage`.
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`rosterContactsFetched`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
rosterContactsFetched
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Triggered once roster contacts have been fetched. Used by the
|
|
|
|
`converse-rosterview.js` plugin to know when it can start to show the roster.
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('rosterContactsFetched').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
|
|
|
.. _`rosterGroupsFetched`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
rosterGroupsFetched
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Triggered once roster groups have been fetched. Used by the
|
|
|
|
`converse-rosterview.js` plugin to know when it can start alphabetically
|
|
|
|
position roster groups.
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('rosterGroupsFetched').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
|
|
|
.. _`rosterInitialized`:
|
|
|
|
|
2016-11-02 14:13:49 +01:00
|
|
|
rosterInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The Backbone collections `RosterContacts` and `RosterGroups` have been created,
|
|
|
|
but not yet populated with data.
|
|
|
|
|
|
|
|
This event is useful when you want to create views for these collections.
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('rosterInitialized').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
rosterPush
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
When the roster receives a push event from server. (i.e. New entry in your buddy list)
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('rosterPush', function (items) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2016-11-02 14:13:49 +01:00
|
|
|
rosterReadyAfterReconnection
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Similar to `rosterInitialized`, but instead pertaining to reconnection. This
|
|
|
|
event indicates that the Backbone collections representing the roster and its
|
|
|
|
groups are now again available after converse.js has reconnected.
|
|
|
|
|
2018-05-29 12:03:49 +02:00
|
|
|
serviceDiscovered
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When converse.js has learned of a service provided by the XMPP server. See XEP-0030.
|
|
|
|
|
|
|
|
``_converse.api.listen.on('serviceDiscovered', function (service) { ... });``
|
|
|
|
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
.. _`statusInitialized`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
statusInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
When the user's own chat status has been initialized.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('statusInitialized', function (status) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-08-09 12:16:47 +02:00
|
|
|
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
_converse.api.waitUntil('statusInitialized').then(function () {
|
|
|
|
// Your code here...
|
|
|
|
});
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
statusChanged
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When own chat status has changed.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('statusChanged', function (status) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
statusMessageChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When own custom status message has changed.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('statusMessageChanged', function (message) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-29 12:03:49 +02:00
|
|
|
streamFeaturesAdded
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2018-05-29 12:03:49 +02:00
|
|
|
Emitted as soon as Converse has processed the stream features as advertised by
|
|
|
|
the server. If you want to check whether a stream feature is supported before
|
|
|
|
proceeding, then you'll first want to wait for this event.
|
2017-05-03 09:06:28 +02:00
|
|
|
|
|
|
|
windowStateChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When window state has changed. Used to determine when a user left the page and when came back.
|
|
|
|
|
2018-05-02 17:07:57 +02:00
|
|
|
``_converse.api.listen.on('windowStateChanged', function (data) { ... });``
|
2018-04-08 19:44:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
List of events on the ChatRoom Backbone.Model
|
|
|
|
---------------------------------------------
|
|
|
|
|
|
|
|
configurationNeeded
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Triggered when a new room has been created which first needs to be configured
|
|
|
|
and when `auto_configure` is set to `false`.
|
|
|
|
|
|
|
|
Used by the core `ChatRoomView` view in order to know when to render the
|
|
|
|
configuration form for a new room.
|