From b6501bcf09fae00de46917b67a809334b7282dfa Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 15 Feb 2018 15:50:11 +0100 Subject: [PATCH] Render .row inside #conversejs element --- src/converse-chatboxes.js | 23 +++++++++++++++++++++-- src/templates/chatboxes.html | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/templates/chatboxes.html diff --git a/src/converse-chatboxes.js b/src/converse-chatboxes.js index 0ad031ca4..36da744a9 100644 --- a/src/converse-chatboxes.js +++ b/src/converse-chatboxes.js @@ -7,11 +7,17 @@ /*global define */ (function (root, factory) { - define(["converse-core", "backbone.overview"], factory); -}(this, function (converse) { + define([ + "converse-core", + "tpl!chatboxes", + "backbone.overview" + ], factory); +}(this, function (converse, tpl_chatboxes) { "use strict"; + const { Backbone, Promise, Strophe, b64_sha1, moment, utils, _ } = converse.env; + converse.plugins.add('converse-chatboxes', { overrides: { @@ -411,6 +417,12 @@ initialize () { this.model.on("add", this.onChatBoxAdded, this); this.model.on("destroy", this.removeChat, this); + this.render(); + }, + + render () { + this.el.innerHTML = tpl_chatboxes(); + this.row_el = this.el.querySelector('.row'); }, _ensureElement () { @@ -440,6 +452,13 @@ } }, + insertRowColumn (el) { + /* Add a new DOM element (likely a chat box) into the + * the row managed by this overview. + */ + this.row_el.insertAdjacentElement('afterBegin', el); + }, + onChatBoxAdded (item) { // Views aren't created here, since the core code doesn't // contain any views. Instead, they're created in overrides in diff --git a/src/templates/chatboxes.html b/src/templates/chatboxes.html new file mode 100644 index 000000000..efd74b4b0 --- /dev/null +++ b/src/templates/chatboxes.html @@ -0,0 +1 @@ +