From f520e1a358ae4c4fa173f32b8578147d5729a07b Mon Sep 17 00:00:00 2001 From: dingyongliang Date: Mon, 6 Feb 2023 13:09:22 +0800 Subject: [PATCH] * zin: add buildItem. --- module/program/ui/browse.html.php | 15 ++++++------- zin/wg/toolbar/v1.php | 36 ++++++++++++++++++++++++++++++- zin/wg/zuinav/v1.php | 34 +++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index 10dbb18baf..e38b3e9d6e 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -16,7 +16,7 @@ foreach(\customModel::getMainMenu() as $menuItem) page ( - set ('title', $title), + set('title', $title), pageheader ( pageheading @@ -29,21 +29,18 @@ page ( zuinav ( - set('js-render', true), + set('js-render', false), set('items', $navItems), + item(array('text' => 'text')), ), ), toolbar ( setId('toolbar'), set('js-render', true), - set('items', array - ( - array('icon' => 'icon-plus'), - array('icon' => 'icon-group'), - array('text' => '研发综合界面'), - ) - ), + item(array('icon' => 'icon-plus')), + item(array('icon' => 'icon-group')), + item(array('text' => '研发综合界面')), ), ), diff --git a/zin/wg/toolbar/v1.php b/zin/wg/toolbar/v1.php index bcf58c3b25..74a4e0b5ad 100644 --- a/zin/wg/toolbar/v1.php +++ b/zin/wg/toolbar/v1.php @@ -3,14 +3,48 @@ namespace zin\wg; require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'wg.class.php'; +use \zin\core\h5; + class toolbar extends \zin\core\wg { static $tag = 'div'; - static $defaultProps = array('class' => 'toolbar', 'id' => 'toolbar'); + static $defaultProps = array('id' => 'toolbar'); static $customProps = 'wrap,gap,items,btnProps,itemRender,beforeRender,afterRender,firstRender'; + protected function itemsWrapper() + { + return h5::nav()->addClass('toolbar'); + } + + protected function buildItem($item) + { + if ($item['type'] === 'divider') return h5::div()->addClass('toolbar-divider'); + + $button = h5::button()->addClass('btn toolbar-item ghost'); + $a = h5::a(); + if ($item['active']) + { + $a->addClass('active'); + } + $url = $item['url']; + if (!empty($url)) + { + $a->prop('href', "$url"); + } + $button->append($a); + $icon = $item['icon']; + if (!empty($icon)) + { + $i = h5::i()->addClass("icon icon-$icon"); + $a->append($i); + } + $span = h5::span($item['text'])->addClass('text'); + $a->append($span); + return $button; + } + protected function build($isPrint = false, $parent = null) { $builder = parent::build($isPrint, $parent); diff --git a/zin/wg/zuinav/v1.php b/zin/wg/zuinav/v1.php index 5158bb9081..f82e8ca2d9 100755 --- a/zin/wg/zuinav/v1.php +++ b/zin/wg/zuinav/v1.php @@ -5,6 +5,8 @@ require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'wg.class.php'; require_once dirname(dirname(__DIR__)) . DS . 'core' . DS . 'h5.class.php'; require_once dirname(__DIR__) . DS . 'icon' . DS . 'v1.php'; +use \zin\core\h5; + class zuinav extends \zin\core\wg { static $tag = 'div'; @@ -15,6 +17,38 @@ class zuinav extends \zin\core\wg public $cssList = array(':root{--nav-active-color: white;}'); + protected function itemsWrapper() + { + return h5::menu()->addClass('nav'); + } + + protected function buildItem($item) + { + if ($item['type'] === 'divider') return h5::li()->addClass('nav-divider'); + + $li = h5::li()->addClass('nav-item'); + $a = h5::a(); + if ($item['active']) + { + $a->addClass('active'); + } + $url = $item['url']; + if (!empty($url)) + { + $a->prop('href', "$url"); + } + $li->append($a); + $icon = $item['icon']; + if (!empty($icon)) + { + $i = h5::i()->addClass("icon icon-$icon"); + $a->append($i); + } + $span = h5::span($item['text'])->addClass('text'); + $a->append($span); + return $li; + } + /** * @return builder */