// Name: HTMLEditor.HTMLEditor.debug.js // Assembly: AjaxControlToolkit // Version: 4.1.7.725 // FileVersion: 4.1.7.0725 Type.registerNamespace("Sys.Extended.UI.HTMLEditor"); Sys.Extended.UI.HTMLEditor.Trim = function(value) { return value.replace(/[\x00-\x1F]+/g,""); }; Sys.Extended.UI.HTMLEditor.TrimAll = function(value) { return value.replace(/[\x00-\x1F]/g,"").replace(/^[\x20]+/g,"").replace(/[\x20]+$/g,""); }; Sys.Extended.UI.HTMLEditor.isIE = (Sys.Browser.agent == Sys.Browser.InternetExplorer); Sys.Extended.UI.HTMLEditor.isSafari = (Sys.Browser.agent == Sys.Browser.Safari); Sys.Extended.UI.HTMLEditor.isOpera = (Sys.Browser.agent == Sys.Browser.Opera); Sys.Extended.UI.HTMLEditor.tryReplaceRgb = function(value) { var result = value; var re = /(rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\))/ig; function hex(d) { return (d < 16) ? ("0" + d.toString(16)) : d.toString(16); }; function repl($0,$1,$2,$3,$4) { var r = parseInt($2); var g = parseInt($3); var b = parseInt($4); return "#" + hex(r) + hex(g) + hex(b); } try { // some versions of Safari don't support such replace result = result.replace(re, repl); } catch(e){} return result; } Sys.Extended.UI.HTMLEditor._getScrollTop = function(win) { var doc = win.document; var scrollTop = 0; if (typeof (win.pageYOffset) == 'number') { scrollTop = win.pageYOffset; } if (doc.body && doc.body.scrollTop) { scrollTop = doc.body.scrollTop; } else if (doc.documentElement && doc.documentElement.scrollTop) { scrollTop = doc.documentElement.scrollTop; } return scrollTop; } Sys.Extended.UI.HTMLEditor._getScrollLeft = function(win) { var doc = win.document; var scrollLeft = 0; if (typeof (win.pageXOffset) == 'number') { scrollLeft = win.pageXOffset; } else if (doc.body && doc.body.scrollLeft) { scrollLeft = doc.body.scrollLeft; } else if (doc.documentElement && doc.documentElement.scrollLeft) { scrollLeft = doc.documentElement.scrollLeft; } return scrollLeft; } Sys.Extended.UI.HTMLEditor.addFormOnSubmit = function(handler, editPanel) { var form = window.theForm; if (window.theForm != null && typeof window.theForm != "undefined") { if (form.HTMLEditor_editPanels == null || typeof form.HTMLEditor_editPanels == "undefined") { form.originalOnSubmit_HTMLEditor = window.theForm.onsubmit; form.HTMLEditor_editPanels = []; window.theForm.onsubmit = Sys.Extended.UI.HTMLEditor.EditPanelsOnSubmit; if (window.__doPostBack != null && typeof window.__doPostBack != "undefined") { if (window.__doPostBack_HTMLEditor_original == null || typeof window.__doPostBack_HTMLEditor_original == "undefined") { window.__doPostBack_HTMLEditor_original = window.__doPostBack; window.__doPostBack = Sys.Extended.UI.HTMLEditor.EditPanelsOnPostBack; } } if (window.ValidatorGetValue != null && typeof window.ValidatorGetValue != "undefined") { if (window.ValidatorGetValue_HTMLEditor_original == null || typeof window.ValidatorGetValue_HTMLEditor_original == "undefined") { window.ValidatorGetValue_HTMLEditor_original = window.ValidatorGetValue; window.ValidatorGetValue = Sys.Extended.UI.HTMLEditor.ValidatorGetValue; } } } form.HTMLEditor_editPanels.push({ handler: handler, editPanel: editPanel }); } } Sys.Extended.UI.HTMLEditor.removeFormOnSubmit = function(handler) { var form = window.theForm; if (window.theForm != null && typeof window.theForm != "undefined") { var original = form.originalOnSubmit_HTMLEditor; if (form.HTMLEditor_editPanels != null && typeof form.HTMLEditor_editPanels != "undefined") { var newArr = []; for (var i = 0; i < form.HTMLEditor_editPanels.length; i++) { var cur = form.HTMLEditor_editPanels[i]; if (cur.handler != handler) { newArr.push(cur); } } form.HTMLEditor_editPanels = newArr; if (form.HTMLEditor_editPanels.length == 0) { window.theForm.onsubmit = original; form.originalOnSubmit_HTMLEditor = null; form.HTMLEditor_editPanels = null; if (window.__doPostBack_HTMLEditor_original != null && typeof window.__doPostBack_HTMLEditor_original != "undefined") { window.__doPostBack = window.__doPostBack_HTMLEditor_original; window.__doPostBack_HTMLEditor_original = null; } if (window.ValidatorGetValue_HTMLEditor_original != null && typeof window.ValidatorGetValue_HTMLEditor_original != "undefined") { window.ValidatorGetValue = window.ValidatorGetValue_HTMLEditor_original; window.ValidatorGetValue_HTMLEditor_original = null; } } } } } Sys.Extended.UI.HTMLEditor.EditPanelsOnSubmit = function(e) { var form = window.theForm; var ret = true; for (var i = 0; i < form.HTMLEditor_editPanels.length; i++) { var ret = form.HTMLEditor_editPanels[i].handler(e); if (!ret) break; } if (ret && form.originalOnSubmit_HTMLEditor != null && typeof form.originalOnSubmit_HTMLEditor != "undefined") { ret = form.originalOnSubmit_HTMLEditor(e); } if (!ret || !window.Page_IsValid) { for (var i = 0; i < form.HTMLEditor_editPanels.length; i++) { form.HTMLEditor_editPanels[i].editPanel._contentPrepared = false; } } return ret; } Sys.Extended.UI.HTMLEditor.ValidatorGetValue = function(id) { var component = $find(id); if (component != null) { var editPanel = null; if (Sys.Extended.UI.HTMLEditor.Editor.isInstanceOfType(component)) { editPanel = component.get_editPanel(); } else if (Sys.Extended.UI.HTMLEditor.EditPanel.isInstanceOfType(component)) { editPanel = component; } if (editPanel != null) { var content = editPanel._contentForValidation; if (content == null || typeof content == "undefined") { content = editPanel.get_content(); } return content; } } return window.ValidatorGetValue_HTMLEditor_original(id); } Sys.Extended.UI.HTMLEditor.EditPanelsOnPostBack = function(eventTarget, eventArgument) { var form = window.theForm; for(var i=0; i < form.HTMLEditor_editPanels.length; i++) { var ret = form.HTMLEditor_editPanels[i].handler(null); if(!ret) return false; } if (window.__doPostBack_HTMLEditor_original != null && typeof window.__doPostBack_HTMLEditor_original != "undefined") { return window.__doPostBack_HTMLEditor_original(eventTarget, eventArgument); } return true; } Sys.Extended.UI.HTMLEditor.getRealAttributeIE = function(element, name, source) { var value = source; var n_value = ""; function tempFunc(p0,p1) { n_value = p1; } element.outerHTML.replace(new RegExp("^(?:<[^>]*?"+name+"=\")([^\"]*?)\"","ig"),tempFunc); if (n_value == "") { element.outerHTML.replace(new RegExp("^(?:<[^>]*?"+name+"=')([^']*?)'","ig"),tempFunc); } if (n_value == "") { element.outerHTML.replace(new RegExp("^(?:<[^>]*?"+name+"=)([^\s>]*?)","ig"),tempFunc); } if (value != n_value && n_value != "") { value = n_value; value = value.replace(/&/g,"&"); } return value; } Sys.Extended.UI.HTMLEditor.getRealAttribute = function(element,name) { var searchName = name.toLowerCase(); var attrs = element.attributes; var value = ""; for (i = 0; i < attrs.length; ++i) { var a = attrs.item(i); if (!a.specified) continue; var name = a.name.toLowerCase(); if (name == searchName) { value = a.value; if (Sys.Extended.UI.HTMLEditor.isIE) { value = Sys.Extended.UI.HTMLEditor.getRealAttributeIE(element, name, value); } if (name == "src" || name == "href") value = value.replace(/(\(S\([A-Za-z0-9_]+\)\)\/)/,""); break; } } return value; } Sys.Extended.UI.HTMLEditor.enabledWordTags = [ "img", "strong", "p", "b", "i", "u", "a", "h1", "h2", "h3", "h4", "h5", "h6", "table", "tbody", "tr", "td", "ul", "ol", "li", "span", "div", "font", "xml", "del", "ins", "em", "sub", "sup", "hr", "br" ]; Sys.Extended.UI.HTMLEditor.cleanUp = function(html) { var old_ret; var ret = Sys.Extended.UI.HTMLEditor.Trim(html.replace(/[\x00-\x1F]+/g," ")) .replace(/^[^\u0000]+?]*?)>/gi,"").replace(/<\/html(?:[^>]*?)>[^\u0000]*$/gi,"") .replace(/
]*?)>[^\u0000]*?<\/head(?:[^>]*?)>/gi,"") .replace(/]*?>([^\u0000]*?)<\/body(?:[^>]*?)>/gi,"$1") .replace(/<\/?html(?:[^>]*?)>/gi,"") .replace(/<\/?head(?:[^>]*?)>/gi,"") .replace(/<\/?body(?:[^>]*?)>/gi,"") .replace(//ig,"") // remove comments .replace(/(<[\/]?)(?:o|v|x|p|w|\?xml):(\w+)([^>]*?>)/ig,"$1$2$3") // remove prefixes .replace(/<(IMAGEDATA)([^>]*?)>/ig,"]*>
<\/p><\/p>/ig,"
") // remove empty P
.replace(/
]*?\/>/ig,"").replace(/<(p|div)[^>]*?> <\/(\1)[^>]*?>/ig,"").replace(/<(p|div)[^>]*?><\/(\1)[^>]*?>/ig,"");
do {
old_ret = ret;
ret = ret.replace(/<([^>]*)(?:class|size|lang|face|start|type|border|[ovwxp]:\w+)=(?:\'[^\']*\'|\"[^\"]*\"|[^> ]+)([^>]*)>/ig, "<$1$2>");
}
while(ret != old_ret)
var div = document.createElement("div");
div.innerHTML = ret;
function diver(elem) {
var n = elem.childNodes.length;
for(var i=0; i
is added
.replace(/<\/(p|div)[^>]*?>/ig,"
");
do {
old_ret = ret;
ret = ret.replace(/<\/b>/ig,"").replace(/<\/i>/ig,"").replace(/<\/u>/ig,"").replace(/<\/strong>/ig,"").replace(/<\/em>/ig,"").replace(/<\/sub>/ig,"").replace(/<\/sup>/ig,"");
ret = ret.replace(/]*?><\/span>/ig,"").replace(/([^<]+?)<\/span>/ig,"$1");
ret = ret.replace(/]*?><\/font>/ig,"").replace(/([^<]+?)<\/font>/ig,"$1");
}
while(ret != old_ret)
ret = ret.replace(/’/g, "'")
.replace(/‘/g, "'")
.replace(/–/g, "-")
.replace(/—/g, "-")
.replace(/…/g, "...")
.replace(/"/g, "\"")
.replace(/“/g, "\"")
.replace(/”/g, "\"")
.replace(//g, "")
.replace(/•/g, "")
.replace(/[ \s]+/g," ").replace(/(( )+)/g," "); // remove extra spaces
if(document.all) ret = ret.replace(/^[\x00-\x1F]* /,"");
return ret;
};
Sys.Extended.UI.HTMLEditor.spanJoiner = function(element,doc, sFrom, sTo, nobr) {
var sIndex = 0;
var sLength = element.childNodes.length;
if(typeof sFrom != "undefined" && sFrom != null) sIndex = sFrom;
if(typeof sTo != "undefined" && sTo != null) sLength = sTo;
for(var i=sIndex; i < sLength && i < element.childNodes.length; i++) {
var child = element.childNodes.item(i)
if (child.parentNode != element) {
continue;
}
switch (child.nodeType) {
case 1: // Node.ELEMENT_NODE
if(child.childNodes.length==0 && Sys.Extended.UI.HTMLEditor.isStyleTag(child.tagName) && child.tagName.toUpperCase() != "A" && !(child.className.length > 0 || (child.getAttribute("class") && child.getAttribute("class").length > 0)) && !Sys.Extended.UI.HTMLEditor.isTempElement(child)) {
element.removeChild(child);
i--;
sLength--;
continue;
}
if( child.tagName.toUpperCase()=="SPAN") {
while(child.childNodes.length==1 && child.firstChild.nodeType==1) {
if(child.firstChild.tagName.toUpperCase()=="SPAN" && !Sys.Extended.UI.HTMLEditor.isTempElement(child.firstChild)) {
var attrs = Sys.Extended.UI.HTMLEditor.differAttr (child.firstChild,[]);
var styles = Sys.Extended.UI.HTMLEditor.differStyle(child.firstChild);
var oldSpan = child.firstChild;
var chieldren = oldSpan.childNodes;
while(oldSpan.firstChild != null) {
child.insertBefore(oldSpan.firstChild,oldSpan);
}
for(var j=0; j < styles.length; j++) {
if(styles[j][1]) {
try {
if(child.style[styles[j][0]]) {
if(styles[j][0].toLowerCase().indexOf("color") >= 0) {
child.style[styles[j][0]] = styles[j][1];
} else {
try {
var sv = child.style[styles[j][0]];
child.style[styles[j][0]] = child.style[styles[j][0]]+" "+styles[j][1];
if(sv == child.style[styles[j][0]]) {
child.style[styles[j][0]] = styles[j][1];
}
}
catch(e) {
child.style[styles[j][0]] = styles[j][1];
}
}
} else {
child.style[styles[j][0]] = styles[j][1];
}
} catch (ee) {}
}
}
for(var j=0; j < attrs.length; j++) {
if(attrs[j][1]) {
child.setAttribute(attrs[j][0],attrs[j][1]);
}
}
child.removeChild(oldSpan);
continue;
} else {
if(child.firstChild.tagName.toUpperCase()=="SPAN" && Sys.Extended.UI.HTMLEditor.isTempElement(child.firstChild)) {
var svv = child.firstChild;
child.parentNode.insertBefore(child.firstChild,child);
child.parentNode.removeChild(child);
child = svv;
}
}
break;
}
var tempArr = [];
var nextChild = child.nextSibling;
while(!Sys.Extended.UI.HTMLEditor.isTempElement(child) && nextChild && i+1 < sLength && (nextChild.nodeType == 3 || (nextChild.nodeType == 1 &&
(nextChild.tagName.toUpperCase()=="SPAN" || (nextChild.tagName.toUpperCase()=="BR") && typeof nobr == "undefined") &&
!Sys.Extended.UI.HTMLEditor.isTempElement(nextChild)))) {
if(nextChild.nodeType == 3) {
if((""+nextChild.data+"").length==0) {
nextChild.parentNode.removeChild(nextChild);
nextChild = child.nextSibling;
sLength--;
} else {
break;
}
}
else {
if(nextChild.tagName.toUpperCase()=="BR") {
tempArr.push(nextChild);
nextChild = nextChild.nextSibling;
} else {
var attrs = Sys.Extended.UI.HTMLEditor.differAttr (child,[], nextChild);
var styles = Sys.Extended.UI.HTMLEditor.differStyle(child, nextChild);
if(attrs.length==0 && styles.length==0 && child.className == nextChild.className) {
var n = tempArr.length;
for(var j=0; j < n; j++) {
child.appendChild(tempArr[j]);
sLength--;
}
tempArr = [];
while(nextChild.firstChild) child.appendChild(nextChild.firstChild);
nextChild.parentNode.removeChild(nextChild);
nextChild = child.nextSibling;
sLength--;
} else {
break;
}
}
}
}
if(!Sys.Extended.UI.HTMLEditor.isTempElement(child) && child.className.length == 0) {
var attrs = Sys.Extended.UI.HTMLEditor.differAttr (child,[]);
var styles = Sys.Extended.UI.HTMLEditor.differStyle(child );
if(attrs.length==0 && styles.length==0) {
i--;
sLength--;
while(child.firstChild) {
child.parentNode.insertBefore(child.firstChild,child);
sLength++;
}
child.parentNode.removeChild(child);
continue;
}
}
}
if(child.parentNode != null) {
if(child.childNodes.length==0 && Sys.Extended.UI.HTMLEditor.isStyleTag(child.tagName) && child.tagName.toUpperCase() != "A" && !(child.className.length > 0 || (child.getAttribute("class") && child.getAttribute("class").length > 0)) && !Sys.Extended.UI.HTMLEditor.isTempElement(child)) {
element.removeChild(child);
i--;
sLength--;
continue;
} else {
Sys.Extended.UI.HTMLEditor.spanJoiner(child,doc);
}
}
break;
}
}
};
Sys.Extended.UI.HTMLEditor._styleTags = [
"strong",
"em",
"u",
"strike",
"s",
"span",
"font",
"b",
"sub",
"sup",
"a",
"i"
];
Sys.Extended.UI.HTMLEditor.isStyleTag = function(tag) {
if(!tag) return false;
for(var i=0; i< Sys.Extended.UI.HTMLEditor._styleTags.length; i++) {
if(Sys.Extended.UI.HTMLEditor._styleTags[i].toLowerCase()==tag.toLowerCase()) return true;
}
return false;
};
Sys.Extended.UI.HTMLEditor.smartClassName = "MSIEparagraph";
Sys.Extended.UI.HTMLEditor.noContextMenuAttribute= "obout-no-contextmenu";
Sys.Extended.UI.HTMLEditor.isTempElement = function(el) {
if(el.id && el.id.length > 0 && el.id.indexOf(Sys.Extended.UI.HTMLEditor.smartClassName) >= 0) return true;
return false;
};
Sys.Extended.UI.HTMLEditor.differAttr = function(element,pr, comp) {
var result = [];
var parent = element.parentNode;
if(typeof comp != "undefined") parent = comp;
if(!parent || !parent.tagName || !Sys.Extended.UI.HTMLEditor.isStyleTag(parent.tagName)) parent = null;
if(element.attributes)
for (var i=0; i < element.attributes.length; i++) {
var attr = element.attributes[i];
var brk=false;
for(var j=0; j < pr.length; j++) {
if(attr.name.toUpperCase() == pr[j].toUpperCase()) {
brk=true;
break;
}
}
if(brk) continue;
if(attr.name.toUpperCase() == "STYLE") continue;
if(attr.name.toUpperCase().substr(0,4) == "_MOZ") continue;
if(attr.specified)
if(parent && parent.attributes && parent.attributes[attr.name]) {
var pattr= parent.attributes[attr.name];
if(pattr) {
if(attr.name != pattr.name || attr.value != pattr.value) {
result.push([attr.name, attr.value]);
}
}
} else {
if(attr.name.toUpperCase() == "CLASS" && attr.value =="") continue;
result.push([attr.name, attr.value]);
}
}
return result;
};
Sys.Extended.UI.HTMLEditor.differStyle = function(element, comp) {
var result = [];
var parent = element.parentNode;
if(typeof comp != "undefined") parent = comp;
if(!parent || !parent.tagName || !Sys.Extended.UI.HTMLEditor.isStyleTag(parent.tagName)) parent = null;
function _putStyle(i,_style) {
_style=""+_style;
if(i.toLowerCase()=="textdecoration") {
var _arr = _style.split(" ");
for(var j=0; j<_arr.length; j++) {
result.push([i, Sys.Extended.UI.HTMLEditor.Trim(_arr[j])]);
}
} else {
result.push([i, _style]);
}
}
for (var i in element.style) {
if(i && typeof i == "string" && i != "accelerator") {
var ii = i;
if(!isNaN(parseInt(i))) {
if(!Sys.Extended.UI.HTMLEditor.isSafari) {
continue;
}
ii = element.style[i];
}
var style = element.style[ii];
if(style && typeof style == "string" && style != "accelerator") {
if(parent && parent.style) {
var pstyle= parent.style [ii];
if(ii.toLowerCase() != "csstext" && ii.toLowerCase() != "length")
if(style != pstyle) {
_putStyle(ii, style);
}
} else {
if(ii.toLowerCase() != "csstext" && ii.toLowerCase() != "length") {
_putStyle(ii, style);
}
}
}
}
}
if(typeof comp != "undefined")
for (var i in parent.style) {
if(i && typeof i == "string" && i != "accelerator") {
var ii = i;
if(!isNaN(parseInt(i))) {
if(!Sys.Extended.UI.HTMLEditor.isSafari) {
continue;
}
ii = element.style[i];
}
var style = parent.style[ii];
if(style && typeof style == "string" && style != "accelerator") {
var pstyle= element.style [ii];
if(i.toLowerCase() != "csstext" && ii.toLowerCase() != "length")
if(style != pstyle) {
_putStyle(ii, style);
}
}
}
}
return result;
};
Sys.Extended.UI.HTMLEditor.brXHTML = function(str) {
return str.replace(/
/ig, "
");
};
Sys.Extended.UI.HTMLEditor._needsClosingTag = function(el) {
var closingTags = " script style div span a del strong em u strike font b sub sup p iframe li ul ol placeholder textarea td tr ";
return (closingTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1);
};
Sys.Extended.UI.HTMLEditor._encodeText_ = function(str) {
return str.replace(/&/ig, "&").replace(//ig, ">").replace(/\"/ig, """).replace(/\xA0/ig, " ");
};
Sys.Extended.UI.HTMLEditor._noNeedsClosingTag = function(el) {
var closingTags = " hr br ";
return (closingTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1);
};
Sys.Extended.UI.HTMLEditor.canBeInsideP = function(el,prize)
{
if(el && el.style && el.style.display && el.style.display.toLowerCase()=="inline") return true;
var name = el.tagName.toUpperCase();
if(name.length==2) {
if(name.substr(0,1)=="H" && parseInt(name.substr(1,1)) > 0) {
return false;
}
}
switch(name) {
case "TBODY" :
case "TR" :
case "TD" :
if(typeof prize != "undefined") {
var par = el.parentNode;
while(par && par.tagName && par.tagName.toUpperCase() != "TABLE") par = par.parentNode;
if(par.tagName.toUpperCase() == "TABLE" && par.style && par.style.display && par.style.display.toLowerCase() == "inline") {
return true;
}
}
case "P" :
case "PRE" :
case "TABLE" :
case "OL" :
case "UL" :
case "LI" :
case "HR" :
case "DIV" :
case "BLOCKQUOTE" :
case "FORM" :
case "FIELDSET" :
case "LEGEND" :
return false;
default:
return true;
}
};
Sys.Extended.UI.HTMLEditor.convertAlign = function(aval) {
var value;
var n;
try { n = parseInt(aval)-1;}
catch(e){return aval;}
switch(n) {
case 1:
value = "left";
break;
case 2:
value = "right";
break;
case 3:
value = "texttop";
break;
case 4:
value = "absmiddle";
break;
case 5:
value = "baseline";
break;
case 6:
value = "absbottom";
break;
case 7:
value = "bottom";
break;
case 8:
value = "middle";
break;
case 9:
value = "top";
break;
default:
value = aval.replace(/\"/g,""");
}
return value;
};
Sys.Extended.UI.HTMLEditor.getHTML = function(root, outputRoot, must)
{
try {
if(typeof must == "undefined") {
if(!outputRoot && root.nodeType==1) {
return root.innerHTML;
} else {
if(outputRoot && root.nodeType==1 && Sys.Extended.UI.HTMLEditor.isIE) {
return root.outerHTML;
}
}
}
} catch(e){}
var html = new Sys.Extended.UI.HTMLEditor.jsDocument(true);
Sys.Extended.UI.HTMLEditor._getHTML_(html, root, outputRoot);
return html.toString();
};
Sys.Extended.UI.HTMLEditor._getHTML_ = function(html, root, outputRoot, must)
{
switch (root.nodeType) {
case 1: // Node.ELEMENT_NODE
case 11: // Node.DOCUMENT_FRAGMENT_NODE
if(root.tagName && root.tagName.indexOf("/") >= 0) {
if(Sys.Extended.UI.HTMLEditor.isIE) {
var tag = root.tagName.toLowerCase().substr(root.tagName.indexOf("/")+1);
var prev = root.previousSibling;
if(tag == "embed") return;
while(prev != null) {
if(prev.nodeType == root.nodeType && prev.tagName && prev.tagName.toLowerCase() == tag) {
html.append("");
return;
}
prev = prev.previousSibling;
}
}
return;
}
var closed;
var noSlash;
var i;
if (outputRoot && root.tagName.length >0) {
var tag = root.tagName.toLowerCase();
closed = (!(root.hasChildNodes() || Sys.Extended.UI.HTMLEditor._needsClosingTag(root)));
noSlash= true;
var scope = "";
if(Sys.Extended.UI.HTMLEditor.isIE && root.scopeName && typeof root.scopeName != "undefined") {
scope = (root.scopeName.toUpperCase()=="HTML")?"":(root.scopeName+":");
}
if(Sys.Extended.UI.HTMLEditor.isIE && (closed || tag == "placeholder") && !Sys.Extended.UI.HTMLEditor._noNeedsClosingTag(root) && tag !="embed") {
var next = root.nextSibling;
while(next != null) {
if(next.nodeType == root.nodeType && next.tagName) {
var nextTagName = next.tagName;
if(nextTagName.indexOf("/") >= 0)
if(nextTagName.toLowerCase().substr(nextTagName.indexOf("/")+1) == tag) {
closed = false;
noSlash= false;
break;
}
}
next = next.nextSibling;
}
}
if(!Sys.Extended.UI.HTMLEditor.canBeInsideP(root)) {
html.append("\n");
}
html.append("<"+((!closed && !noSlash)?"teo"+Sys.Extended.UI.HTMLEditor.smartClassName+":":scope)+ tag);
if(Sys.Extended.UI.HTMLEditor.isIE && root.name && root.name.length > 0) {
html.append(" name=\"" + root.name.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.value && root.value.length > 0 && tag != "textarea") {
html.append(" value=\"" + root.value.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.className && root.className.length > 0) {
html.append(" class=\"" + root.className.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.align && root.align.length > 0) {
html.append(" align=\"" + root.align.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.color && root.color.length > 0) {
html.append(" color=\"" + root.color.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.size && root.size.length > 0 && root.size != "+0") {
html.append(" size=\"" + root.size.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.shape && root.shape.length > 0) {
html.write(" shape" + '="' + root.shape.replace(/\"/g,""") + '"');
}
if(Sys.Extended.UI.HTMLEditor.isIE && root.coords && root.coords.length > 0) {
html.write(" coords" + '="' + root.coords.replace(/\"/g,""") + '"');
}
var attrs = root.attributes;
var cssForSafari = null;
for (i = 0; i < attrs.length; ++i) {
var a = attrs.item(i);
if (!a.specified) continue;
var name = a.name.toLowerCase();
if (name.substr(0, 4) == "_moz") {
continue;
}
if (name == "teoalign") {
continue;
}
var value;
if (name != 'style') {
if(name=='width') {
value= root.width;
if(Sys.Extended.UI.HTMLEditor.isIE && value == 0) {
var n_value = 0;
root.outerHTML.replace(new RegExp("^(?:<[^>]*?width=)([\\d]+)","ig"),function(p0,p1){n_value = p1;});
if(value != n_value) value = n_value;
}
}
else
if(name=='height') {
value= root.height;
if(Sys.Extended.UI.HTMLEditor.isIE && value == 0) {
var n_value = 0;
root.outerHTML.replace(new RegExp("^(?:<[^>]*?height=)([\\d]+)","ig"),function(p0,p1){n_value = p1;});
if(value != n_value) value = n_value;
}
}
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='name' && root.name && root.name.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='value' && root.value && root.value.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='align' && root.align && root.align.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='class' && root.className && root.className.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='color' && root.color && root.color.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='size' && root.size && root.size.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='shape' && root.shape && root.shape.length > 0 )
continue;
else
if(Sys.Extended.UI.HTMLEditor.isIE && name=='coords' && root.coords && root.coords.length > 0 )
continue;
else {
if(tag=="embed" && name=="align" && (Sys.Extended.UI.HTMLEditor.isIE)) {
value = Sys.Extended.UI.HTMLEditor.convertAlign(a.value);
}
else {
value = a.value;
if(Sys.Extended.UI.HTMLEditor.isSafari && name == "class") {
if(/apple-style/ig.test(value)) {
continue;
}
}
if(name == "src" || name == "href") {
if (Sys.Extended.UI.HTMLEditor.isIE) {
value = Sys.Extended.UI.HTMLEditor.getRealAttributeIE(root, name, value);
}
value = value.replace(/(\(S\([A-Za-z0-9_]+\)\)\/)/,"");
}
value = value.replace(/\"/g,""");
}
}
} else {
if(Sys.Extended.UI.HTMLEditor.isSafari) {
cssForSafari = a.value;
}
continue;
}
var qchar = "\"";
if((""+value+"").indexOf("\"") >= 0) qchar="'";
if(name != null) html.append(" " + name + '=' + qchar + value + qchar);
}
if(root.style.cssText.length > 0 || cssForSafari != null) {
var name = "style";
var re1 = /(url\((?:[^\)]*)\))/ig;
var urls = [];
function f2($0,$1) {
urls.push($1);
}
var value = ((cssForSafari !=null)?cssForSafari:root.style.cssText).toLowerCase();
value.replace(re1, f2);
var times = 0;
function f3() {
var temp = urls[times];
times++;
return temp;
}
value = Sys.Extended.UI.HTMLEditor.tryReplaceRgb(value.replace(re1, f3)).replace(/(font-weight\s*:\s*)(700)/ig, "$1bold")
.replace(/([\s]*-moz-[^;]*[;][\s]*)/ig, "").replace(/(-moz-.*)$/i, "")
.replace(/(background-position: 0% 0%[;]*[\s]*)/ig, "");
if(Sys.Extended.UI.HTMLEditor.isSafari) {
function repSaf($0,$1,$2,$3) {
return $1+$2.replace(/(,)/g,"")+$3;
}
value = value.replace(/(text-decoration:)([^;$]+)([;$])/ig, repSaf);
}
if(Sys.Extended.UI.HTMLEditor.isSafari || Sys.Extended.UI.HTMLEditor.isOpera) {
function repSafOp($0,$1,$2,$3) {
return $1+$2.replace(/(['"])/g,"")+$3;
}
value = value.replace(/(font-family:)([^;]+)([;]*)/ig, repSafOp);
}
if(value.length > 0) {
var qchar = "\"";
if((""+value+"").indexOf("\"") >= 0) qchar="'";
html.append(" " + name + '=' + qchar + value + qchar);
}
}
html.append(closed ? " />" : ">");
if(tag=="br") html.append("\n");
}
if(root.tagName && root.tagName.toUpperCase()=="SCRIPT") html.append(root.text);
if(root.tagName && root.tagName.toUpperCase()=="STYLE") {
html.append(root.innerHTML);
} else {
for (i = root.firstChild; i; i = i.nextSibling) {
Sys.Extended.UI.HTMLEditor._getHTML_(html,i, true)
}
}
if (outputRoot && root.tagName.length >0 && !closed && noSlash) {
html.append("" + scope + root.tagName.toLowerCase() + ">");
}
break;
case 3: // Node.TEXT_NODE
html.append(Sys.Extended.UI.HTMLEditor._encodeText_(""+root.data+""));
break;
case 8: // Node.COMMENT_NODE
if(root.length > 0) {
html.append("");
} else { // IE bug tricking (negative lengths happen there)
html.append("");
}
break;
}
};
Sys.Extended.UI.HTMLEditor.RemoveContextMenu = function() {
var editor = this;
var hhh=editor._contextElement.parentNode.removeChild(editor._contextElement);
if (hhh) delete hhh;
editor._contextElement=null;
editor._contextTable=null;
if (editor.__saved_range__){
editor.__saved_range__.select();
editor.__saved_range__=null;
}
};
Sys.Extended.UI.HTMLEditor.contentEditable = function(el, prize) {
while(el != null) {
try {
var mean = null;
if(el.contentEditable != null && typeof el.contentEditable != "undefined" && !(Sys.Extended.UI.HTMLEditor.isSafari || Sys.Extended.UI.HTMLEditor.isOpera)) {
if(!el.contentEditable || el.contentEditable=="false") {
mean = false;
} else {
mean = true;
}
}
else {
var value = el.getAttribute("contenteditable");
if(typeof value == "boolean") {
mean = value;
} else {
if(typeof value == "string" && value.toLowerCase()=="false") {
mean = false;
}
}
}
if(mean != null && typeof mean == "boolean") {
if(!mean) {
return el;
}
}
} catch(ex) {}
if(typeof prize != "undefined" && prize) {
return null;
}
if(el.tagName != null && typeof el.tagName != "undefined" && (el.tagName.toUpperCase()=="BODY" || el.tagName.toUpperCase()=="HTML")) {
break;
}
el = el.parentNode;
}
return null;
};
Sys.Extended.UI.HTMLEditor.getSelParent = function (editor) {
var sel = editor._getSelection();
var range = editor._createRange(sel);
var parent = null;
if(Sys.Extended.UI.HTMLEditor.isIE) {
if(sel.type.toLowerCase()=="control")
parent =range.item(0);
else
parent= editor._getParent(range);
} else {
parent= editor._getParent(range);
if(parent.nodeType != 3 && range.startContainer==range.endContainer) {
var p=parent;
parent = parent.childNodes.item(range.startOffset);
if(parent==null) parent=p;
}
}
return parent;
};
Sys.Extended.UI.HTMLEditor.__getIndex = function(el) {
var ind =0;
if(el.parentNode) {
for(;ind)/ig,regRepl);
return mArr;
};
Sys.Extended.UI.HTMLEditor.setImagesText = function(el,mArr) {
var aList = el.getElementsByTagName("IMG");
var k=0;
for(var i=0; i < aList.length; i++) {
if(!aList[i].src) {
continue;
}
if(mArr[k] && mArr[k].length > 0) {
aList[i].src = mArr[k].replace(/&/ig,"&");
}
k++;
}
};
Sys.Extended.UI.HTMLEditor.canHaveChildren = function(elem) {
if(Sys.Extended.UI.HTMLEditor.isIE) {
return elem.canHaveChildren;
} else {
return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(elem.tagName.toLowerCase());
}
};
Sys.Extended.UI.HTMLEditor._setCursor = function(el1,editor) {
var el = el1;
if(Sys.Extended.UI.HTMLEditor.isIE) {
var sel = editor._getSelection();
var range=editor._createRange(sel);
if(sel.type.toLowerCase() == "control") {
range.remove(0);
sel.empty();
range = editor._createRange();
}
var isText = (el.nodeType==3);
var span;
if(isText)
{
span = editor._doc.createElement("SPAN");
span.innerHTML = " ";
el.parentNode.insertBefore(span,el);
el = span;
}
var location = $common.getLocation(el);
var _left = location.x, _top = location.y;
if(isText) {
span.parentNode.removeChild(span);
}
try {
range.moveToPoint(_left,_top);
} catch(e) {}
range.select();
} else {
var sel = editor._getSelection();
var range=editor._createRange();
range.setStart(el, 0);
range.setEnd(el, 0);
editor._removeAllRanges(sel);
editor._selectRange(sel,range);
editor.focusEditor();
}
};
Sys.Extended.UI.HTMLEditor.myClone = function(el,doc,prize) {
var ela;
if(Sys.Extended.UI.HTMLEditor.isIE && el.tagName && (el.tagName.toUpperCase()=="EMBED" || el.tagName.toUpperCase()=="OBJECT")) {
var div = doc.createElement("DIV");
try {
div.innerHTML = el.outerHTML;
ela = div.firstChild;
} catch(e) {
ela = el;
}
delete div;
} else {
ela = el.cloneNode(prize);
}
return ela;
};
Sys.Extended.UI.HTMLEditor.unStyle = function(el) {
var _prn = (el.parentNode != null && typeof el.parentNode != "undefined")?el.parentNode:null;
if(_prn) {
var _fnd = null;
while ( _prn && _prn.tagName && _prn.tagName.toUpperCase() != "BODY" && Sys.Extended.UI.HTMLEditor.isStyleTag(_prn.tagName) &&
(_prn.tagName.toUpperCase() != "A")) {
_fnd = _prn;
_prn = _prn.parentNode;
}
if(_fnd) {
function diver(add,el, rpr, before, prize) {
var par=rpr.cloneNode(false);
if(add) {
if(add.push && typeof add.push == "function") {
for(var iii=0; iii < add.length; iii++) {
par.appendChild(add[iii]);
}
} else {
par.appendChild(add);
}
}
if(prize) {
par.appendChild(el);
} else {
while(el) {
var elSibling=before?el.previousSibling:el.nextSibling;
if(el.nodeType==1 || (el.nodeType==3 && Sys.Extended.UI.HTMLEditor.Trim(""+el.data+"").length>0)) {
if(el.nodeType==1) {
if(el.tagName && Sys.Extended.UI.HTMLEditor.isStyleTag(el.tagName) && el.childNodes.length==0 && !Sys.Extended.UI.HTMLEditor.isTempElement(el)) {
el=null;
}
}
if(el) {
if(par.childNodes.length == 0 || !before) {
par.appendChild(el);
} else {
par.insertBefore(el,par.firstChild);
}
}
}
el=elSibling;
}
}
if(par.childNodes.length==0) {
delete par;
par=null;
}
else if(par.childNodes.length==1 && par.firstChild.nodeType==3 && (""+par.firstChild.data+"").length==0) {
delete par;
par=null;
} else {
if(!prize && par.tagName && Sys.Extended.UI.HTMLEditor.isStyleTag(par.tagName) && (par.tagName.toUpperCase() != "A") && !Sys.Extended.UI.HTMLEditor.isTempElement(par)) {
var elNumber = par.childNodes.length;
for(var cnt=0; cnt< par.childNodes.length; cnt++) {
var inn = par.childNodes.item(cnt);
if(inn.nodeType==1 && inn.tagName && !Sys.Extended.UI.HTMLEditor.isStyleTag(inn.tagName) &&
(inn.tagName.toUpperCase()=="BR" || inn.tagName.toUpperCase()=="TABLE" ||
Sys.Extended.UI.HTMLEditor.isTempElement(inn))) {
elNumber--;
}
}
if(elNumber == 0) {
var parr = [];
while(par.firstChild) {
var inn = par.removeChild(par.firstChild);
parr.push(inn);
}
par = parr;
}
}
}
if(rpr==_fnd) {
return par;
} else {
if(!prize) {
return diver(par,before?rpr.previousSibling:rpr.nextSibling,rpr.parentNode,before,prize);
} else {
return diver(null,par,rpr.parentNode,before,prize);
}
}
};
_prn = el.parentNode;
if( el.previousSibling == null && el.nextSibling == null &&
_prn && _prn.tagName && _prn.tagName.toUpperCase() != "BODY" && Sys.Extended.UI.HTMLEditor.isStyleTag(_prn.tagName) &&
Sys.Extended.UI.HTMLEditor.differAttr(_prn,["class","color","face","size"]).length > 0) {
el = _prn;
}
var p1 = diver(null,el.previousSibling,el.parentNode,true , false);
var p2 = diver(null,el.nextSibling ,el.parentNode,false, false);
var par = _fnd.parentNode;
if(p1) {
if(p1.push && typeof p1.push == "function") {
for(var iii=0; iii < p1.length; iii++) {
par.insertBefore(p1[iii],_fnd);
}
} else {
par.insertBefore(p1,_fnd);
}
}
if(el.nodeType==1 && el.tagName &&
(el.tagName.toUpperCase()=="BR" || el.tagName.toUpperCase()=="TABLE" ||
Sys.Extended.UI.HTMLEditor.isTempElement(el))) {
par.insertBefore(el,_fnd);
} else {
var p3 = diver(null,el,el.parentNode,false, true);
par.insertBefore(p3,_fnd);
}
if(p2) {
if(p2.push && typeof p2.push == "function") {
for(var iii=0; iii < p2.length; iii++) {
par.insertBefore(p2[iii],_fnd);
}
} else {
par.insertBefore(p2,_fnd);
}
}
par.removeChild (_fnd);
}
}
};
Sys.Extended.UI.HTMLEditor.isTempElement = function(el) {
if(el.id && el.id.length > 0 && el.id.indexOf(Sys.Extended.UI.HTMLEditor.smartClassName) >= 0) {
return true;
}
return false;
};
Sys.Extended.UI.HTMLEditor._moveTagsUp = function(lBound,rBound) {
function _dive(next) {
if(!Sys.Extended.UI.HTMLEditor.isInlineElement(next) || next.nodeType == 3) {
Sys.Extended.UI.HTMLEditor.unStyle(next);
} else if(next.tagName && Sys.Extended.UI.HTMLEditor.isStyleTag(next.tagName) && (next.tagName.toUpperCase() != "A") && !Sys.Extended.UI.HTMLEditor.isTempElement(next)) {
var nnn = next.firstChild;
while(nnn != null) {
var nnnNext = nnn.nextSibling;
_dive(nnn);
nnn = nnnNext;
}
}
}
var next = lBound;
while(next != null && next != rBound) {
var nextSibling = next.nextSibling;
_dive(next);
next = nextSibling;
}
};
Sys.Extended.UI.HTMLEditor._commonTotalParent = function(first,last) {
var ret = null;
var par = first.parentNode;
var fst = first;
while (par) {
if(par.tagName && !Sys.Extended.UI.HTMLEditor.isStyleTag(par.tagName)) {
var indexLast = Sys.Extended.UI.HTMLEditor._lookChild(par,last);
if(indexLast >=0 ) {
var indexFirst = 0;
for(var i=0; i < par.childNodes.length; i++) {
if(par.childNodes.item(i) == fst) {
indexFirst = i;
break;
}
}
return {parent: par, indexFirst: indexFirst, indexLast: indexLast};
}
}
fst = par;
par = par.parentNode;
}
return ret;
};
Sys.Extended.UI.HTMLEditor._commonParent = function(first,last) {
var ret = null;
var par = first.parentNode;
var fst = first;
while (par && par.tagName.toUpperCase() != "BODY" && Sys.Extended.UI.HTMLEditor.isStyleTag(par.tagName)) {
var indexLast = Sys.Extended.UI.HTMLEditor._lookChild(par,last);
if(indexLast >=0 ) {
var indexFirst = 0;
for(var i=0; i < par.childNodes.length; i++) {
if(par.childNodes.item(i) == fst) {
indexFirst = i;
break;
}
}
return {parent: par, indexFirst: indexFirst, indexLast: indexLast};
}
fst = par;
par = par.parentNode;
}
return ret;
};
Sys.Extended.UI.HTMLEditor.positionInParagraph = function(marker,el,left,par,wordBound) {
while(true){
var result = Sys.Extended.UI.HTMLEditor.positionInParagraphLevel(marker,el,left,wordBound);
if(result != null) {
return result;
}
if(par.tagName && Sys.Extended.UI.HTMLEditor.isStyleTag(par.tagName) && (par.tagName.toUpperCase() != "A") && !Sys.Extended.UI.HTMLEditor.isTempElement(par)) {
el = left?par.previousSibling:par.nextSibling;
par = par.parentNode;
} else {
if(!left || par.firstChild == null) {
par.appendChild(marker);
} else {
par.insertBefore(marker,par.firstChild);
}
return marker;
}
}
};
Sys.Extended.UI.HTMLEditor.positionInParagraphLevel = function(marker,el,left,wordBound) {
while(el) {
var elSibling = left?el.previousSibling:el.nextSibling;
if(!Sys.Extended.UI.HTMLEditor.isInlineElement(el)) {
var par = el.parentNode;
if(!left) {
par.insertBefore(marker,el);
} else{
if(el.nextSibling) {
par.insertBefore(marker,el.nextSibling);
} else {
par.appendChild (marker);
}
}
return marker;
}
else if(typeof wordBound == "function" && el.nodeType==3) {
var j;
var str = ""+el.data+"";
if(left) {
for(j=str.length-1; j >= 0; j--) {
if(wordBound(str.substr(j,1))) {
break;
}
}
} else {
for(j=0; j < str.length; j++) {
if(wordBound(str.substr(j,1))) {
break;
}
}
}
if(j >= 0 && j < str.length) {
var par = el.parentNode;
var newNode;
if((j > 0 || (left && j==0)) && (j < str.length-1 || (!left && j==str.length-1))) {
if(left) {
newNode = el.splitText(j+1);
} else {
newNode = el.splitText(j);
}
par.insertBefore(marker,newNode);
} else {
if(!left) {
par.insertBefore(marker,el);
} else {
if(el.nextSibling) {
par.insertBefore(marker,el.nextSibling);
} else {
par.appendChild (marker);
}
}
}
return marker;
}
}
el = left?el.lastChild:el.firstChild;
if(el) {
var result = Sys.Extended.UI.HTMLEditor.positionInParagraphLevel(marker,el,left,wordBound);
if(result != null) {
return result;
}
}
el=elSibling;
}
return null;
};
Sys.Extended.UI.HTMLEditor._addEvent = function(el, evname, func){
if(el.attachEvent)
el.attachEvent("on" + evname, func);
else if(el.addEventListener)
el.addEventListener(evname, func, true);
};
Sys.Extended.UI.HTMLEditor._addEvents = function(el, evs, func) {
for(var i=0; i < evs.length; i++)
Sys.Extended.UI.HTMLEditor._addEvent(el, evs[i], func);
};
Sys.Extended.UI.HTMLEditor._removeEvent = function(el, evname, func) {
if(el.detachEvent)
el.detachEvent("on" + evname, func);
else if(el.removeEventListener)
el.removeEventListener(evname, func, true);
};
Sys.Extended.UI.HTMLEditor._removeEvents = function(el, evs, func) {
for(var i=0; i < evs.length; i++)
Sys.Extended.UI.HTMLEditor._removeEvent(el, evs[i], func);
};
Sys.Extended.UI.HTMLEditor._stopEvent = function(ev) {
if(ev) {
if (Sys.Extended.UI.HTMLEditor.isIE) {
ev.cancelBubble = true;
ev.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
}
};
Sys.Extended.UI.HTMLEditor.restrictedTags = ["DIV","P","TD","TR","TABLE","TBODY","LI","OL","UL","FORM","INPUT"]; // this list can be increased
Sys.Extended.UI.HTMLEditor.isRestricted = function(element) {
var elementTagName = element.tagName.toUpperCase();
for(var i=0; i < Sys.Extended.UI.HTMLEditor.restrictedTags.length; i++) {
if (Sys.Extended.UI.HTMLEditor.restrictedTags[i].toUpperCase() == elementTagName) {
return true;
}
}
if(Sys.Extended.UI.HTMLEditor.isIE && element.scopeName.toUpperCase()!="HTML") {
return true;
}
return false;
};
Sys.Extended.UI.HTMLEditor.jsDocument = function(noExtraLf) {
this.noExtraLf = (typeof noExtraLf != "undefined" && noExtraLf);
this.text = []; //array to store the string
this.write = function (str) {
if(!this.noExtraLf || (this.text.length == 0 && str != "\n") || (this.text.length > 0 && (this.text[this.text.length-1] != "\n" || str != "\n"))) {
this.text[this.text.length] = str;
}
};
this.append = this.write;
this.writeln = function (str) { this.text[this.text.length] = str + "\n"; }
this.toString = function () { return this.text.join(""); }
this.clear = function () { delete this.text; this.text = null; this.text = new Array; }
};
Sys.Extended.UI.HTMLEditor.isHeader = function(el) {
var name = el.tagName.toUpperCase();
if(name.length==2) {
if(name.substr(0,1)=="H" && parseInt(name.substr(1,1)) > 0) {
return true;
}
}
return false;
};
Sys.Extended.UI.HTMLEditor._getReallyFirst = function(root) {
if(typeof root.firstChild != "undefined" && root.firstChild != null) {
if(typeof root.firstChild.childNodes != "undefined" && root.firstChild.childNodes != null) {
return Sys.Extended.UI.HTMLEditor._getReallyFirst(root.firstChild)
}
}
return root;
};
Sys.Extended.UI.HTMLEditor._getReallyLast = function(root) {
if(typeof root.lastChild != "undefined" && root.lastChild != null) {
if(typeof root.lastChild.childNodes != "undefined" && root.lastChild.childNodes != null) {
return Sys.Extended.UI.HTMLEditor._getReallyLast(root.lastChild)
}
}
return root;
};
Sys.Extended.UI.HTMLEditor._reallyFirst = function(root,seek) {
if(root.firstChild) {
if(root.firstChild == seek) return true;
if(root.firstChild.childNodes)
if(Sys.Extended.UI.HTMLEditor._lookChild(root.firstChild,seek) == 0 ) {
return Sys.Extended.UI.HTMLEditor._reallyFirst(root.firstChild,seek)
}
}
return false;
};
Sys.Extended.UI.HTMLEditor._reallyLast = function(root,seek) {
if(root.lastChild) {
if(root.lastChild == seek) return true;
if(root.lastChild.childNodes)
if(Sys.Extended.UI.HTMLEditor._lookChild(root.lastChild,seek) == root.lastChild.childNodes.length-1 ) {
return Sys.Extended.UI.HTMLEditor._reallyLast(root.lastChild,seek)
}
}
return false;
};
Sys.Extended.UI.HTMLEditor.getContainer = function(container, el) {
if(el==container) return container;
if(container.nodeType == 1) {
for(var i=0; i < container.childNodes.length; i++) {
var child = container.childNodes.item(i);
if(el==child) return child;
if(child.nodeType == 1) {
var ind = Sys.Extended.UI.HTMLEditor._lookChild(child,el);
if(ind >= 0) {
if(child.tagName && Sys.Extended.UI.HTMLEditor.isStyleTag(child.tagName) && (child.tagName.toUpperCase() != "A") && !Sys.Extended.UI.HTMLEditor.isTempElement(child))
return Sys.Extended.UI.HTMLEditor.getContainer(child, el);
else
return child;
}
}
}
}
return null;
};
Sys.Extended.UI.HTMLEditor._TryTransformFromPxToPt = function(fontSize,editor, _id) {
var ret = fontSize.replace(/^(\d+)\.(\d+)px/i,"$1px");
if(!Sys.Extended.UI.HTMLEditor.isIE) {
if(ret && ret.length > 0) {
var seek = ret.toLowerCase().split(",")[0];
if (typeof _id != "undefined") {
var el = document.getElementById(_id);
if(el != null) {
var i;
for(i=0; i< el.options.length; i++) {
var cur = Sys.Extended.UI.HTMLEditor.fontSizeSeek(el.options.item(i).value.toLowerCase().split(",")[0]);
if(cur==seek) break;
}
if(i==el.options.length) {
var span = editor._doc.createElement("SPAN");
editor._doc.body.appendChild(span);
for(i=1; i< 100; i++) {
span.style.fontSize = i+"pt";
if(Sys.Extended.UI.HTMLEditor.getStyle(span,"font-size").replace(/^(\d+)\.(\d+)px/i,"$1px") == seek) {
seek = i+"pt";
break;
}
}
span.parentNode.removeChild(span);
}
}
}
ret = seek;
}
}
return ret;
};
Sys.Extended.UI.HTMLEditor.fontSizeSeek = function(val) {
var seek = val.toString();
switch (seek) {
case "1":
seek="8pt";
break;
case "2":
seek="10pt";
break;
case "3":
seek="12pt";
break;
case "4":
seek="14pt";
break;
case "5":
seek="18pt";
break;
case "6":
seek="24pt";
break;
case "7":
seek="36pt";
break;
}
return seek;
};
Sys.Extended.UI.HTMLEditor.getOwnerDocument = function(node) {
return node.nodeType == 9 ? node : node.ownerDocument || node.document;
};
Sys.Extended.UI.HTMLEditor.getClientViewportElement = function(opt_node) {
var doc;
if (opt_node.nodeType == 9) {
doc = opt_node;
} else {
doc = Sys.Extended.UI.HTMLEditor.getOwnerDocument(opt_node);
}
if (Sys.Extended.UI.HTMLEditor.isIE && doc.compatMode != 'CSS1Compat') {
return doc.body;
}
return doc.documentElement;
};
Sys.Extended.UI.HTMLEditor.isReallyVisible = function(el) {
var elem = el;
var real_visible = true;
while(elem) {
if(elem.style && Sys.Extended.UI.HTMLEditor.getStyle(elem,"display") == "none") {
real_visible = false;
break;
}
elem = elem.parentNode;
}
return real_visible;
}
Sys.Extended.UI.HTMLEditor.setSelectionRange = function(input, selectionStart, selectionEnd) {
input.focus();
if (input.setSelectionRange) {
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
};
Sys.Extended.UI.HTMLEditor.setElementVisibility = function(element) {
var ret = new Array();
var elem = element;
while(elem && elem.nodeType==1 && elem.tagName.toUpperCase() != "BODY") {
var display = elem.style.display;
var visibility = elem.style.visibility;
if(elem.style && (display == "none" || visibility == "hidden")) {
ret.push({element: elem, display: display, visibility: visibility});
elem.style.display = "";
elem.style.visibility = "visible";
}
elem = elem.parentNode;
}
return ret;
};
Sys.Extended.UI.HTMLEditor.restoreElementVisibility = function(arr) {
for(var i=0; i < arr.length; i++) {
var item = arr[i];
var style = item.element.style;
style.display = item.display;
style.visibility = item.visibility;
}
};
if(!Sys.Extended.UI.HTMLEditor.isIE) {
try { //not all such browsers support getter/setter
Sys.Extended.UI.HTMLEditor.__MozillaGetInnerText = function(node, html) {
var els=node.childNodes;
for(var i=0;i