ILIAS  release_8 Revision v8.23
with_long_description.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 function with_long_description(): 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  )->withDescription(
17  'This is an example description which is very long to provide a representative view of the object when it has ' .
18  'to occupy enough space to show a very long toast. This may not be the favorable way of displaying a toast, ' .
19  'since toast are assumed to be readable in a short time due to the temporary visibility, therefore they only ' .
20  'should contain short description which can be read withing seconds. But even if this long description softly ' .
21  'violates the concepts of toast itself due to its long character it still provides a good view on the ' .
22  'scalability of the object and could therefore be called to proof its responsivity which confirms its benefit ' .
23  'as an example in spite of its unnatural form and missing usecase for productive systems'
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 }
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23