* ZIN: Attach onClickItem event to programmenu widget.

This commit is contained in:
chentao
2023-06-26 17:46:23 +08:00
parent 0dc7cd50d3
commit 92ec698fea
3 changed files with 21 additions and 6 deletions
+1
View File
@@ -1,6 +1,7 @@
.program-menu {width: 200px; max-height: 100%; margin: -5px 0;}
.program-menu .tree[data-zin-id] {border: 1px solid #E6EAF1; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); overflow-y: auto; width: 200px !important; background-color: #fff; padding-bottom: 20px;}
.program-menu .tree-item.tree-heading {padding: 16px 10px; font-size: 12px; color: var(--color-slate-600)}
.program-menu .tree-item .tree-item-content span {cursor: pointer;}
.program-menu .icon-container {width: 20px; height: 20px; display: flex; justify-content: center; align-items: center; border-radius: 50%; border: 1px solid #0066fa;}
.program-menu .icon-container.down {background-color: inherit;}
+2 -2
View File
@@ -1,5 +1,5 @@
function toggleIcon() {
function toggleIcon(e) {
const $pm = $(e.target).closest('.program-menu');
const show = $pm.attr('data-show');
let show = $pm.attr('data-show');
$pm.attr('data-show', (++show) % 2);
}
+18 -4
View File
@@ -10,7 +10,8 @@ class programMenu extends wg
'activeClass?: string="active"',
'activeIcon?: string="check"',
'activeKey?: string',
'closeLink?: string'
'closeLink?: string',
'onClickItem?: string'
);
public static function getPageCSS(): string|false
@@ -34,8 +35,15 @@ class programMenu extends wg
if(isset($child->icon)) $item['icon'] = $child->icon;
$items = $this->buildMenuTree($item['items'], $child->id);
if(count($items) !== 0) $item['items'] = $items;
else unset($item['items']);
if(count($items) !== 0)
{
$item['items'] = $items;
}
else
{
unset($item['items']);
}
$parent[] = $item;
}
@@ -64,7 +72,13 @@ class programMenu extends wg
{
$items = $this->buildMenuTree(array(), 0);
array_unshift($items, array('type' => 'heading', 'text' => '筛选项目集'));
return array('items' => $items);
$props = array('items' => $items);
/* Attach click event function. */
$onClickItem = $this->prop('onClickItem');
if($onClickItem) $props['onClickItem'] = $onClickItem;
return $props;
}
private function closeBtn()