forked from unimatrix/web
fix: keep embedded boards height stable and deduplicate politics import
This commit is contained in:
parent
e83113ce04
commit
29087e1e7e
3 changed files with 3 additions and 4 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import {mountNativeService} from './cp-v2-native-services.mjs';
|
||||
import {mountNativeService} from './cp-v2-native-services.mjs';
|
||||
import {mountPolicyDecisions} from './cp-v2-politics-decisions.mjs';
|
||||
import {watchMenuHighlights} from './cp-v2-menu-highlights.mjs';
|
||||
import {startCPAuthentication} from './cp-v2-auth.mjs';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ if(is_file(MYBB_ROOT.'system-board-membership.php')){
|
|||
require_once MYBB_ROOT.'system-board-membership.php';
|
||||
require_once MYBB_ROOT.'system-board-policy.php';
|
||||
require_once MYBB_ROOT.'system-board-embed.php';
|
||||
$plugins->add_hook('pre_output_page','dune_system_board_embed');
|
||||
$plugins->add_hook('pre_output_page','dune_system_board_embed',20);
|
||||
}
|
||||
$plugins->add_hook('global_intermediate','dune_central_account_permissions');
|
||||
$plugins->add_hook('usercp_menu','dune_central_account_menu',1);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ function dune_system_board_embed(&$page): void {
|
|||
$href='/system-board-manage.php?kind='.rawurlencode($grant['kind']).'&organisation='.rawurlencode($grant['id']).'&dune_embed=1';
|
||||
$page=preg_replace('/(<body\b[^>]*>)/i','$1<div class="system-board-tools"><a href="'.$href.'">Manage board · Add forum or category</a></div>',$page,1);
|
||||
}
|
||||
$style = '<style>html,body{min-height:0!important}#header,#footer,.navigation,.breadcrumb,.dune-shared-header,.dune-shared-footer{display:none!important}#container,#content{width:auto!important;max-width:none!important;margin:0!important;padding:14px!important}.system-board-tools{margin:12px 0}</style>';
|
||||
$style = '<style>html,body{min-height:0!important;height:auto!important}#header,#footer,.navigation,.breadcrumb,.dune-shared-header,.dune-shared-footer{display:none!important}#container,#content{width:auto!important;max-width:none!important;margin:0!important;padding:14px!important}.system-board-tools{margin:12px 0}</style>';
|
||||
$script = <<<'JS'
|
||||
<script>(()=>{const parents=new Set(['https://cp.dunerealms.com','https://clans.dunerealms.com','https://corp.dunerealms.com','https://pol.dunerealms.com']);const send=()=>{const height=Math.ceil(document.documentElement.scrollHeight)+16;if(parent!==window&&height>=100&&height<=200000)for(const origin of parents)parent.postMessage({type:'dune-embed-size',height},origin);};for(const a of document.querySelectorAll('a[href]')){try{const u=new URL(a.href);if(u.origin===location.origin&&!u.pathname.startsWith('/admin/')&&!u.pathname.endsWith('dune-sso.php')){u.searchParams.set('dune_embed','1');a.href=u.href;}}catch{}}for(const f of document.forms){const input=document.createElement('input');input.type='hidden';input.name='dune_embed';input.value='1';f.append(input);try{const u=new URL(f.action);if(u.origin===location.origin){u.searchParams.set('dune_embed','1');f.action=u.href;}}catch{}}window.addEventListener('message',e=>{if(e.source===parent&&parents.has(e.origin)&&e.data?.type==='dune-embed-measure')send();});new ResizeObserver(send).observe(document.body);send();})();</script>
|
||||
<script>(()=>{const parents=new Set(['https://cp.dunerealms.com','https://clans.dunerealms.com','https://corp.dunerealms.com','https://pol.dunerealms.com']);const send=()=>{const height=Math.ceil(Math.max(document.body.scrollHeight,document.body.getBoundingClientRect().height))+16;if(parent!==window&&height>=100&&height<=200000)for(const origin of parents)parent.postMessage({type:'dune-embed-size',height},origin);};for(const a of document.querySelectorAll('a[href]')){try{const u=new URL(a.href);if(u.origin===location.origin&&!u.pathname.startsWith('/admin/')&&!u.pathname.endsWith('dune-sso.php')){u.searchParams.set('dune_embed','1');a.href=u.href;}}catch{}}for(const f of document.forms){const input=document.createElement('input');input.type='hidden';input.name='dune_embed';input.value='1';f.append(input);try{const u=new URL(f.action);if(u.origin===location.origin){u.searchParams.set('dune_embed','1');f.action=u.href;}}catch{}}window.addEventListener('message',e=>{if(e.source===parent&&parents.has(e.origin)&&e.data?.type==='dune-embed-measure')send();});new ResizeObserver(send).observe(document.body);send();})();</script>
|
||||
JS;
|
||||
$page = str_replace('</head>', $style.'</head>', $page);
|
||||
$page = str_replace('</body>', $script.'</body>', $page);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff