Use strict mode. Emit an event when the connection drops.

This commit is contained in:
JC Brand 2014-04-24 09:51:21 +02:00
parent 64408d2e0a
commit d69a165b05
7 changed files with 176 additions and 278 deletions

View File

@ -5,6 +5,7 @@
* Copyright (c) 2012, Jan-Carel Brand <jc@opkode.com>
* Dual licensed under the MIT and GPL Licenses
*/
"use strict";
// AMD/global registrations
(function (root, factory) {
@ -340,6 +341,7 @@
this.reconnect = function () {
converse.giveFeedback(__('Reconnecting'), 'error');
converse.emit('onReconnect');
if (!converse.prebind) {
this.connection.connect(
this.connection.jid,
@ -3219,6 +3221,7 @@
},
getPrettyStatus: function (stat) {
var pretty_status;
if (stat === 'chat') {
pretty_status = __('online');
} else if (stat === 'dnd') {

View File

@ -4,16 +4,17 @@ Changelog
0.8 (Unreleased)
----------------
.. note:: Converse.js is now relicensed under the `Mozilla Public License http://www.mozilla.org/MPL/2.0/`_.
* Chat boxes and rooms can now be resized vertically. [jcbrand]
* Upgraded many dependencies to their latest versions. [jcbrand]
* Add new configuration setting `forward_messages <https://conversejs.org/docs/html/index.html#forward_messages>`_
Message forwarding was before default behavior but is now optional (and disabled by default).
[jcbrand]
Message forwarding was before default behavior but is now optional (and disabled by default). [jcbrand]
* Newly opened chat boxes always appear immediately left of the controlbox.
* #71 Chat boxes and rooms can be minimized. [jcbrand]
* #130 Fixed bootstrap conflicts. [jcbrand]
* #132 Support for `XEP-0280: Message Carbons <https://xmpp.org/extensions/xep-0280.html'>`_.
Configured via `enable_message_carbons <https://conversejs.org/docs/html/index.html#enable_message_carbons>`_
[hejazee]
Configured via `enable_message_carbons <https://conversejs.org/docs/html/index.html#enable_message_carbons>`_ [hejazee]
0.7.4 (2014-03-05)
------------------

Binary file not shown.

View File

@ -280,7 +280,7 @@ These values are then passed to converse.js's ``initialize`` method.
Example code for server-side prebinding
---------------------------------------
* PHP:
* PHP:
See `xmpp-prebind-php <https://github.com/candy-chat/xmpp-prebind-php>`_ by
Michael Weibel and the folks from Candy chat.
@ -418,7 +418,7 @@ Converse.js directly depends and which will therefore be loaded in the browser.
If you are curious to know what the different dependencies are:
* Development dependencies:
* Development dependencies:
Take a look at whats under the *devDependencies* key in
`package.json <https://github.com/jcbrand/converse.js/blob/master/package.json>`_.
@ -647,7 +647,7 @@ Troubleshooting
Conflicts with other Javascript libraries
=========================================
Problem:
Problem:
---------
You are using other Javascript libraries (like JQuery plugins), and
@ -668,7 +668,7 @@ rules apply if its something else.
The bundled and minified default build of converse.js, ``converse.min.js``
includes within it all of converse.js's dependencies, which include for example *jQuery*.
If you are having conflicts where attributes or methods aren't available
If you are having conflicts where attributes or methods aren't available
on the jQuery object, you are probably loading ``converse.min.js`` (which
includes jQuery) as well as your own jQuery version separately.
@ -721,7 +721,7 @@ Concerning events, the following methods are available:
Event Methods
=============
* **on(eventName, callback)**:
* **on(eventName, callback)**:
Calling the ``on`` method allows you to subscribe to an event.
Every time the event fires, the callback method specified by ``callback`` will be
@ -745,7 +745,7 @@ Event Methods
* ``eventName`` is the event name as a string.
* ``callback`` is the callback method to be called when the event is emitted.
For example::
converse.once('onMessage', function (messageXML) { ... });
@ -765,91 +765,39 @@ Event Types
Here are the different events that are emitted:
* **onInitialized**
``converse.on('onInitialized', function () { ... });``
Triggered once converse.js has been initialized.
* **onReady**
Triggered after a connection has been established and converse.js has
got all its ducks in a row.
``converse.on('onReady', function () { ... });``
* **onMessage**
``converse.on('onMessage', function (messageXML) { ... });``
Triggered when a message is received.
* **onMessageSend**
``converse.on('onMessageSend', function (messageText) { ... });``
Triggered when a message will be sent out.
* **onRoster**
``converse.on('onRoster', function (items) { ... });``
Triggered when the roster is updated.
* **onRosterViewUpdated**
``converse.on('onRosterViewUpdated', function (items) { ... });``
Triggered whenever the roster view (i.e. the rendered HTML) has changed.
* **onChatBoxClosed**
``converse.on('onChatBoxClosed', function (chatbox) { ... });``
Triggered when a chat box has been closed.
* **onChatBoxFocused**
``converse.on('onChatBoxFocused', function (chatbox) { ... });``
Triggered when the focus has been moved to a chat box.
* **onChatBoxOpened**
``converse.on('onChatBoxOpened', function (chatbox) { ... });``
Triggered when a chat box has been opened.
* **onChatBoxToggled**
``converse.on('onChatBoxToggled', function (chatbox) { ... });``
Triggered when a chat box has been minimized or maximized.
* **onStatusChanged**
``converse.on('onStatusChanged', function (status) { ... });``
Triggered when own chat status has changed.
* **onStatusMessageChanged**
``converse.on('onStatusMessageChanged', function (message) { ... });``
Triggered when own custom status message has changed.
* **onBuddyStatusChanged**
``converse.on('onBuddyStatusChanged', function (buddy, status) { ... });``
Triggered when a chat buddy's chat status has changed.
* **onBuddyStatusMessageChanged**
``converse.on('onBuddyStatusMessageChanged', function (buddy, messageText) { ... });``
Triggered when a chat buddy's custom status message has changed.
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| Event Type | When is it triggered? | Example |
+==================================+===================================================================================================+=========================================================================================+
| **onInitialized** | Once converse.js has been initialized. | ``converse.on('onInitialized', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onReady** | After connection has been established and converse.js has got all its ducks in a row. | ``converse.on('onReady', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onReconnect** | After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode. | ``converse.on('onReconnect', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onMessage** | When a message is received. | ``converse.on('onMessage', function (messageXML) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onMessageSend** | When a message will be sent out. | ``converse.on('onMessageSend', function (messageText) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onRoster** | When the roster is updated. | ``converse.on('onRoster', function (items) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onRosterViewUpdated** | Whenever the roster view (i.e. the rendered HTML) has changed. | ``converse.on('onRosterViewUpdated', function (items) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxOpened** | When a chat box has been opened. | ``converse.on('onChatBoxOpened', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxClosed** | When a chat box has been closed. | ``converse.on('onChatBoxClosed', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxFocused** | When the focus has been moved to a chat box. | ``converse.on('onChatBoxFocused', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxToggled** | When a chat box has been minimized or maximized. | ``converse.on('onChatBoxToggled', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onStatusChanged** | When own chat status has changed. | ``converse.on('onStatusChanged', function (status) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onStatusMessageChanged** | When own custom status message has changed. | ``converse.on('onStatusMessageChanged', function (message) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onBuddyStatusChanged** | When a chat buddy's chat status has changed. | ``converse.on('onBuddyStatusChanged', function (buddy, status) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onBuddyStatusMessageChanged** | When a chat buddy's custom status message has changed. | ``converse.on('onBuddyStatusMessageChanged', function (buddy, messageText) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
=============
Configuration
@ -954,7 +902,7 @@ for each page load. While more inconvenient, this is a much more secure option.
This setting can only be used together with ``allow_otr = true``.
.. Note ::
.. Note ::
A browser window's session storage is accessible by all javascript that
is served from the same domain. So if there is malicious javascript served by
the same server (or somehow injected via an attacker), then they will be able
@ -982,7 +930,7 @@ Default = ``false``
Allow the prebind tokens, RID (request ID) and SID (session ID), to be exposed
globally via the API. This allows other scripts served on the same page to use
these values.
these values.
*Beware*: a malicious script could use these tokens to assume your identity
and inject fake chat messages.
@ -1161,6 +1109,10 @@ Used only in conjunction with ``xhr_user_search``.
This is the URL to which an AJAX GET request will be made to fetch user data from your remote server.
The query string will be included in the request with ``q`` as its key.
The calendar can be configured through a `data-pat-calendar` attribute.
The available options are:
.. _`read more about require.js's optimizer here`: http://requirejs.org/docs/optimization.html
.. _`HTTP`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
.. _`XMPP`: https://en.wikipedia.org/wiki/Xmpp

View File

@ -733,93 +733,81 @@ exactly once.</p>
<div class="section" id="event-types">
<h2><a class="toc-backref" href="#id33">Event Types</a><a class="headerlink" href="#event-types" title="Permalink to this headline"></a></h2>
<p>Here are the different events that are emitted:</p>
<ul>
<li><p class="first"><strong>onInitialized</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onInitialized',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered once converse.js has been initialized.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onReady</strong></p>
<blockquote>
<div><p>Triggered after a connection has been established and converse.js has
got all its ducks in a row.</p>
<p><tt class="docutils literal"><span class="pre">converse.on('onReady',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
</div></blockquote>
</li>
<li><p class="first"><strong>onMessage</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onMessage',</span> <span class="pre">function</span> <span class="pre">(messageXML)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a message is received.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onMessageSend</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onMessageSend',</span> <span class="pre">function</span> <span class="pre">(messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a message will be sent out.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onRoster</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onRoster',</span> <span class="pre">function</span> <span class="pre">(items)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when the roster is updated.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onRosterViewUpdated</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onRosterViewUpdated',</span> <span class="pre">function</span> <span class="pre">(items)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered whenever the roster view (i.e. the rendered HTML) has changed.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onChatBoxClosed</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onChatBoxClosed',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a chat box has been closed.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onChatBoxFocused</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onChatBoxFocused',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when the focus has been moved to a chat box.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onChatBoxOpened</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onChatBoxOpened',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a chat box has been opened.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onChatBoxToggled</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onChatBoxToggled',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a chat box has been minimized or maximized.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onStatusChanged</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onStatusChanged',</span> <span class="pre">function</span> <span class="pre">(status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when own chat status has changed.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onStatusMessageChanged</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onStatusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(message)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when own custom status message has changed.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onBuddyStatusChanged</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onBuddyStatusChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a chat buddy&#8217;s chat status has changed.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>onBuddyStatusMessageChanged</strong></p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">converse.on('onBuddyStatusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></p>
<p>Triggered when a chat buddy&#8217;s custom status message has changed.</p>
</div></blockquote>
</li>
</ul>
<table border="1" class="docutils">
<colgroup>
<col width="15%" />
<col width="45%" />
<col width="40%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Event Type</th>
<th class="head">When is it triggered?</th>
<th class="head">Example</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><strong>onInitialized</strong></td>
<td>Once converse.js has been initialized.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onInitialized',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onReady</strong></td>
<td>After connection has been established and converse.js has got all its ducks in a row.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onReady',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onReconnect</strong></td>
<td>After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onReconnect',</span> <span class="pre">function</span> <span class="pre">()</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onMessage</strong></td>
<td>When a message is received.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onMessage',</span> <span class="pre">function</span> <span class="pre">(messageXML)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onMessageSend</strong></td>
<td>When a message will be sent out.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onMessageSend',</span> <span class="pre">function</span> <span class="pre">(messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onRoster</strong></td>
<td>When the roster is updated.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onRoster',</span> <span class="pre">function</span> <span class="pre">(items)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onRosterViewUpdated</strong></td>
<td>Whenever the roster view (i.e. the rendered HTML) has changed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onRosterViewUpdated',</span> <span class="pre">function</span> <span class="pre">(items)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onChatBoxOpened</strong></td>
<td>When a chat box has been opened.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onChatBoxOpened',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onChatBoxClosed</strong></td>
<td>When a chat box has been closed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onChatBoxClosed',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onChatBoxFocused</strong></td>
<td>When the focus has been moved to a chat box.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onChatBoxFocused',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onChatBoxToggled</strong></td>
<td>When a chat box has been minimized or maximized.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onChatBoxToggled',</span> <span class="pre">function</span> <span class="pre">(chatbox)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onStatusChanged</strong></td>
<td>When own chat status has changed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onStatusChanged',</span> <span class="pre">function</span> <span class="pre">(status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onStatusMessageChanged</strong></td>
<td>When own custom status message has changed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onStatusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(message)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-odd"><td><strong>onBuddyStatusChanged</strong></td>
<td>When a chat buddy&#8217;s chat status has changed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onBuddyStatusChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">status)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
<tr class="row-even"><td><strong>onBuddyStatusMessageChanged</strong></td>
<td>When a chat buddy&#8217;s custom status message has changed.</td>
<td><tt class="docutils literal"><span class="pre">converse.on('onBuddyStatusMessageChanged',</span> <span class="pre">function</span> <span class="pre">(buddy,</span> <span class="pre">messageText)</span> <span class="pre">{</span> <span class="pre">...</span> <span class="pre">});</span></tt></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="configuration">
@ -1053,6 +1041,8 @@ corresponds to a matched user and needs the keys <tt class="docutils literal"><s
<p>Used only in conjunction with <tt class="docutils literal"><span class="pre">xhr_user_search</span></tt>.</p>
<p>This is the URL to which an AJAX GET request will be made to fetch user data from your remote server.
The query string will be included in the request with <tt class="docutils literal"><span class="pre">q</span></tt> as its key.</p>
<p>The calendar can be configured through a <cite>data-pat-calendar</cite> attribute.
The available options are:</p>
</div>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@ -280,7 +280,7 @@ These values are then passed to converse.js's ``initialize`` method.
Example code for server-side prebinding
---------------------------------------
* PHP:
* PHP:
See `xmpp-prebind-php <https://github.com/candy-chat/xmpp-prebind-php>`_ by
Michael Weibel and the folks from Candy chat.
@ -418,7 +418,7 @@ Converse.js directly depends and which will therefore be loaded in the browser.
If you are curious to know what the different dependencies are:
* Development dependencies:
* Development dependencies:
Take a look at whats under the *devDependencies* key in
`package.json <https://github.com/jcbrand/converse.js/blob/master/package.json>`_.
@ -647,7 +647,7 @@ Troubleshooting
Conflicts with other Javascript libraries
=========================================
Problem:
Problem:
---------
You are using other Javascript libraries (like JQuery plugins), and
@ -668,7 +668,7 @@ rules apply if its something else.
The bundled and minified default build of converse.js, ``converse.min.js``
includes within it all of converse.js's dependencies, which include for example *jQuery*.
If you are having conflicts where attributes or methods aren't available
If you are having conflicts where attributes or methods aren't available
on the jQuery object, you are probably loading ``converse.min.js`` (which
includes jQuery) as well as your own jQuery version separately.
@ -721,7 +721,7 @@ Concerning events, the following methods are available:
Event Methods
=============
* **on(eventName, callback)**:
* **on(eventName, callback)**:
Calling the ``on`` method allows you to subscribe to an event.
Every time the event fires, the callback method specified by ``callback`` will be
@ -745,7 +745,7 @@ Event Methods
* ``eventName`` is the event name as a string.
* ``callback`` is the callback method to be called when the event is emitted.
For example::
converse.once('onMessage', function (messageXML) { ... });
@ -765,91 +765,39 @@ Event Types
Here are the different events that are emitted:
* **onInitialized**
``converse.on('onInitialized', function () { ... });``
Triggered once converse.js has been initialized.
* **onReady**
Triggered after a connection has been established and converse.js has
got all its ducks in a row.
``converse.on('onReady', function () { ... });``
* **onMessage**
``converse.on('onMessage', function (messageXML) { ... });``
Triggered when a message is received.
* **onMessageSend**
``converse.on('onMessageSend', function (messageText) { ... });``
Triggered when a message will be sent out.
* **onRoster**
``converse.on('onRoster', function (items) { ... });``
Triggered when the roster is updated.
* **onRosterViewUpdated**
``converse.on('onRosterViewUpdated', function (items) { ... });``
Triggered whenever the roster view (i.e. the rendered HTML) has changed.
* **onChatBoxClosed**
``converse.on('onChatBoxClosed', function (chatbox) { ... });``
Triggered when a chat box has been closed.
* **onChatBoxFocused**
``converse.on('onChatBoxFocused', function (chatbox) { ... });``
Triggered when the focus has been moved to a chat box.
* **onChatBoxOpened**
``converse.on('onChatBoxOpened', function (chatbox) { ... });``
Triggered when a chat box has been opened.
* **onChatBoxToggled**
``converse.on('onChatBoxToggled', function (chatbox) { ... });``
Triggered when a chat box has been minimized or maximized.
* **onStatusChanged**
``converse.on('onStatusChanged', function (status) { ... });``
Triggered when own chat status has changed.
* **onStatusMessageChanged**
``converse.on('onStatusMessageChanged', function (message) { ... });``
Triggered when own custom status message has changed.
* **onBuddyStatusChanged**
``converse.on('onBuddyStatusChanged', function (buddy, status) { ... });``
Triggered when a chat buddy's chat status has changed.
* **onBuddyStatusMessageChanged**
``converse.on('onBuddyStatusMessageChanged', function (buddy, messageText) { ... });``
Triggered when a chat buddy's custom status message has changed.
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| Event Type | When is it triggered? | Example |
+==================================+===================================================================================================+=========================================================================================+
| **onInitialized** | Once converse.js has been initialized. | ``converse.on('onInitialized', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onReady** | After connection has been established and converse.js has got all its ducks in a row. | ``converse.on('onReady', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onReconnect** | After the connection has dropped. Converse.js will attempt to reconnect when not in prebind mode. | ``converse.on('onReconnect', function () { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onMessage** | When a message is received. | ``converse.on('onMessage', function (messageXML) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onMessageSend** | When a message will be sent out. | ``converse.on('onMessageSend', function (messageText) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onRoster** | When the roster is updated. | ``converse.on('onRoster', function (items) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onRosterViewUpdated** | Whenever the roster view (i.e. the rendered HTML) has changed. | ``converse.on('onRosterViewUpdated', function (items) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxOpened** | When a chat box has been opened. | ``converse.on('onChatBoxOpened', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxClosed** | When a chat box has been closed. | ``converse.on('onChatBoxClosed', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxFocused** | When the focus has been moved to a chat box. | ``converse.on('onChatBoxFocused', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onChatBoxToggled** | When a chat box has been minimized or maximized. | ``converse.on('onChatBoxToggled', function (chatbox) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onStatusChanged** | When own chat status has changed. | ``converse.on('onStatusChanged', function (status) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onStatusMessageChanged** | When own custom status message has changed. | ``converse.on('onStatusMessageChanged', function (message) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onBuddyStatusChanged** | When a chat buddy's chat status has changed. | ``converse.on('onBuddyStatusChanged', function (buddy, status) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
| **onBuddyStatusMessageChanged** | When a chat buddy's custom status message has changed. | ``converse.on('onBuddyStatusMessageChanged', function (buddy, messageText) { ... });`` |
+----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
=============
Configuration
@ -954,7 +902,7 @@ for each page load. While more inconvenient, this is a much more secure option.
This setting can only be used together with ``allow_otr = true``.
.. Note ::
.. Note ::
A browser window's session storage is accessible by all javascript that
is served from the same domain. So if there is malicious javascript served by
the same server (or somehow injected via an attacker), then they will be able
@ -982,7 +930,7 @@ Default = ``false``
Allow the prebind tokens, RID (request ID) and SID (session ID), to be exposed
globally via the API. This allows other scripts served on the same page to use
these values.
these values.
*Beware*: a malicious script could use these tokens to assume your identity
and inject fake chat messages.
@ -1161,6 +1109,10 @@ Used only in conjunction with ``xhr_user_search``.
This is the URL to which an AJAX GET request will be made to fetch user data from your remote server.
The query string will be included in the request with ``q`` as its key.
The calendar can be configured through a `data-pat-calendar` attribute.
The available options are:
.. _`read more about require.js's optimizer here`: http://requirejs.org/docs/optimization.html
.. _`HTTP`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
.. _`XMPP`: https://en.wikipedia.org/wiki/Xmpp