ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\UI\examples\Popover\Standard Namespace Reference

Functions

 show_card_in_popover ()
 

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

 
 show_popover_with_async_loaded_content ()
 

description: > Example for rendering a standard popover with asynchronous loaded content. More...

 
 show_popover_with_different_positions ()
 

description: > Example for rendering a standard popover with different positions. More...

 
 show_popover_with_vertical_scrollbars ()
 

description: > Example for rendering a standard popover with vertical scrollbars. More...

 

Function Documentation

◆ show_card_in_popover()

ILIAS\UI\examples\Popover\Standard\show_card_in_popover ( )


description: > Example for rendering a standard popover.

expected output: > ILIAS shows a button titled "Show Card". A click onto the button opens a card popover.

The popover can be closed by clicking onto the ILIAS background outside of the popover.

Definition at line 34 of file show_card_in_popover.php.

References $DIC, and $renderer.

35 {
36  global $DIC;
37 
38  // This example shows how to render a card containing an image and a descriptive list inside a popover.
39  $factory = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41 
42  $image = $factory->image()->responsive("./assets/images/logo/HeaderIcon.svg", "Thumbnail Example");
43  $card = $factory->card()->standard("Title", $image)->withSections(array($factory->legacy()->content("Hello World, I'm a card")));
44  $popover = $factory->popover()->standard($card)->withTitle('Card');
45  $button = $factory->button()->standard('Show Card', '#')
46  ->withOnClick($popover->getShowSignal());
47 
48  return $renderer->render([$popover, $button]);
49 }
$renderer
global $DIC
Definition: shib_login.php:22

◆ show_popover_with_async_loaded_content()

ILIAS\UI\examples\Popover\Standard\show_popover_with_async_loaded_content ( )


description: > Example for rendering a standard popover with asynchronous loaded content.

expected output: > ILIAS shows a button titled "Show Popover". After the first click the text shows up with a short delay.

You can close the popover b clicking onto the ILIAS background outside of the popover.

Definition at line 33 of file show_popover_with_async_loaded_content.php.

References $_SERVER, $DIC, ILIAS\UI\examples\Layout\Page\Standard\$refinery, $renderer, ILIAS\UI\examples\Layout\Page\Standard\$request_wrapper, exit, and ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle().

34 {
35  global $DIC;
36  $factory = $DIC->ui()->factory();
37  $renderer = $DIC->ui()->renderer();
38  $refinery = $DIC->refinery();
39  $request_wrapper = $DIC->http()->wrapper()->query();
40 
41  if (
42  $request_wrapper->has('renderPopoverAsync') &&
43  $request_wrapper->retrieve('renderPopoverAsync', $refinery->kindlyTo()->bool())
44  ) {
45  // This is the ajax request to load the content of the popover. During the ajax request,
46  // a loading spinner is presented to the user. Check the code below on how to construct the popover,
47  // e.g. using Popover::withAsyncContentUrl().
48  $content = $factory->legacy()->content('This text is rendered async');
49  echo $renderer->render($content);
50  exit();
51  }
52 
53  $async_url = $_SERVER['REQUEST_URI'] . '&renderPopoverAsync=1';
54  $popover = $factory->popover()->standard($factory->legacy()->content(''))
55  ->withTitle('Popover')
56  ->withAsyncContentUrl($async_url);
57  $button = $factory->button()->standard('Show Popover', '#')
58  ->withOnClick($popover->getShowSignal());
59 
60  return $renderer->render([$popover, $button]);
61 }
$renderer
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:22
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ show_popover_with_different_positions()

ILIAS\UI\examples\Popover\Standard\show_popover_with_different_positions ( )


description: > Example for rendering a standard popover with different positions.

expected output: > In this example ILIAS shows depending on the screen size and scroll position the popover's text accordingly. ILIAS shows three different buttons. Click onto the button and check if the popover's behaviour aligns with the description in the first sentence of this example's expected output.

Please do some tests with different size and scroll positions on your browser window to see if the functions still work.

Definition at line 36 of file show_popover_with_different_positions.php.

References $DIC, and $renderer.

37 {
38  global $DIC;
39  $factory = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41 
42  $content = $factory->legacy()->content('The position of this popover is calculated automatically based on the available space. Note that the max width CSS setting is used here, as this text is quite long.');
43  $popover = $factory->popover()->standard($content);
44  $button = $factory->button()->standard('Auto Popover', '#')
45  ->withOnClick($popover->getShowSignal());
46 
47  $content = $factory->legacy()->content('The position of this popover is either on top or bottom of the triggerer, based on the available space');
48  $popover2 = $factory->popover()->standard($content)
49  ->withVerticalPosition();
50  $button2 = $factory->button()->standard('Vertical Popover', '#')
51  ->withOnClick($popover2->getShowSignal());
52 
53  $content = $factory->legacy()->content('The position of this popover is either on the left or right of the triggerer, based on the available space');
54  $popover3 = $factory->popover()->standard($content)
55  ->withHorizontalPosition();
56  $button3 = $factory->button()->standard('Horizontal Popover', '#')
57  ->withOnClick($popover3->getShowSignal());
58 
59  $buttons = implode(' ', [$renderer->render($button), $renderer->render($button2), $renderer->render($button3)]);
60 
61  return $buttons . $renderer->render([$popover, $popover2, $popover3]);
62 }
$renderer
global $DIC
Definition: shib_login.php:22

◆ show_popover_with_vertical_scrollbars()

ILIAS\UI\examples\Popover\Standard\show_popover_with_vertical_scrollbars ( )


description: > Example for rendering a standard popover with vertical scrollbars.

expected output: > ILIAS shows a button titled "Show me some Series". A click onto the button opens a popover with a longer list of TV-Series.

The list is too big for the popover, but you can scroll down.

Definition at line 34 of file show_popover_with_vertical_scrollbars.php.

References $DIC, $renderer, and ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle().

35 {
36  global $DIC;
37  $factory = $DIC->ui()->factory();
38  $renderer = $DIC->ui()->renderer();
39 
40  // Note: A list should be rendered with the listing popover, e.g. $factory->popover()->listing()
41  // However, at the moment there is no component present representing such list items, so this example
42  // also uses a standard popover.
43 
44  $series = [
45  'Breaking Bad',
46  'Big Bang Theory',
47  'Dexter',
48  'Better Call Saul',
49  'Narcos',
50  'Ray Donovan',
51  'Simpsons',
52  'South Park',
53  'Fargo',
54  'Bloodline',
55  'The Walking Dead',
56  'New Girl',
57  'Sons of Anarchy',
58  'How I Met Your Mother',
59  ];
60  $list = $renderer->render($factory->listing()->unordered($series));
61  // Note: The Popover does not restrict the height. It is the responsibility of the content component
62  // to define the max height and to display vertical scrollbars, if necessary.
63  // At the moment, the renderer of a component is not aware of the context it is rendering the component,
64  // e.g. inside a Popover.
65  // The inline code below simulates this behaviour. Here we want to reduce the
66  // height of the list to 200px and display vertical scrollbars, if needed.
67  $content = "<div style='max-height: 200px; overflow-y: auto; padding-right: 10px;'>{$list}</div>";
68 
69  $popover = $factory->popover()->standard($factory->legacy()->content($content))->withTitle('Series');
70  $button = $factory->button()->standard('Show me some Series', '#')
71  ->withOnClick($popover->getShowSignal());
72 
73  return $renderer->render([$popover, $button]);
74 }
$renderer
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function: