* zin: add more shortcut methods.
This commit is contained in:
@@ -3,13 +3,16 @@ namespace zin;
|
||||
|
||||
page
|
||||
(
|
||||
prop('title', $title),
|
||||
h('h1', 'hello'),
|
||||
button('BUTTON'),
|
||||
btn('Primary')->primary()->rounded(),
|
||||
div
|
||||
(
|
||||
setclass('primary-pale'),
|
||||
h2('Headings2'),
|
||||
h3('Headings3'),
|
||||
html('<div>test</div>'),
|
||||
p('lorem', strong('bold'))
|
||||
)
|
||||
)->title($title)->x();
|
||||
)->x();
|
||||
|
||||
@@ -136,8 +136,7 @@ class classlist
|
||||
$index = trim($index);
|
||||
if(strlen($index) === 0) continue;
|
||||
|
||||
if($value) $this->list[$index] = true;
|
||||
elseif(isset($this->list[$index])) unset($this->list[$index]);
|
||||
$this->list[$index] = boolval($value);
|
||||
}
|
||||
$expectedKey++;
|
||||
}
|
||||
@@ -191,7 +190,7 @@ class classlist
|
||||
$name = trim($name);
|
||||
if(!strlen($name)) continue;
|
||||
|
||||
if(isset($this->list[$name])) unset($this->list[$name]);
|
||||
$this->list[$name] = false;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -216,9 +215,8 @@ class classlist
|
||||
$name = trim($name);
|
||||
if(strlen($name))
|
||||
{
|
||||
if($toggle === NULL) $toggle = !$this->has($name);
|
||||
if($toggle) $this->list[$name] = true;
|
||||
elseif(isset($this->list[$name])) unset($this->list[$name]);
|
||||
if($toggle === NULL) $toggle = !$this->has($name);
|
||||
$this->list[$name] = $toggle;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
+17
-10
@@ -57,10 +57,7 @@ class wg extends ele
|
||||
{
|
||||
if(isset($child->slots))
|
||||
{
|
||||
foreach($child->slots as $slot => $children)
|
||||
{
|
||||
$this->appendTo($slot, $children);
|
||||
}
|
||||
call_user_func_array('appendTo', $child->slots);
|
||||
unset($child->slots);
|
||||
}
|
||||
if(isset($child->css))
|
||||
@@ -99,7 +96,11 @@ class wg extends ele
|
||||
|
||||
if(!isset($this->slots[$slot])) $this->slots[$slot] = array();
|
||||
|
||||
$this->slots[$slot]= array_merge($this->slots[$slot], $args);
|
||||
foreach($args as $child)
|
||||
{
|
||||
if(is_array($child)) $this->slots[$slot] = array_merge($this->slots[$slot], $child);
|
||||
else $this->slots[$slot][] = $child;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -111,7 +112,11 @@ class wg extends ele
|
||||
|
||||
if(!isset($this->slots[$slot])) $this->slots[$slot] = array();
|
||||
|
||||
$this->slots[$slot] = array_merge($args, $this->slots[$slot]);
|
||||
foreach($args as $child)
|
||||
{
|
||||
if(is_array($child)) $this->slots[$slot] = array_merge($child, $this->slots[$slot]);
|
||||
else array_unshift($this->slots[$slot], $child);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -127,8 +132,9 @@ class wg extends ele
|
||||
{
|
||||
if($css === NULL) return $this->getCssCode();
|
||||
|
||||
if($reset) $this->cssList = array($css);
|
||||
else $this->cssList = array_merge($this->cssList, $css);
|
||||
if($reset) $this->cssList = array($css);
|
||||
elseif(is_array($css)) $this->cssList = array_merge($this->cssList, $css);
|
||||
else $this->cssList[] = $css;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -144,8 +150,9 @@ class wg extends ele
|
||||
{
|
||||
if($js === NULL) return implode("\n", $this->jsList);
|
||||
|
||||
if($reset) $this->jsList = array($js);
|
||||
else $this->jsList = array_merge($this->jsList, $js);
|
||||
if($reset) $this->jsList = array($js);
|
||||
elseif(is_array($js)) $this->jsList = array_merge($this->jsList, $js);
|
||||
else $this->jsList[] = $js;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
+64
-23
@@ -13,26 +13,67 @@ namespace zin;
|
||||
|
||||
require_once 'core/h5.class.php';
|
||||
|
||||
function h() {return new core\h5(func_get_args());}
|
||||
function button() {return call_user_func_array('\zin\core\h5::button', func_get_args());}
|
||||
function div() {return call_user_func_array('\zin\core\h5::div', func_get_args());}
|
||||
function span() {return call_user_func_array('\zin\core\h5::span', func_get_args());}
|
||||
function ol() {return call_user_func_array('\zin\core\h5::ol', func_get_args());}
|
||||
function ul() {return call_user_func_array('\zin\core\h5::ul', func_get_args());}
|
||||
function li() {return call_user_func_array('\zin\core\h5::li', func_get_args());}
|
||||
function h1() {return call_user_func_array('\zin\core\h5::h1', func_get_args());}
|
||||
function h2() {return call_user_func_array('\zin\core\h5::h2', func_get_args());}
|
||||
function h3() {return call_user_func_array('\zin\core\h5::h3', func_get_args());}
|
||||
function h4() {return call_user_func_array('\zin\core\h5::h4', func_get_args());}
|
||||
function alink() {return call_user_func_array('\zin\core\h5::a', func_get_args());}
|
||||
function strong() {return call_user_func_array('\zin\core\h5::strong', func_get_args());}
|
||||
function small() {return call_user_func_array('\zin\core\h5::small', func_get_args());}
|
||||
function code() {return call_user_func_array('\zin\core\h5::code', func_get_args());}
|
||||
function pre() {return call_user_func_array('\zin\core\h5::pre', func_get_args());}
|
||||
function br() {return call_user_func_array('\zin\core\h5::br', func_get_args());}
|
||||
function canvas() {return call_user_func_array('\zin\core\h5::canvas', func_get_args());}
|
||||
function iframe() {return call_user_func_array('\zin\core\h5::iframe', func_get_args());}
|
||||
function img() {return call_user_func_array('\zin\core\h5::img', func_get_args());}
|
||||
function input() {return call_user_func_array('\zin\core\h5::input', func_get_args());}
|
||||
function label() {return call_user_func_array('\zin\core\h5::label', func_get_args());}
|
||||
function p() {return call_user_func_array('\zin\core\h5::p', func_get_args());}
|
||||
function custom($name, $data) {$info = new \stdClass();$info->$name = $data;return $info;}
|
||||
function hx($prop, $value = NULL) {return (new core\hx())->set($prop, $value);}
|
||||
function style($prop, $value = NULL) {return (new core\style())->set($prop, $value);}
|
||||
function cssvar($name = '', $value = NULL) {return (new core\style())->var($name, $value);}
|
||||
function prop($prop, $value = NULL) {return (new core\props())->set($prop, $value);}
|
||||
function setClass() {return (new core\classlist())->set(func_get_args());}
|
||||
function toggleClass($name, $toggle = NULL) {return (new core\classlist())->toggle($name, $toggle);}
|
||||
function removeClass($name) {return (new core\classlist())->remove($name);}
|
||||
function html() {return custom('html', implode("\n", func_get_args()));}
|
||||
|
||||
function h() {return new core\h5(func_get_args());}
|
||||
function button() {return call_user_func_array('\zin\core\h5::button', func_get_args());}
|
||||
function div() {return call_user_func_array('\zin\core\h5::div', func_get_args());}
|
||||
function span() {return call_user_func_array('\zin\core\h5::span', func_get_args());}
|
||||
function ol() {return call_user_func_array('\zin\core\h5::ol', func_get_args());}
|
||||
function ul() {return call_user_func_array('\zin\core\h5::ul', func_get_args());}
|
||||
function li() {return call_user_func_array('\zin\core\h5::li', func_get_args());}
|
||||
function h1() {return call_user_func_array('\zin\core\h5::h1', func_get_args());}
|
||||
function h2() {return call_user_func_array('\zin\core\h5::h2', func_get_args());}
|
||||
function h3() {return call_user_func_array('\zin\core\h5::h3', func_get_args());}
|
||||
function h4() {return call_user_func_array('\zin\core\h5::h4', func_get_args());}
|
||||
function h5() {return call_user_func_array('\zin\core\h5::h5', func_get_args());}
|
||||
function h6() {return call_user_func_array('\zin\core\h5::h6', func_get_args());}
|
||||
function a() {return call_user_func_array('\zin\core\h5::a', func_get_args());}
|
||||
function strong() {return call_user_func_array('\zin\core\h5::strong', func_get_args());}
|
||||
function small() {return call_user_func_array('\zin\core\h5::small', func_get_args());}
|
||||
function em() {return call_user_func_array('\zin\core\h5::em', func_get_args());}
|
||||
function sub() {return call_user_func_array('\zin\core\h5::sub', func_get_args());}
|
||||
function sup() {return call_user_func_array('\zin\core\h5::sup', func_get_args());}
|
||||
function code() {return call_user_func_array('\zin\core\h5::code', func_get_args());}
|
||||
function pre() {return call_user_func_array('\zin\core\h5::pre', func_get_args());}
|
||||
function br() {return call_user_func_array('\zin\core\h5::br', func_get_args());}
|
||||
function canvas() {return call_user_func_array('\zin\core\h5::canvas', func_get_args());}
|
||||
function iframe() {return call_user_func_array('\zin\core\h5::iframe', func_get_args());}
|
||||
function audio() {return call_user_func_array('\zin\core\h5::audio', func_get_args());}
|
||||
function video() {return call_user_func_array('\zin\core\h5::video', func_get_args());}
|
||||
function track() {return call_user_func_array('\zin\core\h5::track', func_get_args());}
|
||||
function picture() {return call_user_func_array('\zin\core\h5::picture', func_get_args());}
|
||||
function source() {return call_user_func_array('\zin\core\h5::source', func_get_args());}
|
||||
function svg() {return call_user_func_array('\zin\core\h5::svg', func_get_args());}
|
||||
function del() {return call_user_func_array('\zin\core\h5::del', func_get_args());}
|
||||
function ins() {return call_user_func_array('\zin\core\h5::ins', func_get_args());}
|
||||
function caption() {return call_user_func_array('\zin\core\h5::caption', func_get_args());}
|
||||
function details() {return call_user_func_array('\zin\core\h5::details', func_get_args());}
|
||||
function summary() {return call_user_func_array('\zin\core\h5::summary', func_get_args());}
|
||||
function img() {return call_user_func_array('\zin\core\h5::img', func_get_args());}
|
||||
function input() {return call_user_func_array('\zin\core\h5::input', func_get_args());}
|
||||
function label() {return call_user_func_array('\zin\core\h5::label', func_get_args());}
|
||||
function p() {return call_user_func_array('\zin\core\h5::p', func_get_args());}
|
||||
function main() {return call_user_func_array('\zin\core\h5::main', func_get_args());}
|
||||
function side() {return call_user_func_array('\zin\core\h5::side', func_get_args());}
|
||||
function section() {return call_user_func_array('\zin\core\h5::section', func_get_args());}
|
||||
function nav() {return call_user_func_array('\zin\core\h5::nav', func_get_args());}
|
||||
function table() {return call_user_func_array('\zin\core\h5::table', func_get_args());}
|
||||
function tbody() {return call_user_func_array('\zin\core\h5::tbody', func_get_args());}
|
||||
function thead() {return call_user_func_array('\zin\core\h5::thead', func_get_args());}
|
||||
function tfoot() {return call_user_func_array('\zin\core\h5::tfoot', func_get_args());}
|
||||
function td() {return call_user_func_array('\zin\core\h5::td', func_get_args());}
|
||||
function th() {return call_user_func_array('\zin\core\h5::th', func_get_args());}
|
||||
function tr() {return call_user_func_array('\zin\core\h5::tr', func_get_args());}
|
||||
function form() {return call_user_func_array('\zin\core\h5::form', func_get_args());}
|
||||
function select() {return call_user_func_array('\zin\core\h5::select', func_get_args());}
|
||||
function option() {return call_user_func_array('\zin\core\h5::option', func_get_args());}
|
||||
function textarea() {return call_user_func_array('\zin\core\h5::textarea', func_get_args());}
|
||||
|
||||
+4
-5
@@ -12,12 +12,11 @@
|
||||
namespace zin;
|
||||
|
||||
require_once 'helper.php';
|
||||
require_once 'h5.func.php';
|
||||
|
||||
function hx()
|
||||
{
|
||||
|
||||
}
|
||||
function import() {return custom('import', func_get_args());}
|
||||
function js() {return custom('js', func_get_args());}
|
||||
function css() {return custom('css', func_get_args());}
|
||||
function to() {return custom('slots', func_get_args());}
|
||||
|
||||
function btn() {return createWg('btn', func_get_args());}
|
||||
function page() {return createWg('page', func_get_args());}
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ class page extends \zin\core\wg
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function buildHeader($isPrint = false, $parent = NULL)
|
||||
protected function buildHead($isPrint = false, $parent = NULL)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
@@ -90,7 +90,7 @@ class page extends \zin\core\wg
|
||||
return \zin\core\wg::createBuilder('html')
|
||||
->props($this->props)
|
||||
->before('<!DOCTYPE html>')
|
||||
->append($this->buildHeader()->build())
|
||||
->append($this->buildHead()->build())
|
||||
->append($this->buildBody()->build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user