hedera-web/js/vn/node.js

64 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-02-01 03:21:54 +00:00
module.exports = {
removeChilds(node) {
var childs = node.childNodes;
2015-07-07 15:27:47 +00:00
if (childs)
while (childs.length > 0)
node.removeChild(childs[0]);
},
remove(node) {
2015-07-07 15:27:47 +00:00
if (node.parentNode)
node.parentNode.removeChild(node);
},
setText(node, text) {
Vn.Node.removeChilds(node);
if (text)
node.appendChild(
node.ownerDocument.createTextNode(text));
},
2015-07-15 13:39:07 +00:00
addClass(node, className) {
/* var classes = node.className.split(' ');
2015-07-15 13:39:07 +00:00
if (classes.split(' ').indexOf(className) == -1)
2015-07-15 13:39:07 +00:00
*/ node.className = className +' '+ node.className;
},
2015-07-15 13:39:07 +00:00
removeClass(node, className) {
2015-07-15 13:39:07 +00:00
var index = 0;
var found = false;
var classes = node.className.split(' ');
2015-07-15 13:39:07 +00:00
while ((index = classes.indexOf(className, index)) != -1) {
classes.splice(index, 1);
2015-07-15 13:39:07 +00:00
found = true;
}
if (found)
node.className = classes.join(' ');
},
hide: function(node) {
node.style.display = 'none';
},
show: function(node) {
2015-09-22 07:20:47 +00:00
node.style.display = 'block';
},
disableInputs(formNode, disable = true) {
const inputs = formNode
.querySelectorAll('input, textarea, button, select');
for (const input of inputs)
input.disabled = disable;
}
};
2015-02-01 03:21:54 +00:00
$ = function(id) {
return document.getElementById(id);
2015-02-01 03:21:54 +00:00
}