* zin: add more widgets
This commit is contained in:
@@ -34,6 +34,7 @@ function label() {return createWg('label', func_get_args());}
|
||||
function dtable() {return createWg('dtable', func_get_args());}
|
||||
function menu() {return createWg('menu', func_get_args());}
|
||||
function radio() {return createWg('radio', func_get_args());}
|
||||
function switcher() {return createWg('switcher', func_get_args());}
|
||||
function select() {return createWg('select', func_get_args());}
|
||||
function formlabel() {return createWg('formlabel', func_get_args());}
|
||||
function formgroup() {return createWg('formgroup', func_get_args());}
|
||||
|
||||
@@ -3,10 +3,11 @@ namespace zin;
|
||||
|
||||
require_once dirname(__DIR__) . DS . 'btn' . DS . 'v1.php';
|
||||
require_once dirname(__DIR__) . DS . 'dropdown' . DS . 'v1.php';
|
||||
require_once dirname(__DIR__) . DS . 'checkbox' . DS . 'v1.php';
|
||||
|
||||
class actionItem extends wg
|
||||
{
|
||||
static $defineProps = 'name:string="action", type:string="item", outerTag:string="li", tagName:string="a", icon?:string, text?:string, url?:string, target?:string, active?:bool, disabled?:bool, trailingIcon?:string, outerProps?:array, outerClass?: string';
|
||||
static $defineProps = 'name:string="action", type:string="item", outerTag:string="li", tagName:string="a", icon?:string, text?:string, url?:string, target?:string, active?:bool, disabled?:bool, trailingIcon?:string, outerProps?:array, outerClass?:string, badge?:string|array|object, props?:array';
|
||||
|
||||
protected function buildDividerItem()
|
||||
{
|
||||
@@ -20,6 +21,7 @@ class actionItem extends wg
|
||||
return h::div
|
||||
(
|
||||
set($this->props->skip(array_keys(actionItem::getDefinedProps()))),
|
||||
set($this->prop('props')),
|
||||
$icon ? icon($icon) : NULL,
|
||||
empty($text) ? NULL : span($text, setClass('text')),
|
||||
$this->children(),
|
||||
@@ -29,13 +31,18 @@ class actionItem extends wg
|
||||
|
||||
protected function buildDropdownItem()
|
||||
{
|
||||
$dropdown = new dropdown($this->props->skip('tagName,type,name,outerTag,outerProps'), $this->children());
|
||||
$dropdown = new dropdown($this->props->skip('tagName,type,name,outerTag,outerProps,props'), set($this->prop('props')), $this->children());
|
||||
return $dropdown;
|
||||
}
|
||||
|
||||
protected function buildBtnItem()
|
||||
{
|
||||
return new btn($this->props->skip('tagName,type,name,outerTag,outerProps'), $this->children());
|
||||
return new btn($this->props->skip('tagName,type,name,outerTag,outerProps,props'), set($this->prop('props')),$this->children());
|
||||
}
|
||||
|
||||
protected function buildCheckboxItem()
|
||||
{
|
||||
return new checkbox($this->props->skip('tagName,type,name,outerTag,outerProps,props'), set($this->prop('props')),$this->children());
|
||||
}
|
||||
|
||||
protected function buildItem()
|
||||
@@ -44,7 +51,10 @@ class actionItem extends wg
|
||||
$methodName = "build{$type}Item";
|
||||
if(method_exists($this, $methodName)) return $this->$methodName();
|
||||
|
||||
list($tagName, $icon, $text, $trailingIcon, $url, $target, $active, $disabled) = $this->prop(array('tagName', 'icon', 'text', 'trailingIcon', 'url', 'target', 'active', 'disabled'));
|
||||
list($tagName, $icon, $text, $trailingIcon, $url, $target, $active, $disabled, $badge) = $this->prop(array('tagName', 'icon', 'text', 'trailingIcon', 'url', 'target', 'active', 'disabled', 'badge'));
|
||||
|
||||
if(is_string($badge)) $badge = label($badge);
|
||||
else if(is_array($badge)) $badge = label(set($badge));
|
||||
|
||||
return h::create
|
||||
(
|
||||
@@ -54,6 +64,7 @@ class actionItem extends wg
|
||||
set($this->props->skip(array_keys(actionItem::getDefinedProps()))),
|
||||
$icon ? icon($icon) : NULL,
|
||||
$text,
|
||||
$badge,
|
||||
$this->children(),
|
||||
$trailingIcon ? icon($trailingIcon) : NULL,
|
||||
);
|
||||
|
||||
+35
-8
@@ -3,7 +3,7 @@ namespace zin;
|
||||
|
||||
class checkbox extends wg
|
||||
{
|
||||
protected static $defineProps = 'text?:string';
|
||||
protected static $defineProps = 'text?:string, checked?:bool, name?:string, primary:bool=true, id:string, disabled?:bool, type:string="checkbox", value?:string, typeClass?:string';
|
||||
|
||||
public function onAddChild($child)
|
||||
{
|
||||
@@ -14,19 +14,46 @@ class checkbox extends wg
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildPrimary()
|
||||
{
|
||||
list($id, $text, $name, $checked, $disabled, $type, $typeClass) = $this->prop(array('id', 'text', 'name', 'checked', 'disabled', 'type', 'typeClass'));
|
||||
|
||||
if(empty($typeClass)) $typeClass = $type;
|
||||
if(empty($id)) $id = $this->gid;
|
||||
|
||||
return div
|
||||
(
|
||||
setClass("$typeClass-primary", array('checked' => $checked, 'disabled' => $disabled)),
|
||||
h::input
|
||||
(
|
||||
set::type($type),
|
||||
set::id($id),
|
||||
set($this->props->skip('text,primary,typeClass,id')),
|
||||
),
|
||||
h::label
|
||||
(
|
||||
set::for($id),
|
||||
$text,
|
||||
),
|
||||
$this->children()
|
||||
);
|
||||
}
|
||||
|
||||
protected function build()
|
||||
{
|
||||
if($this->prop('primary')) return $this->buildPrimary();
|
||||
list($text, $type, $typeClass) = $this->prop(array('text', 'type', 'typeClass'));
|
||||
|
||||
return h::label
|
||||
(
|
||||
setClass('pl-2 checkbox'),
|
||||
setClass($this->props->class->list),
|
||||
h::checkbox
|
||||
setClass(empty($typeClass) ? $type : $typeClass),
|
||||
h::input
|
||||
(
|
||||
setId($this->prop('id')),
|
||||
set($this->props->skip(array_merge(array_keys(static::getDefinedProps(), true), array('class')))),
|
||||
$this->prop('checked') ? set('checked', $this->prop('checked')) : null
|
||||
set::type($type),
|
||||
set($this->props->skip('text,primary,typeClass')),
|
||||
),
|
||||
$this->prop('text')
|
||||
is_string($text) ? span($text, set::class('text')) : $text,
|
||||
$this->children()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,40 @@ class featureBar extends wg
|
||||
'trailing' => array(),
|
||||
);
|
||||
|
||||
protected function getItems()
|
||||
{
|
||||
$items = $this->prop('items');
|
||||
if(!empty($items)) return $items;
|
||||
|
||||
global $app, $lang;
|
||||
$currentModule = $app->rawModule;
|
||||
$currentMethod = $app->rawMethod;
|
||||
|
||||
\common::sortFeatureMenu($currentModule, $currentMethod);
|
||||
|
||||
if(!isset($lang->$currentModule->featureBar[$currentMethod])) return NULL;
|
||||
$rawItems = $lang->$currentModule->featureBar[$currentMethod];
|
||||
if(!is_array($rawItems)) return NULL;
|
||||
|
||||
$browseType = data('browseType', '');
|
||||
$orderBy = data('orderBy', '');
|
||||
$recTotal = data('recTotal');
|
||||
$items = array();
|
||||
|
||||
foreach($rawItems as $key => $text)
|
||||
{
|
||||
$isActive = $key == $browseType;
|
||||
$items[] = array
|
||||
(
|
||||
'text' => $text,
|
||||
'active' => $isActive,
|
||||
'url' => createLink($currentModule, $currentMethod, 'all', "browseType=$key&orderBy=$orderBy"),
|
||||
'badge' => $isActive && !empty($recTotal) ? array('text' => $recTotal, 'class' => 'size-sm circle white') : NULL,
|
||||
);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function buildNav()
|
||||
{
|
||||
$nav = $this->block('nav');
|
||||
@@ -21,7 +55,7 @@ class featureBar extends wg
|
||||
return new nav
|
||||
(
|
||||
set::class('nav-feature'),
|
||||
set::items($this->prop('items')),
|
||||
set::items($this->getItems()),
|
||||
divorce($this->children())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ class label extends wg
|
||||
(
|
||||
setClass('label'),
|
||||
set($this->props->skip(array_keys(static::getDefinedProps()))),
|
||||
$this->prop('text'),
|
||||
$this->children()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,8 +114,7 @@ class navbar extends wg
|
||||
commonModel::setMainMenu();
|
||||
commonModel::checkMenuVarsReplaced();
|
||||
|
||||
$app = data('app');
|
||||
$lang = data('lang');
|
||||
global $app, $lang;
|
||||
$isTutorialMode = commonModel::isTutorialMode();
|
||||
$currentModule = $app->rawModule;
|
||||
$currentMethod = $app->rawMethod;
|
||||
|
||||
+7
-21
@@ -1,26 +1,12 @@
|
||||
<?php
|
||||
namespace zin;
|
||||
|
||||
class radio extends wg
|
||||
require_once dirname(__DIR__) . DS . 'checkbox' . DS . 'v1.php';
|
||||
|
||||
class radio extends checkbox
|
||||
{
|
||||
protected static $defineProps = 'text?:string';
|
||||
|
||||
public function onAddChild($child)
|
||||
{
|
||||
if(is_string($child) && !$this->props->has('text'))
|
||||
{
|
||||
$this->props->set('text', $child);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function build()
|
||||
{
|
||||
return h::label
|
||||
(
|
||||
setClass('radio'),
|
||||
h::radio(set($this->props->skip(array_keys(static::getDefinedProps()), true))),
|
||||
$this->prop('text')
|
||||
);
|
||||
}
|
||||
protected static $defaultProps = array
|
||||
(
|
||||
'type' => 'radio'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace zin;
|
||||
|
||||
require_once dirname(__DIR__) . DS . 'checkbox' . DS . 'v1.php';
|
||||
|
||||
class switcher extends checkbox
|
||||
{
|
||||
protected static $defaultProps = array
|
||||
(
|
||||
'typeClass' => 'switch'
|
||||
);
|
||||
}
|
||||
@@ -32,3 +32,8 @@ function getWebRoot($full = false)
|
||||
{
|
||||
return \getWebRoot($full);
|
||||
}
|
||||
|
||||
function hasPriv($module, $method, $object = null, $vars = '')
|
||||
{
|
||||
return common::hasPriv($module, $method, $object, $vars);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user