ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
with_long_description.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 function with_long_description(): string
34 {
35  global $DIC;
36  $tc = $DIC->ui()->factory()->toast()->container();
37 
38  $toasts = [
39  $DIC->ui()->factory()->toast()->standard(
40  'Example',
41  $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Test')
42  )->withDescription(
43  'This is an example description which is very long to provide a representative view of the object when it has ' .
44  'to occupy enough space to show a very long toast. This may not be the favorable way of displaying a toast, ' .
45  'since toast are assumed to be readable in a short time due to the temporary visibility, therefore they only ' .
46  'should contain short description which can be read within seconds. But even if this long description softly ' .
47  'violates the concepts of toast itself due to its long character it still provides a good view on the ' .
48  'scalability of the object and could therefore be called to proof its responsivity which confirms its benefit ' .
49  'as an example in spite of its unnatural form and missing usecase for productive systems'
50  )
51  ];
52 
53  $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
54  $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
55  $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
56  return "$id.addEventListener('click', () => {
57  $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
58  $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
59  let newScript = document.createElement('script');
60  newScript.innerHTML = element.innerHTML;
61  element.parentNode.appendChild(newScript);
62  })
63  });";
64  });
65 
66  return $DIC->ui()->renderer()->render([$button,$tc]);
67 }
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
with_long_description()
description: > Example for rendering a standard toast including a long description.