TinyMCE_DOMUtils.class.js
Summary
No overview generated for 'TinyMCE_DOMUtils.class.js'
TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) {
return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
};
TinyMCE_Engine.prototype.getElementsByAttributeValue = function(n, e, a, v) {
var i, nl = n.getElementsByTagName(e), o = new Array();
for (i=0; i<nl.length; i++) {
if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
o[o.length] = nl[i];
}
return o;
};
TinyMCE_Engine.prototype.isBlockElement = function(n) {
return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
};
TinyMCE_Engine.prototype.getParentBlockElement = function(n) {
while (n) {
if (this.isBlockElement(n))
return n;
n = n.parentNode;
}
return null;
};
TinyMCE_Engine.prototype.insertAfter = function(n, r){
if (r.nextSibling)
r.parentNode.insertBefore(n, r.nextSibling);
else
r.parentNode.appendChild(n);
};
TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
e.innerHTML = tinyMCE.uniqueTag + h;
e.firstChild.removeNode(true);
} else {
h = this.fixGeckoBaseHREFBug(1, e, h);
e.innerHTML = h;
this.fixGeckoBaseHREFBug(2, e, h);
}
};
TinyMCE_Engine.prototype.getOuterHTML = function(e) {
if (tinyMCE.isMSIE)
return e.outerHTML;
var d = e.ownerDocument.createElement("body");
d.appendChild(e);
return d.innerHTML;
};
TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
if (tinyMCE.isMSIE) {
e.outerHTML = h;
return;
}
var d = e.ownerDocument.createElement("body");
d.innerHTML = h;
e.parentNode.replaceChild(d.firstChild, e);
};
TinyMCE_Engine.prototype._getElementById = function(id) {
var e, i, j, f;
e = document.getElementById(id);
if (!e) {
f = document.forms;
for (i=0; i<f.length; i++) {
for (j=0; j<f[i].elements.length; j++) {
if (f[i].elements[j].name == id) {
e = f[i].elements[j];
break;
}
}
}
}
return e;
};
TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) {
var i;
if (typeof(t) == "undefined" || n.nodeType == t && (typeof(nn) == "undefined" || n.nodeName == nn))
na[na.length] = n;
if (n.hasChildNodes()) {
for (i=0; i<n.childNodes.length; i++)
tinyMCE.getNodeTree(n.childNodes[i], na, t, nn);
}
return na;
};
TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
if (typeof(names) == "undefined") {
if (node.nodeType == 1)
return node;
while ((node = node.parentNode) != null && node.nodeType != 1) ;
return node;
}
if (node == null)
return null;
var namesAr = names.toUpperCase().split(',');
do {
for (var i=0; i<namesAr.length; i++) {
if (node.nodeName == namesAr[i] || names == "*") {
if (typeof(attrib_name) == "undefined")
return node;
else if (node.getAttribute(attrib_name)) {
if (typeof(attrib_value) == "undefined") {
if (node.getAttribute(attrib_name) != "")
return node;
} else if (node.getAttribute(attrib_name) == attrib_value)
return node;
}
}
}
} while ((node = node.parentNode) != null);
return null;
};
TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
if (typeof(default_value) == "undefined")
default_value = "";
if (!elm || elm.nodeType != 1)
return default_value;
var v = elm.getAttribute(name);
if (name == "class" && !v)
v = elm.className;
if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "")
v = elm.src;
if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "")
v = elm.href;
if (name == "http-equiv" && tinyMCE.isMSIE)
v = elm.httpEquiv;
if (name == "style" && !tinyMCE.isOpera)
v = elm.style.cssText;
return (v && v != "") ? v : default_value;
};
TinyMCE_Engine.prototype.setAttrib = function(element, name, value, fix_value) {
if (typeof(value) == "number" && value != null)
value = "" + value;
if (fix_value) {
if (value == null)
value = "";
var re = new RegExp('[^0-9%]', 'g');
value = value.replace(re, '');
}
if (name == "style")
element.style.cssText = value;
if (name == "class")
element.className = value;
if (value != null && value != "" && value != -1)
element.setAttribute(name, value);
else
element.removeAttribute(name);
};
TinyMCE_Engine.prototype.setStyleAttrib = function(elm, name, value) {
eval('elm.style.' + name + '=value;');
if (tinyMCE.isMSIE && value == null || value == '') {
var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));
elm.style.cssText = str;
elm.setAttribute("style", str);
}
};
TinyMCE_Engine.prototype.switchClass = function(ei, c) {
var e;
if (tinyMCE.switchClassCache[ei])
e = tinyMCE.switchClassCache[ei];
else
e = tinyMCE.switchClassCache[ei] = document.getElementById(ei);
if (e) {
if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0)
c = 'mceTiledButton ' + c;
e.className = c;
}
};
TinyMCE_Engine.prototype.getAbsPosition = function(n) {
var p = {absLeft : 0, absTop : 0};
while (n) {
p.absLeft += n.offsetLeft;
p.absTop += n.offsetTop;
n = n.offsetParent;
}
return p;
};
Documentation generated by
JSDoc on Fri Feb 24 13:38:20 2006