2017-01-09 23:54:14 +00:00
|
|
|
var AddToDOM = function (element, parent, overflowHidden)
|
2016-11-25 02:08:33 +00:00
|
|
|
{
|
|
|
|
if (overflowHidden === undefined) { overflowHidden = true; }
|
|
|
|
|
|
|
|
var target;
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
if (typeof parent === 'string')
|
|
|
|
{
|
|
|
|
// Hopefully an element ID
|
|
|
|
target = document.getElementById(parent);
|
|
|
|
}
|
|
|
|
else if (typeof parent === 'object' && parent.nodeType === 1)
|
|
|
|
{
|
|
|
|
// Quick test for a HTMLelement
|
|
|
|
target = parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback, covers an invalid ID and a non HTMLelement object
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
target = document.body;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (overflowHidden && target.style)
|
|
|
|
{
|
|
|
|
target.style.overflow = 'hidden';
|
|
|
|
}
|
|
|
|
|
|
|
|
target.appendChild(element);
|
|
|
|
|
|
|
|
return element;
|
2017-01-09 23:54:14 +00:00
|
|
|
};
|
2016-11-25 02:08:33 +00:00
|
|
|
|
|
|
|
module.exports = AddToDOM;
|