ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\UI\examples\Toast\Container Namespace Reference

Functions

 base ()
 
 with_multiple_toasts ()
 
 with_toast ()
 

Function Documentation

◆ base()

ILIAS\UI\examples\Toast\Container\base ( )

description: > Example for rendering a toast container.

expected output: >

ILIAS shows a blue button wich will not activate any actions.

Definition at line 32 of file base.php.

32 : string
33{
34 global $DIC;
35 $tc = $DIC->ui()->factory()->toast()->container();
36
37 $toasts = [];
38
39 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
40 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
41 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
42 return "$id.addEventListener('click', () => {
43 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
44 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
45 let newScript = document.createElement('script');
46 newScript.innerHTML = element.innerHTML;
47 element.parentNode.appendChild(newScript);
48 })
49 });";
50 });
51
52 return $DIC->ui()->renderer()->render([$button,$tc]);
53}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
global $DIC
Definition: shib_login.php:26

References $DIC, and $id.

◆ with_multiple_toasts()

ILIAS\UI\examples\Toast\Container\with_multiple_toasts ( )

description: > Example for rendring a toast container with multiple toasts.

expected output: > ILIAS shows a blue button. Clicking that button opens three different messages in the right top edge which

disappear after a few seconds.

Definition at line 33 of file with_multiple_toasts.php.

33 : string
34{
35 global $DIC;
36 $tc = $DIC->ui()->factory()->toast()->container();
37
38 $toasts = [
39 $DIC->ui()->factory()->toast()->standard(
40 'Example 1',
41 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
42 ),
43 $DIC->ui()->factory()->toast()->standard(
44 'Example 2',
45 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
46 ),
47 $DIC->ui()->factory()->toast()->standard(
48 'Example 3',
49 $DIC->ui()->factory()->symbol()->icon()->standard('mail', 'Test')
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}

References $DIC, and $id.

◆ with_toast()

ILIAS\UI\examples\Toast\Container\with_toast ( )

expected output: > ILIAS shows a blue button. If you click said button a message "Example" appears in the right top edge which

disappears after a few seconds.

Definition at line 30 of file with_toast.php.

30 : string
31{
32 global $DIC;
33 $tc = $DIC->ui()->factory()->toast()->container();
34
35 $toasts = [
36 $DIC->ui()->factory()->toast()->standard(
37 'Example',
38 $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Test')
39 )
40 ];
41
42 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
43 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
44 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
45 return "$id.addEventListener('click', () => {
46 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
47 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
48 let newScript = document.createElement('script');
49 newScript.innerHTML = element.innerHTML;
50 element.parentNode.appendChild(newScript);
51 })
52 });";
53 });
54
55 return $DIC->ui()->renderer()->render([$button,$tc]);
56}

References $DIC, and $id.