2024-05-23 09:42:14 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-08-01 15:01:09 +00:00
|
|
|
import type { InitConverseJSParams } from 'shared/lib/types'
|
2023-05-04 17:14:23 +00:00
|
|
|
|
2023-08-01 15:01:09 +00:00
|
|
|
function initDom ({ forceReadonly, transparent }: InitConverseJSParams, isInIframe: boolean): void {
|
2023-05-04 17:14:23 +00:00
|
|
|
const body = document.querySelector('body')
|
|
|
|
if (isInIframe) {
|
|
|
|
if (body) {
|
2024-03-28 14:06:15 +00:00
|
|
|
body.classList.add('livechat-iframe') // we need to keep this, for embedded chats in external websites
|
2023-05-04 17:14:23 +00:00
|
|
|
// prevent horizontal scrollbar when in iframe. (don't know why, but does not work if done by CSS)
|
|
|
|
body.style.overflowX = 'hidden'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (forceReadonly) {
|
|
|
|
body?.classList.add('livechat-readonly')
|
|
|
|
if (forceReadonly === 'noscroll') {
|
|
|
|
body?.classList.add('livechat-noscroll')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (transparent) {
|
|
|
|
body?.classList.add('livechat-transparent')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
initDom
|
|
|
|
}
|