ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\UI\examples\Counter\Status Namespace Reference

Functions

 base ()
 
 multiple_glyphs ()
 
 with_js ()
 
 with_novelty ()
 

Function Documentation

◆ base()

ILIAS\UI\examples\Counter\Status\base ( )

description: > Base example for rendering a status counter.

expected output: >

ILIAS shows a rendered glyph with a counter. The counter consists of a white colored number within a grey circle.

Definition at line 32 of file base.php.

33{
34 global $DIC;
35 $f = $DIC->ui()->factory();
36 $renderer = $DIC->ui()->renderer();
37
38 return $renderer->render($f->symbol()->glyph()->mail("#")
39 ->withCounter($f->counter()->status(3)));
40}
$renderer
global $DIC
Definition: shib_login.php:26

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

◆ multiple_glyphs()

ILIAS\UI\examples\Counter\Status\multiple_glyphs ( )

description: > Example for rendering multiple glyphs with status counters

expected output: > ILIAS shows three rendered glyphs with two counters each in a row.

The counters consist of a white number each and are highlighted red resp. grey

Definition at line 33 of file multiple_glyphs.php.

34{
35 global $DIC;
36 $f = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38
39 $note = $f->symbol()->glyph()->note("#")
40 ->withCounter($f->counter()->novelty(100))
41 ->withCounter($f->counter()->status(8));
42
43 $tag = $f->symbol()->glyph()->tag("#")
44 ->withCounter($f->counter()->novelty(1))
45 ->withCounter($f->counter()->status(800));
46
47 $comment = $f->symbol()->glyph()->comment("#")
48 ->withCounter($f->counter()->novelty(1))
49 ->withCounter($f->counter()->status(8));
50
51 return $renderer->render($note) . $renderer->render($tag) . $renderer->render($comment);
52}
$comment
Definition: buildRTE.php:72

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

◆ with_js()

ILIAS\UI\examples\Counter\Status\with_js ( )

description: > Base example for rendering a JS status counter

note: > Counters also offer an interface for manipulations through JS. Checkout src/UI/templates/js/Counter/counter.js for a complete spec.

expected output: > ILIAS shows different JS-exmaples which can get altered directly:

  • Click once to raise the status counter to 10.
  • Click once to raise the novelty counter to 1.
  • Click once to change the novelty counter to a status counter.

    - Click once to change the status counter 3 to a novelty counter 7.

Definition at line 40 of file with_js.php.

41{
42 global $DIC;
43 $f = $DIC->ui()->factory();
44 $renderer = $DIC->ui()->renderer();
45
46 //Note that both counters have to be present to perform JS actions on them
47 $like = $f->symbol()->glyph()->love("#")
48 ->withCounter($f->counter()->novelty(3))
49 ->withCounter($f->counter()->status(0));
50
51 $set_status_button = $f->button()->bulky($like, "Set Status Counter to 10 on click.", "#")
52 ->withAdditionalOnLoadCode(
53 function ($id) {
54 return "
55 $(\"#$id\").click(function() {
56 il.UI.counter.getCounterObject($(this)).setStatusTo(10);
57 });";
58 }
59 );
60
61 $increment_novelty_button = $f->button()->bulky($like, "Increment Novelty Counter by on click", "#")
62 ->withAdditionalOnLoadCode(
63 function ($id) {
64 return "
65 $(\"#$id\").click(function() {
66 il.UI.counter.getCounterObject($(this)).incrementNoveltyCount(1);
67 });";
68 }
69 );
70
71 $set_novelty_count_to_status_button = $f->button()->bulky($like, "Set Novelty Count to status on click", "#")
72 ->withAdditionalOnLoadCode(
73 function ($id) {
74 return "
75 $(\"#$id\").click(function() {
76 il.UI.counter.getCounterObject($(this)).setTotalNoveltyToStatusCount(1);
77 });";
78 }
79 );
80
81 //What will the value of Status be after click?
82 $combined_button = $f->button()->bulky($like, "Some chained actions", "#")
83 ->withAdditionalOnLoadCode(
84 function ($id) {
85 return "
86 $(\"#$id\").click(function() {
87 var counter = il.UI.counter.getCounterObject($(this));
88 counter.setNoveltyTo(3);
89 counter.setStatusTo(3);
90 counter.incrementStatusCount(1);
91 counter.setTotalNoveltyToStatusCount();
92 console.log(
93 counter.getStatusCount()
94 );
95 });";
96 }
97 );
98
99 return $renderer->render([$set_status_button,$increment_novelty_button,$set_novelty_count_to_status_button,$combined_button]);
100}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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

◆ with_novelty()

ILIAS\UI\examples\Counter\Status\with_novelty ( )

description: > Base example for rendering a status counter with novelty

expected output: >

ILIAS shows a glyph with two counters. The counter's numbers are white and highlighted red resp. grey.

Definition at line 32 of file with_novelty.php.

33{
34 global $DIC;
35 $f = $DIC->ui()->factory();
36 $renderer = $DIC->ui()->renderer();
37
38 return $renderer->render(
39 $f->symbol()->glyph()->mail("#")
40 ->withCounter($f->counter()->novelty(1))
41 ->withCounter($f->counter()->status(8))
42 );
43}

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