Skip to content

Commit

Permalink
UI: add DD JS to Input View Controls (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen authored Jul 8, 2024
1 parent 598ca71 commit f74ec01
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace ILIAS\UI\Implementation\Component\Input\ViewControl;

use ILIAS\UI\Implementation\Render\AbstractComponentRenderer;
use ILIAS\UI\Implementation\Render\ResourceRegistry;
use ILIAS\UI\Renderer as RendererInterface;
use ILIAS\UI\Component;
use LogicException;
Expand Down Expand Up @@ -117,6 +118,10 @@ function(event, signal_data) {
fn($id) => "$('#{$id} > .dropdown-menu')
.on('click', (event) => event.stopPropagation());"
);
$component = $component->withAdditionalOnLoadCode(
fn($id) =>
"il.UI.dropdown.init(document.getElementById(\"$id\"));"
);

$id = $this->bindJavaScript($component);
$container_submit_signal = $component->getOnChangeSignal();
Expand Down Expand Up @@ -175,6 +180,10 @@ function(event, signal_data) {
});"
);
}
$component = $component->withAdditionalOnLoadCode(
fn($id) =>
"il.UI.dropdown.init(document.getElementById(\"$id\"));"
);
$id = $this->bindJavaScript($component);

$tpl->setVariable('ID', $id);
Expand Down Expand Up @@ -354,6 +363,15 @@ function(event, signal_data) {
});"
);
}
$component = $component->withAdditionalOnLoadCode(
fn($id) => "
il.UI.dropdown.init(
document.getElementById(\"$id\").querySelector(
'.dropdown.il-viewcontrol-pagination__num-of-items'
)
);
"
);
$id = $this->bindJavaScript($component);

$tpl->setVariable('ID', $id);
Expand All @@ -371,4 +389,13 @@ function(event, signal_data) {

return $tpl->get();
}

/**
* @inheritdoc
*/
public function registerResources(ResourceRegistry $registry): void
{
parent::registerResources($registry);
$registry->register('assets/js/dropdown.js');
}
}

0 comments on commit f74ec01

Please sign in to comment.