feature - chat appended properly on page load

This commit is contained in:
Alexandre Bourlier 2018-08-01 09:46:45 +02:00
parent bbb8e0a24c
commit a7d8a91457
1 changed files with 14 additions and 0 deletions

View File

@ -48,6 +48,20 @@
></sib-chat>
<script>
// Move the chat singleton to the right view on "page load"
window.onload = function() {
if (window.location.pathname.indexOf("-chat") !== -1) {
var chatSingleton = document.querySelector("#chat-singleton");
var pathnameParts = window.location.pathname.split("/");
var viewName = pathnameParts[pathnameParts.length - 1];
var view = document.getElementById(viewName);
view.appendChild(chatSingleton);
chatSingleton.dataset.src = view.dataset.src;
}
}
// Move the chat singleton to the right view on "navigate"
window.addEventListener('navigate', event => {
var chatSingleton = document.querySelector("#chat-singleton");
var view = document.getElementById(event.detail.route);