ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\UI\examples\Button\Toggle Namespace Reference

Functions

 base ()
 

description: > Example for rendering a Toggle Button. More...

 
 unavailable_action ()
 

description: > This example provides the given button with an unavailable action. More...

 
 with_tooltip ()
 

description: > Example for rendering a Toggle Button with tooltips More...

 

Function Documentation

◆ base()

ILIAS\UI\examples\Button\Toggle\base ( )


description: > Example for rendering a Toggle Button.

expected output: > ILIAS shows a switch. Clicking onto the switch will result in the switch moving to the right side and opening a dialog: "Toggle Button has been turned on". Closing the dialog via "delete" will move back the switch. The switch will stay on the right side if the dialog is closed via "close".

Another click onto the switch will move the switch to the left side. ILIAS notifies: "Toggle Button has been turned off".

Definition at line 36 of file base.php.

References $DIC, and $renderer.

37 {
38  global $DIC;
39  $factory = $DIC->ui()->factory();
40  $renderer = $DIC->ui()->renderer();
41 
42  $message1 = 'Toggle Button has been turned on';
43  $message2 = 'Toggle Button has been turned off';
44  $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
45 
46  $modal = $factory->modal()->interruptive('ON', $message1, $form_action);
47  $modal2 = $factory->modal()->interruptive('OFF', $message2, $form_action);
48 
49  //Note, important do not miss to set a proper aria-label (see rules above).
50  //Note that aria-pressed is taken care off by the default implementation.
51  $button = $factory->button()->toggle("", $modal->getShowSignal(), $modal2->getShowSignal())
52  ->withAriaLabel("Switch the State of XY");
53 
54  return $renderer->render([$button, $modal, $modal2]);
55 }
$renderer
global $DIC
Definition: shib_login.php:22

◆ unavailable_action()

ILIAS\UI\examples\Button\Toggle\unavailable_action ( )


description: > This example provides the given button with an unavailable action.

Note that the disabled attribute is set in the DOM. No action must be fired, even if done by keyboard.

expected output: >

ILIAS shows a greyed out switch. Clicking onto the switch won't activate any actions.

Definition at line 34 of file unavailable_action.php.

References $DIC, Vendor\Package\$f, and $renderer.

35 {
36  global $DIC;
37  $f = $DIC->ui()->factory();
38  $renderer = $DIC->ui()->renderer();
39 
40  $button = $f->button()->toggle('', '#', '#')
41  ->withAriaLabel("Switch the State of XY")
42  ->withUnavailableAction();
43 
44  return $renderer->render([$button]);
45 }
$renderer
global $DIC
Definition: shib_login.php:22

◆ with_tooltip()

ILIAS\UI\examples\Button\Toggle\with_tooltip ( )


description: > Example for rendering a Toggle Button with tooltips

expected output: >

Hovering over the rendered switch shows following tooltips: "tooltip: ilias" and "tooltip: learning management system".

Definition at line 32 of file with_tooltip.php.

References $DIC, Vendor\Package\$f, and $renderer.

33 {
34  global $DIC;
35  $f = $DIC->ui()->factory();
36  $renderer = $DIC->ui()->renderer();
37 
38  $button = $f->button()->toggle('', '#', '#')
39  ->withAriaLabel("Switch the State of XY")
40  ->withHelpTopics(
41  ...$f->helpTopics("ilias", "learning management system")
42  );
43 
44  return $renderer->render([$button]);
45 }
$renderer
global $DIC
Definition: shib_login.php:22