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

Functions

 base ()
 
 with_action ()
 
 with_additional_links ()
 
 with_description ()
 
 with_link_title ()
 
 with_long_description ()
 

Function Documentation

◆ base()

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

description: > Example for rendering a standard toast.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" on the right top edge which

disappears after a few seconds.

Definition at line 33 of file base.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',
41 $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Test')
42 )
43 ];
44
45 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
46 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
47 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
48 return "$id.addEventListener('click', () => {
49 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
50 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
51 let newScript = document.createElement('script');
52 newScript.innerHTML = element.innerHTML;
53 element.parentNode.appendChild(newScript);
54 })
55 });";
56 });
57
58 return $DIC->ui()->renderer()->render([$button,$tc]);
59}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
global $DIC
Definition: shib_login.php:26

References $DIC, and $id.

◆ with_action()

ILIAS\UI\examples\Toast\Standard\with_action ( )

description: > Example for rendering a standard toast with actions.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" on the right top edge which

disappears after a few seconds.

Definition at line 33 of file with_action.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',
41 $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Test')
42 )->withAction('https://www.ilias.de')
43 ];
44
45 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
46 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
47 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
48 return "$id.addEventListener('click', () => {
49 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
50 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
51 let newScript = document.createElement('script');
52 newScript.innerHTML = element.innerHTML;
53 element.parentNode.appendChild(newScript);
54 })
55 });";
56 });
57
58 return $DIC->ui()->renderer()->render([$button,$tc]);
59}

References $DIC, and $id.

◆ with_additional_links()

ILIAS\UI\examples\Toast\Standard\with_additional_links ( )

description: > Example for rendering a standard toast with additional links.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" on the right top edge including

two links which open a page each.

Definition at line 33 of file with_additional_links.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',
41 $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Example')
42 )
43 ->withAdditionalLink($DIC->ui()->factory()->link()->standard('ILIAS', 'https://www.ilias.de'))
44 ->withAdditionalLink($DIC->ui()->factory()->link()->standard('GitHub', 'https://www.github.com'))
45 ];
46
47 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
48 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
49 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
50 return "$id.addEventListener('click', () => {
51 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
52 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
53 let newScript = document.createElement('script');
54 newScript.innerHTML = element.innerHTML;
55 element.parentNode.appendChild(newScript);
56 })
57 });";
58 });
59
60 return $DIC->ui()->renderer()->render([$button,$tc]);
61}

References $DIC, and $id.

◆ with_description()

ILIAS\UI\examples\Toast\Standard\with_description ( )

description: > Example for rendering a standard toast including a description.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" including a description on the

right top edge and which disappears after a few seconds.

Definition at line 33 of file with_description.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',
41 $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Test')
42 )->withDescription('This is an example description.')
43 ];
44
45 $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
46 $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
47 $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
48 return "$id.addEventListener('click', () => {
49 $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
50 $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
51 let newScript = document.createElement('script');
52 newScript.innerHTML = element.innerHTML;
53 element.parentNode.appendChild(newScript);
54 })
55 });";
56 });
57
58 return $DIC->ui()->renderer()->render([$button,$tc]);
59}

References $DIC, and $id.

◆ with_link_title()

ILIAS\UI\examples\Toast\Standard\with_link_title ( )

description: > Example for rendering a standard toast with a link title.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" on the right top edge which

disappears after a few seconds. The message box's title is rendered as link.

Definition at line 33 of file with_link_title.php.

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

References $DIC, and $id.

◆ with_long_description()

ILIAS\UI\examples\Toast\Standard\with_long_description ( )

description: > Example for rendering a standard toast including a long description.

expected output: > ILIAS shows a blue button "Show". Clicking onto the button opens a message "Example" including a long description on

the right top edge which disappears after a few seconds.

Definition at line 33 of file with_long_description.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',
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}

References $DIC, and $id.