projects
/
php-utility-classes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
69409dd
)
add shorthand functions to set/add classes and set IDs on elements
author
Robert Kaiser
<kairo@kairo.at>
Fri, 20 Apr 2018 19:40:27 +0000
(21:40 +0200)
committer
Robert Kaiser
<kairo@kairo.at>
Fri, 20 Apr 2018 19:40:27 +0000
(21:40 +0200)
classes/document.php-class
patch
|
blob
|
blame
|
history
diff --git
a/classes/document.php-class
b/classes/document.php-class
index f266fb073b022b3fdbcb3ae16edd5d4277fced4d..be9d1502ec1e58805329dc14b613f6fdce4f8b00 100755
(executable)
--- a/
classes/document.php-class
+++ b/
classes/document.php-class
@@
-612,6
+612,16
@@
class ExtendedElement extends DOMElement {
// public function appendJSFile($jsURL, [$defer], [$async])
// appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
// returns the new child
// public function appendJSFile($jsURL, [$defer], [$async])
// appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
// returns the new child
+ //
+ // public function setClass($classname)
+ // sets the 'class' attribute of the element to the given classname value
+ //
+ // public function addClass($classname)
+ // adds the given classname value to the space-separated list in the 'class' attribute
+ // returns the value of the 'class' attribute
+ //
+ // public function setID($elem_id)
+ // sets the 'id' attribute of the element to the given elem_id value
public function appendElement($name, $value = '') {
return $this->appendChild($this->ownerDocument->createElement($name, $value));
public function appendElement($name, $value = '') {
return $this->appendChild($this->ownerDocument->createElement($name, $value));
@@
-697,6
+707,19
@@
class ExtendedElement extends DOMElement {
public function appendJSFile($jsdata, $defer = false, $async = false) {
return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
}
public function appendJSFile($jsdata, $defer = false, $async = false) {
return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
}
+ public function setClass($classname) {
+ $this->setAttribute('class', $classname);
+ }
+ public function addClass($classname) {
+ $classval = $this->getAttribute('class');
+ if (strlen($classval)) { $classval .= ' '; }
+ $classval .= $classname;
+ $this->setClass($classval);
+ return $classval;
+ }
+ public function setID($elem_id) {
+ $this->setAttribute('id', $elem_id);
+ }
}
class ExtendedDocumentFragment extends DOMDocumentFragment {
}
class ExtendedDocumentFragment extends DOMDocumentFragment {