Skip to content

Commit

Permalink
MWPW-155694 Decorate chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon32 committed Aug 27, 2024
1 parent 97475e6 commit 81da7be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/dynamic-chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function decorateChatbot(chatbot) {
if (!chatbot || document.querySelector('.close-sticky-section')) return;

if (document.querySelector('.sticky-bottom')) {
chatbot.style.display = 'none';
document.addEventListener('milo:sticky:closed', () => {
chatbot.style.display = '';
});
}
}

export default function observeChatbot() {
const observer = new MutationObserver((mutationsList) => {
mutationsList.forEach((mutation) => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach((node) => {
if (node.id === 'hb_chatbot-root') {
decorateChatbot(node);
observer.disconnect();
}
});
}
});
});
observer.observe(document.body, { childList: true });
}
4 changes: 4 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ export const LIBS = setLibs(window.location);
const { default: registerAAUniversity } = await import('./aa-university.js');
window.addEventListener('mktoSubmit', registerAAUniversity);
}
if (document.querySelector('.sticky-bottom')) {
const { default: observeChatbot } = await import('./dynamic-chat.js');
observeChatbot();
}
if (document.querySelector('.faas')) {
loadStyle('/styles/faas.css');
}
Expand Down

0 comments on commit 81da7be

Please sign in to comment.