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