Add new public API method converse.insertInto
This commit is contained in:
parent
9780024dc6
commit
cf258f0b4c
@ -43,6 +43,7 @@ Soon we'll deprecate the latter, so prepare now.
|
||||
- New config option [muc_hats_from_vcard](https://conversejs.org/docs/html/configuration.html#muc-hats-from-vcard).
|
||||
- New config option [muc_send_probes](https://conversejs.org/docs/html/configuration.html#muc-send-probes).
|
||||
- New config option [show_message_avatar](https://conversejs.org/docs/html/configuration.html#show-message-avatar).
|
||||
- New public API [converse.insertInto](https://conversejs.org/docs/html/api/converse.html#.insertInto)
|
||||
|
||||
## 6.0.0 (2020-01-09)
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -208,7 +208,7 @@ test:
|
||||
## Documentation
|
||||
|
||||
./bin/activate:
|
||||
python3.7 -m venv .
|
||||
python3 -m venv .
|
||||
|
||||
.installed.cfg: requirements.txt buildout.cfg
|
||||
./bin/pip install -r requirements.txt
|
||||
|
@ -154,5 +154,29 @@ converse.plugins.add('converse-chatboxviews', {
|
||||
api.listen.on('chatBoxViewsInitialized', () => calculateViewportHeightUnit());
|
||||
window.addEventListener('resize', () => calculateViewportHeightUnit());
|
||||
/************************ END Event Handlers ************************/
|
||||
|
||||
|
||||
Object.assign(converse, {
|
||||
/**
|
||||
* Public API method which will ensure that the #conversejs element
|
||||
* is inserted into a container element.
|
||||
*
|
||||
* This method is useful when the #conversejs element has been
|
||||
* detached from the DOM somehow.
|
||||
* @async
|
||||
* @memberOf converse
|
||||
* @method insertInto
|
||||
* @example
|
||||
* converse.insertInto(document.querySelector('#converse-container'));
|
||||
*/
|
||||
insertInto (container) {
|
||||
const el = _converse.chatboxviews?.el;
|
||||
if (el && !container.contains(el)) {
|
||||
container.insertAdjacentElement('afterBegin', el);
|
||||
} else if (!el) {
|
||||
throw new Error("Cannot insert non-existing #conversejs element into the DOM");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user