Skip to content

Commit 34becbf

Browse files
Kajetan Dvoracekbeatrycze-volk
authored andcommitted
Refactor: Extract dlfController::eventTarget
1 parent 6554159 commit 34becbf

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Resources/Private/JavaScript/DigitalcollectionsScripts.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,16 @@ $(function () {
226226
let docController = null;
227227
window.addEventListener('tx-dlf-documentLoaded', e => {
228228
docController = e.detail.docController;
229-
});
230229

231-
// Update URL in page grid button
232-
document.body.addEventListener('tx-dlf-stateChanged', e => {
233-
if (docController === null) {
234-
return;
235-
}
230+
// Update URL in page grid button
231+
docController.eventTarget.addEventListener('tx-dlf-stateChanged', e => {
232+
if (docController === null) {
233+
return;
234+
}
236235

237-
$('#digitalcollections-enable-grid-view')
238-
.attr('href', docController.makePageUrl(e.detail.page, true));
236+
$('#digitalcollections-enable-grid-view')
237+
.attr('href', docController.makePageUrl(e.detail.page, true));
238+
});
239239
});
240240
})();
241241

Resources/Private/Plugins/Kitodo/Templates/Toolbox/Main.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@
176176
</f:if>
177177

178178
<script>
179-
window.addEventListener('DOMContentLoaded', () => {
179+
window.addEventListener('tx-dlf-documentLoaded', (e) => {
180180
// Avoid instantiating dlfToolbox multiple times;
181181
// TODO: Rethink how it's done
182182
if (!window.tx_dlf_toolbox) {
183-
window.tx_dlf_toolbox = new dlfToolbox();
183+
window.tx_dlf_toolbox = new dlfToolbox(e.detail.docController);
184184
}
185185
});
186186
</script>

0 commit comments

Comments
 (0)