frontend: Fix duplicate variable declarations in ResizeObserver scope
- Rename variables to avoid conflicts with existing declarations - Wrap ResizeObserver code in IIFE for local scope isolation - Fixes build error: 'editorPanel' and 'legendBtn' already declared Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
7e30a3217a
commit
1c92c66c18
+13
-11
@@ -1170,23 +1170,25 @@ function mountBuildBadge(){
|
|||||||
mountBuildBadge();
|
mountBuildBadge();
|
||||||
|
|
||||||
/* ---------- Editor-Panel: Copy & Agenda Buttons nur sichtbar wenn Panel offen genug ---------- */
|
/* ---------- Editor-Panel: Copy & Agenda Buttons nur sichtbar wenn Panel offen genug ---------- */
|
||||||
const editorPanel = document.querySelector('.panel.editor');
|
(function() {
|
||||||
const editorHead = editorPanel?.querySelector('.panel-head');
|
const editorPanelEl = document.querySelector('.panel.editor');
|
||||||
const editorBody = editorPanel?.querySelector('.editor-body');
|
const editorHeadEl = editorPanelEl?.querySelector('.panel-head');
|
||||||
const copyBtn = document.getElementById('copy');
|
const editorBodyEl = editorPanelEl?.querySelector('.editor-body');
|
||||||
const legendBtn = document.getElementById('legendBtn');
|
const copyBtnEl = document.getElementById('copy');
|
||||||
|
const legendBtnEl = document.getElementById('legendBtn');
|
||||||
|
|
||||||
if(editorBody && editorHead && copyBtn && legendBtn){
|
if(editorBodyEl && editorHeadEl && copyBtnEl && legendBtnEl){
|
||||||
const updateButtonVisibility = () => {
|
const updateButtonVisibility = () => {
|
||||||
const headHeight = editorHead.offsetHeight;
|
const headHeight = editorHeadEl.offsetHeight;
|
||||||
const bodyHeight = editorBody.offsetHeight;
|
const bodyHeight = editorBodyEl.offsetHeight;
|
||||||
/* Buttons nur sichtbar wenn mindestens Titelzeilenhöhe sichtbar ist */
|
/* Buttons nur sichtbar wenn mindestens Titelzeilenhöhe sichtbar ist */
|
||||||
const shouldShow = bodyHeight >= headHeight;
|
const shouldShow = bodyHeight >= headHeight;
|
||||||
copyBtn.style.display = shouldShow ? 'block' : 'none';
|
copyBtnEl.style.display = shouldShow ? 'block' : 'none';
|
||||||
legendBtn.style.display = shouldShow ? 'block' : 'none';
|
legendBtnEl.style.display = shouldShow ? 'block' : 'none';
|
||||||
};
|
};
|
||||||
|
|
||||||
const resizeObserver = new ResizeObserver(updateButtonVisibility);
|
const resizeObserver = new ResizeObserver(updateButtonVisibility);
|
||||||
resizeObserver.observe(editorBody);
|
resizeObserver.observe(editorBodyEl);
|
||||||
updateButtonVisibility(); /* Initial call */
|
updateButtonVisibility(); /* Initial call */
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user