64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
|
|
module.exports = {
|
|
removeChilds(node) {
|
|
var childs = node.childNodes;
|
|
|
|
if (childs)
|
|
while (childs.length > 0)
|
|
node.removeChild(childs[0]);
|
|
},
|
|
|
|
remove(node) {
|
|
if (node.parentNode)
|
|
node.parentNode.removeChild(node);
|
|
},
|
|
|
|
setText(node, text) {
|
|
Vn.Node.removeChilds(node);
|
|
|
|
if (text)
|
|
node.appendChild(
|
|
node.ownerDocument.createTextNode(text));
|
|
},
|
|
|
|
addClass(node, className) {
|
|
/* var classes = node.className.split(' ');
|
|
|
|
if (classes.split(' ').indexOf(className) == -1)
|
|
*/ node.className = className +' '+ node.className;
|
|
},
|
|
|
|
removeClass(node, className) {
|
|
var index = 0;
|
|
var found = false;
|
|
var classes = node.className.split(' ');
|
|
|
|
while ((index = classes.indexOf(className, index)) != -1) {
|
|
classes.splice(index, 1);
|
|
found = true;
|
|
}
|
|
|
|
if (found)
|
|
node.className = classes.join(' ');
|
|
},
|
|
|
|
hide: function(node) {
|
|
node.style.display = 'none';
|
|
},
|
|
|
|
show: function(node) {
|
|
node.style.display = 'block';
|
|
},
|
|
|
|
disableInputs(formNode, disable = true) {
|
|
const inputs = formNode
|
|
.querySelectorAll('input, textarea, button, select');
|
|
for (const input of inputs)
|
|
input.disabled = disable;
|
|
}
|
|
};
|
|
|
|
$ = function(id) {
|
|
return document.getElementById(id);
|
|
}
|