Html
Html elements
Html elements
Create Header:
$Div = $this->get('html', 'DIV', 'Hello world!');
--- $Div outputs
<DIV>Hello World!</DIV>
Set element attributes with second parameter as array:
$Div = $this->get('html', 'DIV', Array(
'content' => 'Hello World!',
'id' => 'header',
'role' => 'page-header',
'class' => 'page__header'
));
--- $Div outputs
<DIV id="header" data-role="page-header" class="page__header">Hello World!</DIV>
Set same attributes via set -methods:
$Div = $this->get('html', 'DIV')
->setContent('Hello World!')
->setId('header')
...
Create element and add it to another element:
$UL = $this->get('html', 'UL');
$LI = $this->get('html', 'LI', 'Line')->appendTo($UL);
--- $UL outputs
<UL>
<LI>Line</LI>
</UL>
Create and add element using parent element:
$UL->appendElement('LI', 'Second line');
$UL->prependElement('LI', 'First line');
--- $UL outputs
<UL>
<LI>First line</LI>
<LI>Line</LI>
<LI>Second line</LI>
</UL>
Method | Return | Description |
---|---|---|
::create(tag,html) | eHtmlElement | Create new eHtmlElement. |
setTag(name) | this | Set element tag name. |
getTag() | string | Get element tag name |
setContent(string) | this | Set string as tag html content. |
addContent(string) | this | Add string to tag html content. |
clearContent() | this | Revoe all html content from tag. |
getContent() | string | Get tag html content. |
html(string) | this | Set string as tag html content. |
html() | string | Get tag html content. |
Method | Return | Description |
---|---|---|
append(data) | string,object | Add content inside tag. |
prepend(data) | string,object | Add content in start of tag. |
appendTo(eHtmlElement) | this | Add element inside other element. |
prepend(eHtmlElement) | this | Add element in start of other element. |
getParent() | eHtmlElement | Get elements parent element |
Method | Return | Description |
---|---|---|
bind(name,function) | this | Binb javascript function to event. |
Method | Return | Description |
---|---|---|
setClass(name) | this | Set tag class, clear old definitions. |
addClass(name, name...) | this | Add classes to tag. |
removeClass(name) | this | Remove given class. |
clearClass() | this | Clear all class definitions. |
isClass() | bool | Return TRUE if element at least one class. |
isClass([name]) | bool | REturn TRUE if element has given class. |
getClass() | array | Classes in array. |
getClassString() | this | Classes inspace delimited string. |
Method | Return | Description |
---|---|---|
setCss(name,value) | this | Set CSS value. |
setCss(array) | array | Set CSS from assoc array. Clear previous definitions. |
addCss(name,value) | this | Add value to CSS. |
addCss(array) | this | Add CSS values from assoc array. |
clearCss(name,value) | this | Clear all css definitions. |
getCss(name) | string | Get css value. |
getCss() | array | Get all css definitions. |
getCssString() | string | Return CSS definitions in: style="name:value;" -string |
setWidth(name,value) | this | Set element width. Alias to setCss('width',100), except adds missing unit. |
setHeight(name,value) | this | Set element height. Alias to setCss('height',100), except adds missing unit. |
All undedfined method clas are setName()
Method | Return | Description |
---|---|---|
setAttr(name,value) | this | Set attr variable. |
setAttr(array) | this | Set attr values from assoc array. |
addAttr(name,value) | this | Set value to attribute. |
addAttr(array) | this | Set multiple attribute values vrom assoc array. |
isAttr(name) | bool | Return TRUE, if attr is defined. |
removeAttr(name) | this | Remove attr definition. |
removeAttr() | this | Remove all attr definitions. |
clearAttr(name) | this | Clear calue in attr. |
getAttrDelimiter(name) | string | Get delimiter used to combine multiple values. (Semicolon or space). |
setAttrText() | this | Additional freetext that is added in end of tag. |
getAttrString() | string | Return attributes n: name="value" -format. |
All undefined methods are cast as set/get attr method
Method | Return | Description |
---|---|---|
name() | string | Alias to getAttr(name) |
name(value) | this | Alias to setAttr(name,value) |
getName() | string | Alias to getAttr(name) |
setName(value) | this | Alias to setAttr(name,value) |
addName(value) | this | Alias to addAttr(name,value) |
isName() | bool | Alias to isAttr(name) |
clearName() | this | Alias to isAttr(name) |
Data values are set in tag as:
Method | Return | Description |
---|---|---|
setRole(name) | this | Set role. Alias to setData('role',name) |
setData(name,value) | this | Set value to variable. |
setData(array) | this | Set values from assoc array |
addData(array) | this | Add values from assoc array |
clearData() | this | Clear all data definitions. |
removeData(name) | this | Remove definition of certain value. |
getData(name) | mixed | Get value of var. |
getData() | array | Get all vars. |
getDataString() | string | Get data in: data-name=value -format |
Var can be used to save and retrieve values that are used
Method | Return | Description |
---|---|---|
setVar(name,value) | this | Set value to variable. |
setVar(array) | this | Set values from assoc array |
getVar(name) | mixed | Get value of var. |
getVar() | array | Get all vars. |