hedera-web/web/js/vn/node.js

69 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-02-01 03:21:54 +00:00
Vn.Node =
{
removeChilds: function (node)
{
var childs = node.childNodes;
2015-07-07 15:27:47 +00:00
if (childs)
while (childs.length > 0)
node.removeChild (childs[0]);
}
,remove: function (node)
{
2015-07-07 15:27:47 +00:00
if (node.parentNode)
node.parentNode.removeChild (node);
}
,setText: function (node, text)
{
Vn.Node.removeChilds (node);
if (text)
node.appendChild (document.createTextNode (text));
}
2015-07-15 13:39:07 +00:00
,addClass: function (node, className)
{
/* var classes = node.className.split (' ');
if (classes.split (' ').indexOf (className) == -1)
*/ node.className = className +' '+ node.className;
}
,removeClass: function (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)
{
2015-08-17 18:02:14 +00:00
var style = window.getComputedStyle (node);
if (style.display === 'none')
node.style.display = 'initial';
}
};
2015-02-01 03:21:54 +00:00
function $ (id)
{
return document.getElementById (id);
}