ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\UI\examples\Toast\Standard Namespace Reference

Functions

 base ()
 

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

 
 with_action ()
 

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

 
 with_additional_links ()
 

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

 
 with_description ()
 

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

 
 with_link_title ()
 

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

 
 with_long_description ()
 

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

 

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.

References $DIC, and $id.

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 }
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ 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.

References $DIC, $id, and ILIAS\GlobalScreen\Scope\Footer\Factory\withAction().

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 }
withAction(URI|Signal|string $action)
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ 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.

References $DIC, and $id.

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 }
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ 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.

References $DIC, and $id.

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 }
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ 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.

References $DIC, and $id.

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 }
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ 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.

References $DIC, and $id.

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 }
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23