Update to pluggable.js 0.0.2
This commit is contained in:
parent
66c7c41888
commit
89e5bd7c54
|
@ -1,6 +1,7 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.0.7 (Unreleased)
|
## 2.0.0 (Unreleased)
|
||||||
|
- Backwards incompatible change: the `_super` attribute in plugins is now named `__super__`. [jcbrand]
|
||||||
- Continuously attempt to resurrect dead connections when `auto_reconnect` is `true`. [jcbrand]
|
- Continuously attempt to resurrect dead connections when `auto_reconnect` is `true`. [jcbrand]
|
||||||
- Update the 'rooms' API to allow user to pass in room attributes. [jcbrand]
|
- Update the 'rooms' API to allow user to pass in room attributes. [jcbrand]
|
||||||
- Add new configuration setting [message_storage](https://conversejs.org/docs/html/configuration.html#message_storage) [jcbrand]
|
- Add new configuration setting [message_storage](https://conversejs.org/docs/html/configuration.html#message_storage) [jcbrand]
|
||||||
|
|
|
@ -1030,14 +1030,21 @@ When converse.js has learned of a service provided by the XMPP server. See XEP-0
|
||||||
``converse.listen.on('serviceDiscovered', function (event, service) { ... });``
|
``converse.listen.on('serviceDiscovered', function (event, service) { ... });``
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Writing a converse.js plugin
|
Writing a converse.js plugin
|
||||||
============================
|
============================
|
||||||
|
|
||||||
Converse.js exposes a plugin mechanism which allows developers to extend and
|
Developers are able to extend and override the objects, functions and the
|
||||||
override its functionality.
|
Backbone models and views that make up converse.js by means of writing plugins.
|
||||||
|
|
||||||
You register a plugin as follows:
|
Converse.js uses `pluggable.js <https://github.com/jcbrand/pluggable.js/>`_ as
|
||||||
|
its plugin architecture.
|
||||||
|
|
||||||
|
To understand how this plugin architecture works, please read the
|
||||||
|
`pluggable.js documentation <https://jcbrand.github.io/pluggable.js/>`_
|
||||||
|
and to grok its inner workins, please refer to the `annotated source code
|
||||||
|
<https://jcbrand.github.io/pluggable.js/docs/pluggable.html>`_.
|
||||||
|
|
||||||
|
You register a converse.js plugin as follows:
|
||||||
|
|
||||||
.. code-block:: javascript
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
@ -1146,28 +1153,28 @@ An example plugin
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// You can access the original function being overridden
|
// You can access the original function being overridden
|
||||||
// via the _super attribute.
|
// via the __super__ attribute.
|
||||||
// Make sure to pass on the arguments supplied to this
|
// Make sure to pass on the arguments supplied to this
|
||||||
// function and also to apply the proper "this" object.
|
// function and also to apply the proper "this" object.
|
||||||
this._super.onConnected.apply(this, arguments);
|
this.__super__.onConnected.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
XMPPStatus: {
|
XMPPStatus: {
|
||||||
// Override converse.js's XMPPStatus Backbone model so that we can override the
|
// Override converse.js's XMPPStatus Backbone model so that we can override the
|
||||||
// function that sends out the presence stanza.
|
// function that sends out the presence stanza.
|
||||||
sendPresence: function (type, status_message, jid) {
|
sendPresence: function (type, status_message, jid) {
|
||||||
// The "converse" object is available via the _super
|
// The "converse" object is available via the __super__
|
||||||
// attribute.
|
// attribute.
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
|
|
||||||
// Custom code can come here
|
// Custom code can come here
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// You can call the original overridden method, by
|
// You can call the original overridden method, by
|
||||||
// accessing it via the _super attribute.
|
// accessing it via the __super__ attribute.
|
||||||
// When calling it, you need to apply the proper
|
// When calling it, you need to apply the proper
|
||||||
// context as reference by the "this" variable.
|
// context as reference by the "this" variable.
|
||||||
this._super.sendPresence.apply(this, arguments);
|
this.__super__.sendPresence.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"requirejs": "~2.2.0",
|
"requirejs": "~2.2.0",
|
||||||
"pluggable.js": "https://github.com/jcbrand/pluggable.js.git#0a43995de5186b6a575719127a28eda2f3f2fb86",
|
"pluggable.js": "0.0.2",
|
||||||
"jquery": "1.12.3",
|
"jquery": "1.12.3",
|
||||||
"jed": "0.5.4",
|
"jed": "0.5.4",
|
||||||
"underscore": "~1.8.3",
|
"underscore": "~1.8.3",
|
||||||
|
|
|
@ -204,7 +204,7 @@
|
||||||
* method.
|
* method.
|
||||||
*
|
*
|
||||||
* If a method is overridden, then the original method will still be
|
* If a method is overridden, then the original method will still be
|
||||||
* available via the _super attribute.
|
* available via the __super__ attribute.
|
||||||
*
|
*
|
||||||
* name: The attribute being overridden.
|
* name: The attribute being overridden.
|
||||||
* value: The value of the attribute being overridden.
|
* value: The value of the attribute being overridden.
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
/* Helper method for overriding or extending Converse's Backbone Views or Models
|
/* Helper method for overriding or extending Converse's Backbone Views or Models
|
||||||
*
|
*
|
||||||
* When a method is overriden, the original will still be available
|
* When a method is overriden, the original will still be available
|
||||||
* on the _super attribute of the object being overridden.
|
* on the __super__ attribute of the object being overridden.
|
||||||
*
|
*
|
||||||
* obj: The Backbone View or Model
|
* obj: The Backbone View or Model
|
||||||
* attributes: A hash of attributes, such as you would pass to Backbone.Model.extend or Backbone.View.extend
|
* attributes: A hash of attributes, such as you would pass to Backbone.Model.extend or Backbone.View.extend
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
this.add(item.get('id'), view);
|
this.add(item.get('id'), view);
|
||||||
return view;
|
return view;
|
||||||
} else {
|
} else {
|
||||||
return this._super.onChatBoxAdded.apply(this, arguments);
|
return this.__super__.onChatBoxAdded.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,18 @@
|
||||||
|
|
||||||
initSession: function () {
|
initSession: function () {
|
||||||
this.controlboxtoggle = new this.ControlBoxToggle();
|
this.controlboxtoggle = new this.ControlBoxToggle();
|
||||||
this._super.initSession.apply(this, arguments);
|
this.__super__.initSession.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
initConnection: function () {
|
initConnection: function () {
|
||||||
this._super.initConnection.apply(this, arguments);
|
this.__super__.initConnection.apply(this, arguments);
|
||||||
if (this.connection) {
|
if (this.connection) {
|
||||||
this.addControlBox();
|
this.addControlBox();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisconnected: function () {
|
onDisconnected: function () {
|
||||||
var result = this._super.onDisconnected.apply(this, arguments);
|
var result = this.__super__.onDisconnected.apply(this, arguments);
|
||||||
// Set connected to `false`, so that if we reconnect,
|
// Set connected to `false`, so that if we reconnect,
|
||||||
// "onConnected" will be called, to fetch the roster again and
|
// "onConnected" will be called, to fetch the roster again and
|
||||||
// to send out a presence stanza.
|
// to send out a presence stanza.
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
afterReconnected: function () {
|
afterReconnected: function () {
|
||||||
this._super.afterReconnected.apply(this, arguments);
|
this.__super__.afterReconnected.apply(this, arguments);
|
||||||
var view = converse.chatboxviews.get('controlbox');
|
var view = converse.chatboxviews.get('controlbox');
|
||||||
if (view.model.get('connected')) {
|
if (view.model.get('connected')) {
|
||||||
converse.chatboxviews.get("controlbox").onConnected();
|
converse.chatboxviews.get("controlbox").onConnected();
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
_tearDown: function () {
|
_tearDown: function () {
|
||||||
this._super._tearDown.apply(this, arguments);
|
this.__super__._tearDown.apply(this, arguments);
|
||||||
if (this.rosterview) {
|
if (this.rosterview) {
|
||||||
this.rosterview.unregisterHandlers();
|
this.rosterview.unregisterHandlers();
|
||||||
// Removes roster groups
|
// Removes roster groups
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
clearSession: function () {
|
clearSession: function () {
|
||||||
this._super.clearSession.apply(this, arguments);
|
this.__super__.clearSession.apply(this, arguments);
|
||||||
if (typeof this.connection !== 'undefined' && this.connection.connected) {
|
if (typeof this.connection !== 'undefined' && this.connection.connected) {
|
||||||
this.chatboxes.get('controlbox').save({'connected': false});
|
this.chatboxes.get('controlbox').save({'connected': false});
|
||||||
}
|
}
|
||||||
|
@ -92,12 +92,12 @@
|
||||||
|
|
||||||
ChatBoxes: {
|
ChatBoxes: {
|
||||||
chatBoxMayBeShown: function (chatbox) {
|
chatBoxMayBeShown: function (chatbox) {
|
||||||
return this._super.chatBoxMayBeShown.apply(this, arguments) &&
|
return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
|
||||||
chatbox.get('id') !== 'controlbox';
|
chatbox.get('id') !== 'controlbox';
|
||||||
},
|
},
|
||||||
|
|
||||||
onChatBoxesFetched: function (collection, resp) {
|
onChatBoxesFetched: function (collection, resp) {
|
||||||
this._super.onChatBoxesFetched.apply(this, arguments);
|
this.__super__.onChatBoxesFetched.apply(this, arguments);
|
||||||
if (!_.include(_.pluck(resp, 'id'), 'controlbox')) {
|
if (!_.include(_.pluck(resp, 'id'), 'controlbox')) {
|
||||||
this.add({
|
this.add({
|
||||||
id: 'controlbox',
|
id: 'controlbox',
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
return this.add(item.get('id'), view);
|
return this.add(item.get('id'), view);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return this._super.onChatBoxAdded.apply(this, arguments);
|
return this.__super__.onChatBoxAdded.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
return controlbox.$el.outerWidth(true);
|
return controlbox.$el.outerWidth(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return this._super.getChatBoxWidth.apply(this, arguments);
|
return this.__super__.getChatBoxWidth.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
'num_unread': 0
|
'num_unread': 0
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make converse pluggable
|
// Make converse pluggable
|
||||||
pluggable.enable(converse, 'converse');
|
pluggable.enable(converse, 'converse', 'pluggable');
|
||||||
|
|
||||||
// Module-level constants
|
// Module-level constants
|
||||||
converse.STATUS_WEIGHTS = {
|
converse.STATUS_WEIGHTS = {
|
||||||
|
|
|
@ -56,12 +56,12 @@
|
||||||
this.resizing = null;
|
this.resizing = null;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
return this._super.registerGlobalEventHandlers.apply(this, arguments);
|
return this.__super__.registerGlobalEventHandlers.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
ChatBox: {
|
ChatBox: {
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
var result = this._super.initialize.apply(this, arguments),
|
var result = this.__super__.initialize.apply(this, arguments),
|
||||||
height = this.get('height'), width = this.get('width'),
|
height = this.get('height'), width = this.get('width'),
|
||||||
save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this);
|
save = this.get('id') === 'controlbox' ? this.set.bind(this) : this.save.bind(this);
|
||||||
save({
|
save({
|
||||||
|
@ -81,11 +81,11 @@
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
var result = this._super.render.apply(this, arguments);
|
var result = this.__super__.render.apply(this, arguments);
|
||||||
this.setWidth();
|
this.setWidth();
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
_show: function () {
|
_show: function () {
|
||||||
this.initDragResize().setDimensions();
|
this.initDragResize().setDimensions();
|
||||||
this._super._show.apply(this, arguments);
|
this.__super__._show.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
initDragResize: function () {
|
initDragResize: function () {
|
||||||
|
@ -230,17 +230,17 @@
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
renderLoginPanel: function () {
|
renderLoginPanel: function () {
|
||||||
var result = this._super.renderLoginPanel.apply(this, arguments);
|
var result = this.__super__.renderLoginPanel.apply(this, arguments);
|
||||||
this.initDragResize().setDimensions();
|
this.initDragResize().setDimensions();
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
renderContactsPanel: function () {
|
renderContactsPanel: function () {
|
||||||
var result = this._super.renderContactsPanel.apply(this, arguments);
|
var result = this.__super__.renderContactsPanel.apply(this, arguments);
|
||||||
this.initDragResize().setDimensions();
|
this.initDragResize().setDimensions();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -255,11 +255,11 @@
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
$(window).on('resize', _.debounce(this.setDimensions.bind(this), 100));
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
var result = this._super.render.apply(this, arguments);
|
var result = this.__super__.render.apply(this, arguments);
|
||||||
this.setWidth();
|
this.setWidth();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
this.add(item.get('id'), view);
|
this.add(item.get('id'), view);
|
||||||
return view;
|
return view;
|
||||||
} else {
|
} else {
|
||||||
return this._super.onChatBoxAdded.apply(this, arguments);
|
return this.__super__.onChatBoxAdded.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,13 @@
|
||||||
Features: {
|
Features: {
|
||||||
addClientFeatures: function () {
|
addClientFeatures: function () {
|
||||||
converse.connection.disco.addFeature(Strophe.NS.MAM);
|
converse.connection.disco.addFeature(Strophe.NS.MAM);
|
||||||
return this._super.addClientFeatures.apply(this, arguments);
|
return this.__super__.addClientFeatures.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ChatBox: {
|
ChatBox: {
|
||||||
getMessageAttributes: function ($message, $delay, original_stanza) {
|
getMessageAttributes: function ($message, $delay, original_stanza) {
|
||||||
var attrs = this._super.getMessageAttributes.apply(this, arguments);
|
var attrs = this.__super__.getMessageAttributes.apply(this, arguments);
|
||||||
attrs.archive_id = $(original_stanza).find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id');
|
attrs.archive_id = $(original_stanza).find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id');
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
ChatBoxView: {
|
ChatBoxView: {
|
||||||
render: function () {
|
render: function () {
|
||||||
var result = this._super.render.apply(this, arguments);
|
var result = this.__super__.render.apply(this, arguments);
|
||||||
if (!this.disable_mam) {
|
if (!this.disable_mam) {
|
||||||
this.$content.on('scroll', _.debounce(this.onScroll.bind(this), 100));
|
this.$content.on('scroll', _.debounce(this.onScroll.bind(this), 100));
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
afterMessagesFetched: function () {
|
afterMessagesFetched: function () {
|
||||||
if (this.disable_mam || !converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
if (this.disable_mam || !converse.features.findWhere({'var': Strophe.NS.MAM})) {
|
||||||
return this._super.afterMessagesFetched.apply(this, arguments);
|
return this.__super__.afterMessagesFetched.apply(this, arguments);
|
||||||
}
|
}
|
||||||
if (this.model.messages.length < converse.archived_messages_page_size) {
|
if (this.model.messages.length < converse.archived_messages_page_size) {
|
||||||
this.fetchArchivedMessages({
|
this.fetchArchivedMessages({
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
'max': converse.archived_messages_page_size
|
'max': converse.archived_messages_page_size
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this._super.afterMessagesFetched.apply(this, arguments);
|
return this.__super__.afterMessagesFetched.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchArchivedMessages: function (options) {
|
fetchArchivedMessages: function (options) {
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
ChatRoomView: {
|
ChatRoomView: {
|
||||||
render: function () {
|
render: function () {
|
||||||
var result = this._super.render.apply(this, arguments);
|
var result = this.__super__.render.apply(this, arguments);
|
||||||
if (!this.disable_mam) {
|
if (!this.disable_mam) {
|
||||||
this.$content.on('scroll', _.debounce(this.onScroll.bind(this), 100));
|
this.$content.on('scroll', _.debounce(this.onScroll.bind(this), 100));
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
// New functions which don't exist yet can also be added.
|
// New functions which don't exist yet can also be added.
|
||||||
|
|
||||||
_initialize: function () {
|
_initialize: function () {
|
||||||
this._super._initialize.apply(this, arguments);
|
this.__super__._initialize.apply(this, arguments);
|
||||||
converse.minimized_chats = new converse.MinimizedChats({
|
converse.minimized_chats = new converse.MinimizedChats({
|
||||||
model: converse.chatboxes
|
model: converse.chatboxes
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
converse.chatboxviews.trimChats();
|
converse.chatboxviews.trimChats();
|
||||||
}
|
}
|
||||||
}, 200));
|
}, 200));
|
||||||
return this._super.registerGlobalEventHandlers.apply(this, arguments);
|
return this.__super__.registerGlobalEventHandlers.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
wrappedChatBox: function (chatbox) {
|
wrappedChatBox: function (chatbox) {
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
* returned via the API.
|
* returned via the API.
|
||||||
*/
|
*/
|
||||||
if (!chatbox) { return; }
|
if (!chatbox) { return; }
|
||||||
var box = this._super.wrappedChatBox.apply(this, arguments);
|
var box = this.__super__.wrappedChatBox.apply(this, arguments);
|
||||||
box.maximize = chatbox.maximize.bind(chatbox);
|
box.maximize = chatbox.maximize.bind(chatbox);
|
||||||
box.minimize = chatbox.minimize.bind(chatbox);
|
box.minimize = chatbox.minimize.bind(chatbox);
|
||||||
return box;
|
return box;
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
ChatBox: {
|
ChatBox: {
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
if (this.get('id') === 'controlbox') {
|
if (this.get('id') === 'controlbox') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,11 @@
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.model.on('change:minimized', this.onMinimizedChanged, this);
|
this.model.on('change:minimized', this.onMinimizedChanged, this);
|
||||||
return this._super.initialize.apply(this, arguments);
|
return this.__super__.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
afterShown: function () {
|
afterShown: function () {
|
||||||
this._super.afterShown.apply(this, arguments);
|
this.__super__.afterShown.apply(this, arguments);
|
||||||
if (!this.model.get('minimized')) {
|
if (!this.model.get('minimized')) {
|
||||||
converse.chatboxviews.trimChats(this);
|
converse.chatboxviews.trimChats(this);
|
||||||
}
|
}
|
||||||
|
@ -106,18 +106,18 @@
|
||||||
|
|
||||||
shouldShowOnTextMessage: function () {
|
shouldShowOnTextMessage: function () {
|
||||||
return !this.model.get('minimized') &&
|
return !this.model.get('minimized') &&
|
||||||
this._super.shouldShowOnTextMessage.apply(this, arguments);
|
this.__super__.shouldShowOnTextMessage.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
setChatBoxHeight: function (height) {
|
setChatBoxHeight: function (height) {
|
||||||
if (!this.model.get('minimized')) {
|
if (!this.model.get('minimized')) {
|
||||||
return this._super.setChatBoxHeight.apply(this, arguments);
|
return this.__super__.setChatBoxHeight.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setChatBoxWidth: function (width) {
|
setChatBoxWidth: function (width) {
|
||||||
if (!this.model.get('minimized')) {
|
if (!this.model.get('minimized')) {
|
||||||
return this._super.setChatBoxWidth.apply(this, arguments);
|
return this.__super__.setChatBoxWidth.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
this.maximize();
|
this.maximize();
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
var result = this._super.initialize.apply(this, arguments);
|
var result = this.__super__.initialize.apply(this, arguments);
|
||||||
if (this.model.get('minimized')) {
|
if (this.model.get('minimized')) {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
|
|
||||||
ChatBoxes: {
|
ChatBoxes: {
|
||||||
chatBoxMayBeShown: function (chatbox) {
|
chatBoxMayBeShown: function (chatbox) {
|
||||||
return this._super.chatBoxMayBeShown.apply(this, arguments) &&
|
return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
|
||||||
!chatbox.get('minimized');
|
!chatbox.get('minimized');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
showChat: function (attrs) {
|
showChat: function (attrs) {
|
||||||
/* Find the chat box and show it. If it doesn't exist, create it.
|
/* Find the chat box and show it. If it doesn't exist, create it.
|
||||||
*/
|
*/
|
||||||
var chatbox = this._super.showChat.apply(this, arguments);
|
var chatbox = this.__super__.showChat.apply(this, arguments);
|
||||||
if (chatbox.get('minimized')) {
|
if (chatbox.get('minimized')) {
|
||||||
chatbox.maximize();
|
chatbox.maximize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,14 +66,14 @@
|
||||||
*/
|
*/
|
||||||
if (!chatbox) { return; }
|
if (!chatbox) { return; }
|
||||||
var view = converse.chatboxviews.get(chatbox.get('id'));
|
var view = converse.chatboxviews.get(chatbox.get('id'));
|
||||||
var box = this._super.wrappedChatBox.apply(this, arguments);
|
var box = this.__super__.wrappedChatBox.apply(this, arguments);
|
||||||
box.is_chatroom = view.is_chatroom;
|
box.is_chatroom = view.is_chatroom;
|
||||||
return box;
|
return box;
|
||||||
},
|
},
|
||||||
|
|
||||||
Features: {
|
Features: {
|
||||||
addClientFeatures: function () {
|
addClientFeatures: function () {
|
||||||
this._super.addClientFeatures.apply(this, arguments);
|
this.__super__.addClientFeatures.apply(this, arguments);
|
||||||
if (converse.allow_muc_invitations) {
|
if (converse.allow_muc_invitations) {
|
||||||
converse.connection.disco.addFeature('jabber:x:conference'); // Invites
|
converse.connection.disco.addFeature('jabber:x:conference'); // Invites
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,8 @@
|
||||||
|
|
||||||
ControlBoxView: {
|
ControlBoxView: {
|
||||||
renderContactsPanel: function () {
|
renderContactsPanel: function () {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
this._super.renderContactsPanel.apply(this, arguments);
|
this.__super__.renderContactsPanel.apply(this, arguments);
|
||||||
if (converse.allow_muc) {
|
if (converse.allow_muc) {
|
||||||
this.roomspanel = new converse.RoomsPanel({
|
this.roomspanel = new converse.RoomsPanel({
|
||||||
'$parent': this.$el.find('.controlbox-panes'),
|
'$parent': this.$el.find('.controlbox-panes'),
|
||||||
|
@ -108,8 +108,8 @@
|
||||||
onConnected: function () {
|
onConnected: function () {
|
||||||
// TODO: This can probably be refactored to be an event
|
// TODO: This can probably be refactored to be an event
|
||||||
// handler (and therefore removed from overrides)
|
// handler (and therefore removed from overrides)
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
this._super.onConnected.apply(this, arguments);
|
this.__super__.onConnected.apply(this, arguments);
|
||||||
|
|
||||||
if (this.model.get('connected')) {
|
if (this.model.get('connected')) {
|
||||||
converse.features.off('add', this.featureAdded, this);
|
converse.features.off('add', this.featureAdded, this);
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
featureAdded: function (feature) {
|
featureAdded: function (feature) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
if ((feature.get('var') === Strophe.NS.MUC) && (converse.allow_muc)) {
|
if ((feature.get('var') === Strophe.NS.MUC) && (converse.allow_muc)) {
|
||||||
this.roomspanel.model.save({muc_domain: feature.get('from')});
|
this.roomspanel.model.save({muc_domain: feature.get('from')});
|
||||||
var $server= this.$el.find('input.new-chatroom-server');
|
var $server= this.$el.find('input.new-chatroom-server');
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
view = new converse.ChatRoomView({'model': item});
|
view = new converse.ChatRoomView({'model': item});
|
||||||
return this.add(item.get('id'), view);
|
return this.add(item.get('id'), view);
|
||||||
} else {
|
} else {
|
||||||
return this._super.onChatBoxAdded.apply(this, arguments);
|
return this.__super__.onChatBoxAdded.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,12 +60,12 @@
|
||||||
// New functions which don't exist yet can also be added.
|
// New functions which don't exist yet can also be added.
|
||||||
|
|
||||||
_initialize: function () {
|
_initialize: function () {
|
||||||
this._super._initialize.apply(this, arguments);
|
this.__super__._initialize.apply(this, arguments);
|
||||||
this.otr = new this.OTR();
|
this.otr = new this.OTR();
|
||||||
},
|
},
|
||||||
|
|
||||||
registerGlobalEventHandlers: function () {
|
registerGlobalEventHandlers: function () {
|
||||||
this._super.registerGlobalEventHandlers();
|
this.__super__.registerGlobalEventHandlers();
|
||||||
|
|
||||||
$(document).click(function () {
|
$(document).click(function () {
|
||||||
if ($('.toggle-otr ul').is(':visible')) {
|
if ($('.toggle-otr ul').is(':visible')) {
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
wrappedChatBox: function (chatbox) {
|
wrappedChatBox: function (chatbox) {
|
||||||
var wrapped_chatbox = this._super.wrappedChatBox.apply(this, arguments);
|
var wrapped_chatbox = this.__super__.wrappedChatBox.apply(this, arguments);
|
||||||
if (!chatbox) { return; }
|
if (!chatbox) { return; }
|
||||||
return _.extend(wrapped_chatbox, {
|
return _.extend(wrapped_chatbox, {
|
||||||
'endOTR': chatbox.endOTR.bind(chatbox),
|
'endOTR': chatbox.endOTR.bind(chatbox),
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
ChatBox: {
|
ChatBox: {
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
if (this.get('box_id') !== 'controlbox') {
|
if (this.get('box_id') !== 'controlbox') {
|
||||||
this.save({
|
this.save({
|
||||||
'otr_status': this.get('otr_status') || UNENCRYPTED
|
'otr_status': this.get('otr_status') || UNENCRYPTED
|
||||||
|
@ -102,17 +102,17 @@
|
||||||
* OTR session is still being established, so there are no
|
* OTR session is still being established, so there are no
|
||||||
* "visible" OTR messages being exchanged.
|
* "visible" OTR messages being exchanged.
|
||||||
*/
|
*/
|
||||||
return this._super.shouldPlayNotification.apply(this, arguments) &&
|
return this.__super__.shouldPlayNotification.apply(this, arguments) &&
|
||||||
!(utils.isOTRMessage($message[0]) && !_.contains([UNVERIFIED, VERIFIED], this.get('otr_status')));
|
!(utils.isOTRMessage($message[0]) && !_.contains([UNVERIFIED, VERIFIED], this.get('otr_status')));
|
||||||
},
|
},
|
||||||
|
|
||||||
createMessage: function ($message, $delay, original_stanza) {
|
createMessage: function ($message, $delay, original_stanza) {
|
||||||
var converse = this._super.converse,
|
var converse = this.__super__.converse,
|
||||||
$body = $message.children('body'),
|
$body = $message.children('body'),
|
||||||
text = ($body.length > 0 ? $body.text() : undefined);
|
text = ($body.length > 0 ? $body.text() : undefined);
|
||||||
|
|
||||||
if ((!text) || (!converse.allow_otr)) {
|
if ((!text) || (!converse.allow_otr)) {
|
||||||
return this._super.createMessage.apply(this, arguments);
|
return this.__super__.createMessage.apply(this, arguments);
|
||||||
}
|
}
|
||||||
if (text.match(/^\?OTRv23?/)) {
|
if (text.match(/^\?OTRv23?/)) {
|
||||||
this.initiateOTR(text);
|
this.initiateOTR(text);
|
||||||
|
@ -128,14 +128,14 @@
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Normal unencrypted message.
|
// Normal unencrypted message.
|
||||||
return this._super.createMessage.apply(this, arguments);
|
return this.__super__.createMessage.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getSession: function (callback) {
|
getSession: function (callback) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
var cipher = CryptoJS.lib.PasswordBasedCipher;
|
var cipher = CryptoJS.lib.PasswordBasedCipher;
|
||||||
var pass, instance_tag, saved_key, pass_check;
|
var pass, instance_tag, saved_key, pass_check;
|
||||||
if (converse.cache_otr_key) {
|
if (converse.cache_otr_key) {
|
||||||
|
@ -226,7 +226,7 @@
|
||||||
// send the query message to them.
|
// send the query message to them.
|
||||||
this.save({'otr_status': UNENCRYPTED});
|
this.save({'otr_status': UNENCRYPTED});
|
||||||
this.getSession(function (session) {
|
this.getSession(function (session) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
this.otr = new otr.OTR({
|
this.otr = new otr.OTR({
|
||||||
fragment_size: 140,
|
fragment_size: 140,
|
||||||
send_interval: 200,
|
send_interval: 200,
|
||||||
|
@ -273,8 +273,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
this._super.initialize.apply(this, arguments);
|
this.__super__.initialize.apply(this, arguments);
|
||||||
this.model.on('change:otr_status', this.onOTRStatusChanged, this);
|
this.model.on('change:otr_status', this.onOTRStatusChanged, this);
|
||||||
this.model.on('showOTRError', this.showOTRError, this);
|
this.model.on('showOTRError', this.showOTRError, this);
|
||||||
this.model.on('showSentOTRMessage', function (text) {
|
this.model.on('showSentOTRMessage', function (text) {
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
createMessageStanza: function () {
|
createMessageStanza: function () {
|
||||||
var stanza = this._super.createMessageStanza.apply(this, arguments);
|
var stanza = this.__super__.createMessageStanza.apply(this, arguments);
|
||||||
if (this.model.get('otr_status') !== UNENCRYPTED || utils.isOTRMessage(stanza.nodeTree)) {
|
if (this.model.get('otr_status') !== UNENCRYPTED || utils.isOTRMessage(stanza.nodeTree)) {
|
||||||
// OTR messages aren't carbon copied
|
// OTR messages aren't carbon copied
|
||||||
stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up()
|
stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up()
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
onMessageSubmitted: function (text) {
|
onMessageSubmitted: function (text) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
if (!converse.connection.authenticated) {
|
if (!converse.connection.authenticated) {
|
||||||
return this.showHelpMessages(
|
return this.showHelpMessages(
|
||||||
['Sorry, the connection has been lost, '+
|
['Sorry, the connection has been lost, '+
|
||||||
|
@ -322,7 +322,7 @@
|
||||||
this.model.otr.sendMsg(text);
|
this.model.otr.sendMsg(text);
|
||||||
this.model.trigger('showSentOTRMessage', text);
|
this.model.trigger('showSentOTRMessage', text);
|
||||||
} else {
|
} else {
|
||||||
this._super.onMessageSubmitted.apply(this, arguments);
|
this.__super__.onMessageSubmitted.apply(this, arguments);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
showOTRError: function (msg) {
|
showOTRError: function (msg) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
if (msg === 'Message cannot be sent at this time.') {
|
if (msg === 'Message cannot be sent at this time.') {
|
||||||
this.showHelpMessages(
|
this.showHelpMessages(
|
||||||
[__('Your message could not be sent')], 'error');
|
[__('Your message could not be sent')], 'error');
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
authOTR: function (ev) {
|
authOTR: function (ev) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
var scheme = $(ev.target).data().scheme;
|
var scheme = $(ev.target).data().scheme;
|
||||||
var result, question, answer;
|
var result, question, answer;
|
||||||
if (scheme === 'fingerprint') {
|
if (scheme === 'fingerprint') {
|
||||||
|
@ -425,7 +425,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
renderToolbar: function (options) {
|
renderToolbar: function (options) {
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
if (!converse.show_toolbar) {
|
if (!converse.show_toolbar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@
|
||||||
otr_tooltip: this.getOTRTooltip(),
|
otr_tooltip: this.getOTRTooltip(),
|
||||||
otr_translated_status: OTR_TRANSLATED_MAPPING[data.otr_status],
|
otr_translated_status: OTR_TRANSLATED_MAPPING[data.otr_status],
|
||||||
});
|
});
|
||||||
this._super.renderToolbar.call(this, options);
|
this.__super__.renderToolbar.call(this, options);
|
||||||
this.$el.find('.chat-toolbar').append(
|
this.$el.find('.chat-toolbar').append(
|
||||||
converse.templates.toolbar_otr(
|
converse.templates.toolbar_otr(
|
||||||
_.extend(this.model.toJSON(), options || {})
|
_.extend(this.model.toJSON(), options || {})
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
/* Also render a registration panel, when rendering the
|
/* Also render a registration panel, when rendering the
|
||||||
* login panel.
|
* login panel.
|
||||||
*/
|
*/
|
||||||
this._super.renderLoginPanel.apply(this, arguments);
|
this.__super__.renderLoginPanel.apply(this, arguments);
|
||||||
var converse = this._super.converse;
|
var converse = this.__super__.converse;
|
||||||
if (converse.allow_registration) {
|
if (converse.allow_registration) {
|
||||||
this.registerpanel = new converse.RegisterPanel({
|
this.registerpanel = new converse.RegisterPanel({
|
||||||
'$parent': this.$el.find('.controlbox-panes'),
|
'$parent': this.$el.find('.controlbox-panes'),
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
// New functions which don't exist yet can also be added.
|
// New functions which don't exist yet can also be added.
|
||||||
afterReconnected: function () {
|
afterReconnected: function () {
|
||||||
this.rosterview.registerRosterXHandler();
|
this.rosterview.registerRosterXHandler();
|
||||||
this._super.afterReconnected.apply(this, arguments);
|
this.__super__.afterReconnected.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
RosterGroups: {
|
RosterGroups: {
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
label_state: __('State'),
|
label_state: __('State'),
|
||||||
label_any: __('Any'),
|
label_any: __('Any'),
|
||||||
label_online: __('Online'),
|
label_online: __('Online'),
|
||||||
label_chatty: __('Chat'),
|
label_chatty: __('Chatty'),
|
||||||
label_busy: __('Busy'),
|
label_busy: __('Busy'),
|
||||||
label_away: __('Away'),
|
label_away: __('Away'),
|
||||||
label_xa: __('Extended Away'),
|
label_xa: __('Extended Away'),
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
Features: {
|
Features: {
|
||||||
addClientFeatures: function () {
|
addClientFeatures: function () {
|
||||||
this._super.addClientFeatures.apply(this, arguments);
|
this.__super__.addClientFeatures.apply(this, arguments);
|
||||||
if (converse.use_vcards) {
|
if (converse.use_vcards) {
|
||||||
converse.connection.disco.addFeature(Strophe.NS.VCARD);
|
converse.connection.disco.addFeature(Strophe.NS.VCARD);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user