var i;
var ScrWid = (document.body.offsetWidth) - 6;
var TotalLen = ScrWid;
for (i = 0 ; i < NumTBs ; i++) {
TB = yToolbars[i];
if (TB.TBWidth > TotalLen) TotalLen = TB.TBWidth;
}
var PrevTB;
var LastStart = 0;
var RelTop = 0;
var LastWid, CurrWid;
var TB = yToolbars[0];
TB.style.posTop = 0;
TB.style.posLeft = 0;
var Start = TB.TBWidth;
for (i = 1 ; i < yToolbars.length ; i++) {
PrevTB = TB;
TB = yToolbars[i];
CurrWid = TB.TBWidth;
i--;
TB = yToolbars[i];
var TBInd = TB.sourceIndex;
var A = TB.document.all;
var item;
for (i in A) {
item = A.item(i);
if (! item) continue;
if (! item.style) continue;
if (item.sourceIndex <= TBInd) continue;
if (item.style.position == "absolute") continue;
item.style.posTop = RelTop;
}
}
function DoLayout()
{
LayoutTBs();
}
function validateMode()
{
if (! bTextMode) return true;
alert("请取消“使用 HTML 语法书写”选项再使用系统编辑功能!");
Composition.focus();
return false;
}
function format1(what,opt)
{
if (opt=="removeFormat")
{
what=opt;
opt=null;
}
if (opt==null) Composition.document.execCommand(what);
else Composition.document.execCommand(what,"",opt);
pureText = false;
Composition.focus();
}
function format(what,opt)
{
if (!validateMode()) return;
format1(what,opt);
}
function setMode(newMode)
{
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();
function getEl(sTag,start)
{
while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
return start;
}
function UserDialog(what)
{
if (!validateMode()) return;
Composition.document.execCommand(what, true);
pureText = false;
Composition.focus();
}
function foreColor()
{
if (! validateMode()) return;
var arr = showModalDialog("color.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
if (arr != null) format('forecolor', arr);
else Composition.focus();
}
function cleanHtml()
{
var fonts = Composition.document.body.all.tags("FONT");
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
}
}
function getPureHtml()
{
var str = "";
var paras = Composition.document.body.all.tags("P");
if (paras.length > 0) {
for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str;
} else {
str = Composition.document.body.innerHTML;
}
return str;
}
var bLoad=false
var pureText=true
var bodyTag="<head><style type=\"text/css\">body {font-size:10.8pt} P {margin-top: 0;margin-bottom: 0}</style><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#FFFFFF\" MONOSPACE>"
var bTextMode=false
public_description=new Editor
function Editor()
{
this.put_HtmlMode=setMode;
this.put_value=putText;
this.get_value=getText;
}
function getText()
{
if (bTextMode)
return Composition.document.body.innerText;
else
{
cleanHtml();
cleanHtml();
return Composition.document.body.innerHTML;
}
}
function putText(v)
{
if (bTextMode)
Composition.document.body.innerText = v;
else
Composition.document.body.innerHTML = v;
}
function InitDocument()
{
Composition.document.open();
Composition.document.write(bodyTag);
Composition.document.close();
// Composition.focus();
// setTimeout("Composition.focus()",0);