General clean up. Work on using iframes and setting the height correctly.
This commit is contained in:
@@ -1,15 +1,90 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').LayoutData} */
|
||||
export let data: any;
|
||||
import { browser } from '$app/environment';
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
let log_lvl = 0;
|
||||
|
||||
$ae_loc.url_origin = data.url.origin;
|
||||
$ae_loc.params = data.params;
|
||||
console.log(`+layout.svelte data:`, data);
|
||||
|
||||
|
||||
|
||||
let iframe = data.url.searchParams.get('iframe');
|
||||
if (browser && iframe == 'true') {
|
||||
console.log('Use iframe layout!');
|
||||
// data_struct['iframe'] = iframe;
|
||||
$ae_loc.iframe = true;
|
||||
|
||||
document.getElementsByTagName('html')[0].classList.add('iframe');
|
||||
// document.getElementsByTagName('html')[0].classList.remove('dark');
|
||||
// document.getElementsByTagName('html')[0].classList.remove('light');
|
||||
|
||||
// $ae_loc.hub.show_element__access_type = false;
|
||||
// $ae_loc.hub.show_element__cfg = false;
|
||||
} else if (browser && iframe == 'false') {
|
||||
// data_struct['iframe'] = false;
|
||||
$ae_loc.iframe = false;
|
||||
|
||||
document.getElementsByTagName('html')[0].classList.remove('iframe');
|
||||
// document.getElementsByTagName('html')[0].classList.add('light');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$: if ($ae_loc.iframe_height && $ae_loc.iframe_height_modal_body) {
|
||||
console.log('getting new dimensions for iframe:', $ae_loc.iframe_height, $ae_loc.iframe_height_modal_body);
|
||||
|
||||
let iframe_height = 0;
|
||||
|
||||
if ($ae_loc.iframe_height > $ae_loc.iframe_height_modal_body) {
|
||||
iframe_height = $ae_loc.iframe_height;
|
||||
} else {
|
||||
iframe_height = $ae_loc.iframe_height_modal_body;
|
||||
|
||||
// console.log($ae_loc.modal_dimensions);
|
||||
|
||||
if ($ae_loc.modal_dimensions && $ae_loc.modal_dimensions.header_height) {
|
||||
iframe_height = iframe_height + $ae_loc.modal_dimensions.header_height;
|
||||
}
|
||||
if ($ae_loc.modal_dimensions && $ae_loc.modal_dimensions.footer_height) {
|
||||
iframe_height = iframe_height + $ae_loc.modal_dimensions.footer_height;
|
||||
}
|
||||
// iframe_height = iframe_height + 50; // Just in case
|
||||
}
|
||||
|
||||
console.log(`Suggested new iframe_height: ${iframe_height}`);
|
||||
window.parent.postMessage({'iframe_height': iframe_height}, "*"); // This should be in pixels
|
||||
} else if ($ae_loc.iframe_height) {
|
||||
console.log('setting new iframe_height:', $ae_loc.iframe_height);
|
||||
|
||||
// let iframe_height = $ae_loc.iframe_height;
|
||||
|
||||
window.parent.postMessage({'iframe_height': $ae_loc.iframe_height}, "*"); // This should be in pixels
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<svelte:head>
|
||||
<title>{$ae_loc.title ?? 'Æ loading...'}</title>
|
||||
{#if $ae_loc.iframe}
|
||||
<!-- <meta name="robots" content="noindex, nofollow" /> -->
|
||||
<link href="https://assets-staging.noviams.com/novi-core-assets/css/fontawesome.css" rel="stylesheet" />
|
||||
<link href="https://assets-staging.noviams.com/novi-core-assets/css/c/idaa/idaa.css" rel="stylesheet" />
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
|
||||
{#if ($ae_loc.trusted_access)}
|
||||
<slot />
|
||||
<div
|
||||
bind:clientHeight={$ae_loc.iframe_height}
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="container flex flex-col gap-1 w-full items-center justify-center font-bold p-8 m-8">
|
||||
<h1>
|
||||
|
||||
Reference in New Issue
Block a user