ILIAS  release_8 Revision v8.24
with_multiple_toasts.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
7function with_multiple_toasts(): string
8{
9 global $DIC;
10 $tc = $DIC->ui()->factory()->toast()->container();
11
12 $toasts = [
13 $DIC->ui()->factory()->toast()->standard(
14 'Example 1',
15 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
16 ),
17 $DIC->ui()->factory()->toast()->standard(
18 'Example 2',
19 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
20 ),
21 $DIC->ui()->factory()->toast()->standard(
22 'Example 3',
23 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
24 )
25 ];
26
27 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
28 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
29 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
30 return "$id.addEventListener('click', () => {
31 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
32 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
33 let newScript = document.createElement('script');
34 newScript.innerHTML = element.innerHTML;
35 element.parentNode.appendChild(newScript);
36 })
37 });";
38 });
39
40 return $DIC->ui()->renderer()->render([$button,$tc]);
41}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
global $DIC
Definition: feed.php:28