Skip to content

Commit

Permalink
Display toolbox initialization only once
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Sep 12, 2023
1 parent ef2ec00 commit 8a451a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Classes/Controller/ToolboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ private function renderImageManipulationTool()

$this->view->assign('imageManipulation', true);
$this->view->assign('parentContainer', $parentContainer);
// activate it here as it is the most common used tool
$this->view->assign('activateToolbox', true);
}

/**
Expand Down
20 changes: 11 additions & 9 deletions Resources/Private/Templates/Toolbox/Main.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@
</f:if>
</ul>

<script>
window.addEventListener('tx-dlf-documentLoaded', (e) => {
// Avoid instantiating dlfToolbox multiple times;
// TODO(client-side): Rethink how it's done
if (!window.tx_dlf_toolbox) {
window.tx_dlf_toolbox = new dlfToolbox(e.detail.docController);
}
});
</script>
<f:if condition="{activateToolbox}">
<f:then>
<script>
window.addEventListener('tx-dlf-documentLoaded', (e) => {
if (!window.tx_dlf_toolbox) {
window.tx_dlf_toolbox = new dlfToolbox(e.detail.docController);
}
});
</script>
</f:then>
</f:if>

</html>

0 comments on commit 8a451a1

Please sign in to comment.