3declare(strict_types=1);
22 $f =
$DIC->ui()->factory();
23 $renderer =
$DIC->ui()->renderer();
26 $like =
$f->symbol()->glyph()->love(
"#")
27 ->withCounter(
$f->counter()->novelty(3))
28 ->withCounter(
$f->counter()->status(0));
30 $set_status_button =
$f->button()->bulky($like,
"Set Status Counter to 10 on click.",
"#")
31 ->withAdditionalOnLoadCode(
34 $(\"#$id\").click(function() {
35 il.UI.counter.getCounterObject($(this)).setStatusTo(10);
40 $increment_novelty_button =
$f->button()->bulky($like,
"Increment Novelty Counter by on click",
"#")
41 ->withAdditionalOnLoadCode(
44 $(\"#$id\").click(function() {
45 il.UI.counter.getCounterObject($(this)).incrementNoveltyCount(1);
50 $set_novelty_count_to_status_button =
$f->button()->bulky($like,
"Set Novelty Count to status on click",
"#")
51 ->withAdditionalOnLoadCode(
54 $(\"#$id\").click(function() {
55 il.UI.counter.getCounterObject($(this)).setTotalNoveltyToStatusCount(1);
61 $combined_button =
$f->button()->bulky($like,
"Some chained actions",
"#")
62 ->withAdditionalOnLoadCode(
65 $(\"#$id\").click(function() {
66 var counter = il.UI.counter.getCounterObject($(this));
67 counter.setNoveltyTo(3);
68 counter.setStatusTo(3);
69 counter.incrementStatusCount(1);
70 counter.setTotalNoveltyToStatusCount();
72 counter.getStatusCount()
78 return $renderer->render([$set_status_button,$increment_novelty_button,$set_novelty_count_to_status_button,$combined_button]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
with_js()
Note, counters also offer an interface for manipulations through JS.