org.javasimon.console.resource.js.javasimon-util.js Maven / Gradle / Ivy
"use strict";
var javasimon=window.javasimon||{};
window.javasimon=javasimon;
/**
* DOM Helper to create and append nodes to DOM tree
*/
javasimon.DOMUtil={
fnAppendChildElement:function(eParent, sName, oAttributes) {
var eChild=document.createElement(sName);
this.fnSetAttributes(eChild, oAttributes);
if (eParent) {
eParent.appendChild(eChild);
}
return eChild;
},
fnSetAttributes:function(eNode, oAttributes) {
if (oAttributes) {
for (var sAttributeName in oAttributes) {
eNode.setAttribute(sAttributeName, oAttributes[sAttributeName]);
}
}
},
fnAppendChildText:function(eParent,sText) {
var eChild=document.createTextNode(sText);
eParent.appendChild(eChild);
return eChild;
},
fnAppendChildImage:function(eParent,sSrc) {
return this.fnAppendChildElement(eParent,'img', {src: sSrc});
},
fnAppendLink:function(eParent, oAttributes) {
var eLink=this.fnAppendChildElement(eParent, "a", oAttributes);
if (oAttributes) {
var sLabel=oAttributes.label;
if (sLabel) {
this.fnAppendChildText(eLink, sLabel);
}
}
return eLink;
},
fnAppendLinkButton:function(eParent, oAttributes){
var eLink=this.fnAppendLink(eParent);
return $(eLink).button(oAttributes);
},
fnRemoveChildren:function(eParent) {
if (eParent.hasChildNodes()) {
var nChildCount=eParent.childNodes.length;
for(var i=0;i