From 92ec698feae04ea1a97fd8ea4fd4afc179aadfac Mon Sep 17 00:00:00 2001 From: chentao Date: Mon, 26 Jun 2023 17:45:50 +0800 Subject: [PATCH] * ZIN: Attach onClickItem event to programmenu widget. --- lib/zin/wg/programmenu/css/v1.css | 1 + lib/zin/wg/programmenu/js/v1.js | 4 ++-- lib/zin/wg/programmenu/v1.php | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/zin/wg/programmenu/css/v1.css b/lib/zin/wg/programmenu/css/v1.css index 0a26c9430f..f9df58d234 100644 --- a/lib/zin/wg/programmenu/css/v1.css +++ b/lib/zin/wg/programmenu/css/v1.css @@ -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;} diff --git a/lib/zin/wg/programmenu/js/v1.js b/lib/zin/wg/programmenu/js/v1.js index 34781635de..2fffb8d854 100644 --- a/lib/zin/wg/programmenu/js/v1.js +++ b/lib/zin/wg/programmenu/js/v1.js @@ -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); } diff --git a/lib/zin/wg/programmenu/v1.php b/lib/zin/wg/programmenu/v1.php index 01928cad0b..133616d423 100644 --- a/lib/zin/wg/programmenu/v1.php +++ b/lib/zin/wg/programmenu/v1.php @@ -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()