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