Commit 26c579e3 authored by Seve's avatar Seve Committed by JC Brand

Start with sending stanza with spoiler

parent a2b2291e
(function (root, factory) { (function (root, factory) {
define(["converse-core", "strophe.vcard"], factory); define(["converse-core", "strophe.vcard", "converse-chatview"], factory);
}(this, function (converse) { }(this, function (converse) {
// Commonly used utilities and variables can be found under the "env" // Commonly used utilities and variables can be found under the "env"
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
_ = converse.env._, _ = converse.env._,
moment = converse.env.moment; moment = converse.env.moment;
function isEditSpoilerMessage() {
return document.querySelector('.toggle-spoiler').getAttribute('active') === 'true';
}
// The following line registers your plugin. // The following line registers your plugin.
converse.plugins.add("converse-spoilers", { converse.plugins.add("converse-spoilers", {
...@@ -125,11 +128,7 @@ ...@@ -125,11 +128,7 @@
} }
} }
function isEditSpoilerMessage() {
return document.querySelector('.toggle-spoiler').getAttribute('active') === 'true';
}
function createHintTextArea(){ function createHintTextArea(){
let hintTextArea = document.createElement('input'); let hintTextArea = document.createElement('input');
hintTextArea.setAttribute('type', 'text'); hintTextArea.setAttribute('type', 'text');
...@@ -147,47 +146,19 @@ ...@@ -147,47 +146,19 @@
* the "overrides" namespace. * the "overrides" namespace.
*/ */
'overrides': { 'overrides': {
/* For example, the private *_converse* object has a 'ChatBoxView': {
* method "onConnected". You can override that method as follows: 'createMessageStanza': function () {
*/ debugger;
'onConnected': function () { let messageStanza = this.__super__.createMessageStanza.apply(this, arguments);
// Overrides the onConnected method in converse.js if (isEditSpoilerMessage()) {
messageStanza.c('spoiler',{'xmlns': 'urn:xmpp:spoiler:0'}, _('Spoiler')); //TODO Check for hint or send __('Spoiler');
// Top-level functions in "overrides" are bound to the }
// inner "_converse" object. alert(messageStanza);
var _converse = this; return messageStanza;
// Your custom code can come here ...
// You can access the original function being overridden
// via the __super__ attribute.
// Make sure to pass on the arguments supplied to this
// function and also to apply the proper "this" object.
_converse.__super__.onConnected.apply(this, arguments);
// Your custom code can come here ...
},
/* Override converse.js's XMPPStatus Backbone model so that we can override the
* function that sends out the presence stanza.
*/
'XMPPStatus': {
'sendPresence': function (type, status_message, jid) {
// The "_converse" object is available via the __super__
// attribute.
var _converse = this.__super__._converse;
// Custom code can come here ...
// You can call the original overridden method, by
// accessing it via the __super__ attribute.
// When calling it, you need to apply the proper
// context as reference by the "this" variable.
this.__super__.sendPresence.apply(this, arguments);
// Custom code can come here ...
} }
} }
} }
}); });
})); }));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment