ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
client.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
21 function client(): string
22 {
23  global $DIC;
24  $factory = $DIC->ui()->factory();
25  $renderer = $DIC->ui()->renderer();
26 
27  $progress_bar = $factory->progress()->bar('clicking the button 10 times');
28 
29  $make_progress = $factory->button()->standard('make some progress', '#');
30  $make_progress = $make_progress->withAdditionalOnLoadCode(
31  static fn(string $id) => "
32  let progress = 0;
33  document.getElementById('$id')?.addEventListener('click', (event) => {
34  if (90 === progress) {
35  event.target.disabled = true;
36  il.UI.Progress.Bar.success('{$progress_bar->getUpdateSignal()}', 'all done!');
37  return;
38  }
39 
40  progress += 10;
41  il.UI.Progress.Bar.determinate('{$progress_bar->getUpdateSignal()}', progress);
42  });
43  ",
44  );
45 
46  return $renderer->render([$progress_bar, $make_progress]);
47 }
$renderer
global $DIC
Definition: shib_login.php:25
client()
description: > This example shows how a Progress Bar can be rendered and used on the client...
Definition: client.php:21
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24