ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
trait.ilMMCloseOnClick.php
Go to the documentation of this file.
1<?php
2
7
12trait ilMMCloseOnClick
13{
14 protected function addDisengageDecorator(isItem $item) : isItem
15 {
16 if (($item instanceof isParent || $item instanceof isInterchangeableItem) && $item->getParent()->serialize() === '') {
17 // always close MainBar when a link has been clicked
18 return $item->addComponentDecorator(static function (ILIAS\UI\Component\Component $c
19 ) : ILIAS\UI\Component\Component {
20 if ($c instanceof JavaScriptBindable) {
21 return $c->withAdditionalOnLoadCode(function ($id) {
22 return "$('#$id').click(function() {
23 il.UI.maincontrols.mainbar.disengageAll();
24 il.UI.maincontrols.mainbar.clearStates();
25 })";
26 });
27 }
28 return $c;
29 });
30 }
31
32 return $item;
33 }
34}
An exception for terminatinating execution or to throw for unit testing.
addComponentDecorator(Closure $component_decorator)
Interface to be extended by components that have the possibility to bind to Javascript.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.