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`:
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
Events emitted by converse.js
|
|
|
|
=============================
|
|
|
|
|
2016-11-02 15:31:58 +01:00
|
|
|
.. contents:: Table of Contents
|
|
|
|
:depth: 2
|
|
|
|
:local:
|
|
|
|
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
.. note:: see also :ref:`listen-grouping` above.
|
|
|
|
|
|
|
|
Event Types
|
|
|
|
-----------
|
|
|
|
|
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
|
|
|
|
|
|
|
cachedRoster
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The contacts roster has been retrieved from the local cache (`sessionStorage`).
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('cachedRoster', function (items) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
2017-04-18 19:24:49 +02:00
|
|
|
See also the `roster`_ event further down.
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
callButtonClicked
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a call button (i.e. with class .toggle-call) on a chat box has been clicked.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('callButtonClicked', function (connection, model) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat box has been initialized. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatBoxInitialized', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxOpened
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat box has been opened. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatBoxOpened', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatRoomOpened
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat room has been opened. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatRoomOpened', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxClosed
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat box has been closed. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatBoxClosed', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxFocused
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When the focus has been moved to a chat box. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatBoxFocused', function (chatbox) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
chatBoxToggled
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat box has been minimized or maximized. Relevant to converse-chatview.js plugin.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('chatBoxToggled', function (chatbox) { ... });``
|
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.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.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).
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('contactRequest', function (user_data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
contactRemoved
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The user has removed a contact.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('contactRemoved', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
contactStatusChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat buddy's chat status has changed.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('contactStatusChanged', function (buddy) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
contactStatusMessageChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a chat buddy's custom status message has changed.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('contactStatusMessageChanged', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
disconnected
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
After converse.js has disconnected from the XMPP server.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('disconnected', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
initialized
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
Once converse.js has been initialized.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.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.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('logout', function () { ... });``
|
2016-11-02 08:42:24 +01:00
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
messageSend
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
|
|
|
When a message will be sent out.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('messageSend', function (messageText) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
noResumeableSession
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When keepalive=true but there aren't any stored prebind tokens.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('noResumeableSession', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
pluginsInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Once all plugins have been initialized. This is a useful event if you want to
|
|
|
|
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>`.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('pluginsInitialized', function () { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
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.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('reconnected', function () { ... });``
|
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.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.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.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('roomInvite', function (data) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
roster
|
|
|
|
~~~~~~
|
|
|
|
|
|
|
|
When the roster has been received from the XMPP server.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('roster', function (items) { ... });``
|
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`.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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)
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.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.
|
|
|
|
|
2016-10-21 16:33:47 +02:00
|
|
|
statusInitialized
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When own chat status has been initialized.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('statusInitialized', function (status) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
statusChanged
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When own chat status has changed.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('statusChanged', function (status) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
statusMessageChanged
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When own custom status message has changed.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('statusMessageChanged', function (message) { ... });``
|
2016-10-21 16:33:47 +02:00
|
|
|
|
|
|
|
serviceDiscovered
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
When converse.js has learned of a service provided by the XMPP server. See XEP-0030.
|
|
|
|
|
2017-04-19 17:48:50 +02:00
|
|
|
``_converse.on('serviceDiscovered', function (service) { ... });``
|