📄 htmleditor.asp
字号:
g_state.selection.type=idEditbox.document.selection.type
}
function _CPopup_Init()
{
var sz="<HTML ID=popup><STYLE>" +document.styleSheets.defPopupSkin.cssText +"\n" +document.styleSheets.popupSkin.cssText +"</STYLE><BODY ONCONTEXTMENU=\"return false\" ONSCROLL=\"return false\" SCROLL=no TABINDEX=-1 ONSELECTSTART=\"return event.srcElement.tagName=='INPUT'\" ><DIV ID=puRegion><TABLE ID=header><TR><TH NOWRAP ID=caption></TH><TH VALIGN=middle ALIGN=RIGHT><DIV ID=close ONCLICK=\"parent._CPopup_Hide()\">×</DIV></TH></TR></TABLE><DIV ALIGN=CENTER ID=content></DIV></DIV></BODY></HTML>"
idPopup.document.open("text/html","replace")
idPopup.document.write(sz)
idPopup.document.close()
}
function _CPopup_Hide()
{
document.all.idPopup.style.zIndex=-1
document.all.idPopup.style.visibility="hidden"
idPopup.document._type=""
idPopup.document.onkeydown=idPopup.document.onmouseover=idPopup.document.onclick=null
}
function _CPopup_Show(szType)
{
var oRenderer,szCacheKey="PopupRenderer."+szType
if(!isIE4)
g_state.SaveSelection()
if(idPopup.document._type==szType)
_CPopup_Hide()
else
{
document.all.idPopup.style.zIndex=-1
oRenderer=g_state.aCache[szCacheKey]
if((!oRenderer)||("Link"==szType)||("Image"==szType))
g_state.aCache[szCacheKey]=oRenderer=new _CPopupRenderer(szType)
document.all.idPopup.style.visibility=""
document.all.idPopup.style.pixelHeight=document.all.idPopup.style.pixelWidth=idPopup.document.all.puRegion.style.pixelHeight=idPopup.document.all.puRegion.style.pixelWidth=50
idPopup.document._type=szType
idPopup.document._renderer=oRenderer
idPopup.document.all.caption.innerText=oRenderer.GetCaption()
idPopup.document.all.content.innerHTML=oRenderer.GetHTML()
idPopup.document.onkeydown=new Function("this._renderer.OnKeyDown()")
idPopup.document.onmouseover=new Function("this._renderer.OnMouseOver()")
idPopup.document.onclick=new Function("this._renderer.OnClick()")
oRenderer.ResetContext(idPopup.document)
setTimeout("_CPopupRenderer_Display('"+szType+"')",100)
}
}
function _CPopupRenderer_Display(szType)
{
var oRenderer,szCacheKey="PopupRenderer."+szType
oRenderer=g_state.aCache[szCacheKey]
if(oRenderer.autoSize)
{
idPopup.document.all.puRegion.style.pixelHeight=document.all.idPopup.style.pixelHeight=idPopup.document.all.puRegion.offsetHeight
idPopup.document.all.puRegion.style.pixelWidth=document.all.idPopup.style.pixelWidth=idPopup.document.all.puRegion.offsetWidth+50
document.all.idPopup.style.pixelLeft=(document.body.clientWidth - idPopup.document.all.puRegion.offsetWidth)/ 2
}
else
{
idPopup.document.all.puRegion.style.pixelHeight=document.all.idPopup.style.pixelHeight=document.body.clientHeight - idToolbar.offsetHeight- document.all.idMode.offsetHeight-20
idPopup.document.all.puRegion.style.pixelWidth=document.all.idPopup.style.pixelWidth=document.body.clientWidth - 50
document.all.idPopup.style.pixelLeft=25
}
document.all.idPopup.style.zIndex=2
idPopup.focus()
}
function _CPopupRenderer(szType)
{
this.szType=szType
this.elCurrent=this.oDocument=null
this.ResetContext=_CPopupRenderer_ResetContext
this.GetCaption=_CPopupRenderer_GetCaption
this.GetHTML=_CPopupRenderer_GetHTML
this.autoSize=true
this.OnMouseOver=new Function()
this.OnKeyDown=_CListPopupRenderer_GenericOnKeyDown
switch(szType)
{
case "formatblock":
case "font":
case "fontsize":
this.OnMouseOver= _CListPopupRenderer_OnMouseOver
this.OnKeyDown=_CListPopupRenderer_OnKeyDown
case "ForeColor":
this.OnClick=_CListPopupRenderer_OnClick
this.Highlight=_CListPopupRenderer_Highlight
this.Select=_CListPopupRenderer_Select
break
default:
this.OnClick=new Function()
break
}
switch(szType)
{
case "formatblock":
this.szCaption="选择当前字体格式"
this.PrepareHTML=_CFormatBlockPopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "font":
this.szCaption="选择当前字体"
this.PrepareHTML=_CFontFacesPopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "fontsize":
this.szCaption="选择当前字体尺寸"
this.PrepareHTML =_CFontSizesPopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "Link":
this.szCaption="创建、修改链接"
this.PrepareHTML=_CLinkPopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "Image":
this.szCaption="创建、修改图片"
this.PrepareHTML=_CImagePopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "Table":
this.szCaption="创建、修改表格"
this.PrepareHTML=_CTablePopupRenderer_PrepareHTML
this.szHTML=this.PrepareHTML()
break
case "ForeColor":
this.szCaption="选择当前字体颜色"
this.szHTML="<DIV ID=ColorPopup ALIGN=CENTER>"+_CUtil_BuildColorTable("")+"</DIV>"
break
default:
this.szCaption=""
break
}
}
function _CPopupRenderer_ResetContext(oDoc)
{
this.oDocument=oDoc
this.elCurrent=null
if(this.szType=="Table")
{
var oSel=idEditbox.document.selection.createRange()
var oBlock=(oSel.parentElement!=null?_CUtil_GetElement(oSel.parentElement(),"TABLE"):_CUtil_GetElement(oSel.item(0),"TABLE"))
if(oBlock!=null)
{
oDoc.all.tabEdit.className=""
oDoc.all.tabEditBodytxtPadding.value=oBlock.cellPadding
oDoc.all.tabEditBodytxtSpacing.value=oBlock.cellSpacing
oDoc.all.tabEditBodytxtBorder.value=oBlock.border
oDoc.all.tabEditBodytxtBorderColor.value=oBlock.borderColor
oDoc.all.tabEditBodytxtBackgroundImage.value=oBlock.background
oDoc.all.tabEditBodytxtBackgroundColor.value=oBlock.bgColor
}
oDoc.elCurrent=oBlock
}
}
function _CPopupRenderer_GetCaption()
{
return this.szCaption
}
function _CPopupRenderer_GetHTML()
{
return this.szHTML
}
function _CFontSizesPopupRenderer_PrepareHTML()
{
var sz="<TABLE ALIGN=center ID=idList CELLSPACING=0 CELLPADDING=0>"
for(var i=1;i <= 7;i++)
{
sz+="<TR><TD NOWRAP _item="+i+" ALIGN=center STYLE=\"margin:0pt;padding:0pt\"><FONT SIZE="+i+">" +"静夜AaBbCc("+i+")</FONT></TD></TR>"
}
sz+="</TABLE>"
return sz
}
function _CFontFacesPopupRenderer_PrepareHTML()
{
var sz="<TABLE ALIGN=center ID=idList CELLSPACING=0 CELLPADDING=0>"
for(var i=0;i<defaultFonts.length;i++)
{
if(i%2==0)sz+="<TR>"
sz+="<TD NOWRAP _item="+i+" ALIGN=center STYLE=\"margin:0pt;padding:0pt\"><FONT FACE=\""+defaultFonts[i][0]+"\">" +defaultFonts[i][1] +"</FONT>"+(defaultFonts[i][2]?("("+defaultFonts[i][1]+")"):"")+"</TD>"
if(i%2)sz+="</TR>"
}
if(i%2) sz+="</TR>"
sz+="<TR><TD ROWSPAN=2 ONCLICK=\"parent._CFontFacesPopupRenderer_InsertOther(this)\" ALIGN=center _item=\"custom\" STYLE=\"margin:0pt;padding:0pt\" NOWRAP ID=customFont>其他字体...</TD></TR>"
sz+="</TABLE>"
return sz
}
function _CFontFacesPopupRenderer_InsertOther()
{
var szFont=prompt("请输入您指定的字体名称: ","宋体")
if((szFont!=null)&&(szFont!=""))
_Format("FontName",szFont)
_CPopup_Hide()
}
function _CFormatBlockPopupRenderer_PrepareHTML()
{
var sz,defaultParagraphs=new Array()
defaultParagraphs[0]=new Array("<P>","普通")
for(var i=1;i <= 6;i++)
defaultParagraphs[i]=new Array("<H"+i+">","标题"+i+"(H"+i+")")
defaultParagraphs[7]=new Array("<PRE>","格式化文本(PRE)")
sz="<TABLE CLASS=block ALIGN=center ID=idList CELLSPACING=0 CELLPADDING=0>"
for(var i=0;i<defaultParagraphs.length;i++)
{
sz+="<TR><TD NOWRAP _item="+i+" ALIGN=center STYLE=\"margin:0pt;padding:0pt\">"+defaultParagraphs[i][0] +defaultParagraphs[i][1] +"</"+defaultParagraphs[i][0].substring(1)+"</TD></TR>"
}
sz+="</TABLE>"
return sz
}
function _CTablePopupRenderer_PrepareHTMLPage(szID,bDisplay)
{
var sz="<TABLE height=100% "+((!bDisplay)?" style=\"display:none\"":"")+" width=100% CELLSPACING=0 CELLPADDING=0 ID="+szID+"><TR ID=tableContents><TD ID=tableOptions VALIGN=TOP NOWRAP WIDTH=150 ROWSPAN=2><A HREF=\"javascript:parent._CTablePopupRenderer_Select(this,'"+szID+"','prop1')\">设定行列</A><BR><A HREF=\"javascript:parent._CTablePopupRenderer_Select(this,'"+szID+"','prop2')\">设定边框与间隔</A><BR><A HREF=\"javascript:parent._CTablePopupRenderer_Select(this,'"+szID+"','prop3')\">设定边框</A><BR><A HREF=\"javascript:parent._CTablePopupRenderer_Select(this,'"+szID+"','prop4')\">设定背景</A><BR></TD><TD BGCOLOR=black ID=puDivider ROWSPAN=2></TD><TD ID=tableProps VALIGN=TOP>"
if(szID=="tabNewBody")
{
sz+= "<DIV ID='"+szID+"prop1'><P CLASS=tablePropsTitle>设定行列</P><TABLE><TR><TD>行: </TD><TD><INPUT SIZE=2 MAXLENGTH=2 TYPE=text ID="+szID+"txtRows VALUE=2 ></TD></TR><TR><TD>列: </TD><TD><INPUT SIZE=2 MAXLENGTH=2 TYPE=text ID="+szID+"txtColumns VALUE=2 ></TD></TR></TABLE></DIV>"
}
else
{
sz+= "<DIV ID='"+szID+"prop1'><P CLASS=tablePropsTitle>设定行列</P>" +"<INPUT type=button ID="+szID+"txtRows VALUE=\"插入行\" ONCLICK=\"parent._CTablePopupRenderer_AddRow(this)\"><P><INPUT type=button ID="+szID+"txtCells VALUE=\"插入列\" ONCLICK=\"parent._CTablePopupRenderer_AddCell(this)\"><BR></DIV>"
}
sz+="<DIV ID='"+szID+"prop2' STYLE=\"display:none\"><P CLASS=tablePropsTitle>设定边框与间隔</P>单元格边框: <INPUT SIZE=2 TYPE=text ID="+szID+"txtPadding VALUE=1><BR>单元格间隔: <INPUT SIZE=2 TYPE=text ID="+szID+"txtSpacing VALUE=1></DIV><DIV ID="+szID+"prop3 STYLE=\"display:none\"><P CLASS=tablePropsTitle>设定边框</P>边框宽度: <INPUT SIZE=2 TYPE=text ID="+szID+"txtBorder VALUE=1><BR>边框颜色: <INPUT SIZE=4 TYPE=text ID="+szID+"txtBorderColor value=#000000><BR>" +_CUtil_BuildColorTable("idBorder"+szID,"","parent._CTablePopupRenderer_ColorSelect(this,'"+szID+"txtBorderColor')")+"</DIV><DIV ID="+szID+"prop4 SIZE=12 STYLE=\"display:none\"><P CLASS=tablePropsTitle>设定背景</P>背景图片: <INPUT TYPE=text ID="+szID+"txtBackgroundImage SIZE=15><BR>背景颜色: <INPUT TYPE=text SIZE=4 ID="+szID+"txtBackgroundColor><BR>" +_CUtil_BuildColorTable("idBackground"+szID,"","parent._CTablePopupRenderer_ColorSelect(this,'"+szID+"txtBackgroundColor')")+"</DIV></TD></TR><TR><TD align=center ID=tableButtons valign=bottom>"
if(szID=="tabNewBody")
{
sz+="<INPUT TYPE=submit ONCLICK=\"parent._CTablePopupRenderer_BuildTable('"+szID+"',this.document)\" VALUE=\"创建表格\"> <INPUT TYPE=reset VALUE=\" 取 消 \" ONCLICK=\"parent._CPopup_Hide()\">"
}
else
{
sz+="<INPUT TYPE=submit ONCLICK=\"parent._CTablePopupRenderer_BuildTable('"+szID+"',this.document)\" VALUE=\"修改表格\"> <INPUT TYPE=reset VALUE=\" 取 消 \" ONCLICK=\"parent._CPopup_Hide()\">"
}
sz+= "</TD></TR></TABLE>"
return sz
}
function _CTablePopupRenderer_PrepareHTML()
{
var sz="<TABLE CLASS=tabBox ID=\"tabSelect\" CELLSPACING=0 CELLPADDING=0 WIDTH=95%><TR HEIGHT=15><TD CLASS=tabItem STYLE=\"border-bottom:none\" NOWRAP><DIV ONCLICK=\"if(tabEdit.className!='disabled'){this.className='selected';this.parentElement.style.borderBottom=tabEdit.className=tabNewBody.style.display='';tabEditBody.style.display='none';tabEdit.parentElement.style.borderBottom='1px black solid'}\" CLASS=selected ID=tabNew>创建表格</DIV></TD><TD CLASS=tabItem NOWRAP><DIV ONCLICK=\"if(this.className!='disabled'){this.className='selected';this.parentElement.style.borderBottom=tabNew.className=tabEditBody.style.display='';tabNew.parentElement.style.borderBottom='1px black solid';tabNewBody.style.display='none'}\" CLASS=disabled ID=tabEdit>修改表格</DIV></TD><TD CLASS=tabSpace WIDTH=100%> </TD></TR><TR><TD VALIGN=TOP CLASS=tabBody COLSPAN=3>"+_CTablePopupRenderer_PrepareHTMLPage("tabNewBody",true)+_CTablePopupRenderer_PrepareHTMLPage("tabEditBody",false)+"</TD></TR></TABLE>"
return sz
}
function _CTablePopupRenderer_Select(el,szID,id)
{
var d=el.document
for(var i=1;i<5;i++)
d.all[szID+"prop"+i].style.display="none"
d.all[szID+id].style.display=""
}
function _CTablePopupRenderer_ColorSelect(el,id)
{
el.document.all[id].value=el.bgColor
}
function _CTablePopupRenderer_AddRow(el)
{
var elRow=el.document.elCurrent.insertRow()
for(var i=0;i<el.document.elCurrent.rows[0].cells.length;i++)
{
var elCell=elRow.insertCell()
elCell.innerHTML=" "
}
}
function _CTablePopupRenderer_AddCell(el){
for(var i=0;i<el.document.elCurrent.rows.length;i++){
var elCell=el.document.elCurrent.rows[i].insertCell()
elCell.innerHTML=" "
}
}
function _CTablePopupRenderer_BuildTable(szID,d)
{
if(szID=="tabNewBody"){
var sz="<TABLE "+(((d.all[szID+"txtBorder"].value=="")||(d.all[szID+"txtBorder"].value=="0"))?"class=\"NOBORDER\"":"")+(d.all[szID+"txtPadding"].value!=""?"cellPadding=\""+d.all[szID+"txtPadding"].value+"\" ":"")+(d.all[szID+"txtSpacing"].value!=""?"cellSpacing=\""+d.all[szID+"txtSpacing"].value+"\" ":"")+(d.all[szID+"txtBorder"].value!=""?"border=\""+d.all[szID+"txtBorder"].value+"\" ":"")+(d.all[szID+"txtBorderColor"].value!=""?"bordercolor=\""+d.all[szID+"txtBorderColor"].value+"\" ":"")+(d.all[szID+"txtBackgroundImage"].value!=""?"background=\""+d.all[szID+"txtBackgroundImage"].value+"\" ":"")+(d.all[szID+"txtBackgroundColor"].value!=""?"bgColor=\""+d.all[szID+"txtBackgroundColor"].value+"\" ":"")+">"
if(d.all[szID+"txtRows"].value>99)d.all[szID+"txtRows"].value=99
if(d.all[szID+"txtColumns"].value>99)d.all[szID+"txtColumns"].value=50
for(var r=0;r<parseInt(d.all[szID+"txtRows"].value);r++)
{
sz+="<TR>"
for(var c=0;c<parseInt(d.all[szID+"txtColumns"].value);c++)
sz+="<TD> </TD>"
sz+="</TR>"
}
sz+="</TABLE>"
insertHTML(sz)
}else
if(d.elCurrent){
d.elCurrent.cellPadding=d.all.tabEditBodytxtPadding.value
d.elCurrent.cellSpacing=d.all.tabEditBodytxtSpacing.value
d.elCurrent.border=d.all.tabEditBodytxtBorder.value
d.elCurrent.className=(d.elCurrent.border==""||d.elCurrent.border==0)?"NOBORDER":""
d.elCurrent.borderColor=d.all.tabEditBodytxtBorderColor.value
d.elCurrent.bgColor=d.all.tabEditBodytxtBackgroundColor.value
d.elCurrent.background=d.all.tabEditBodytxtBackgroundImage.value
}
g_state.RestoreSelection()
_CPopup_Hide()
}
function _CListPopupRenderer_OnClick()
{
var elTD=_CUtil_GetElement(this.oDocument.parentWindow.event.srcElement,"TD")
if(elTD &&elTD._item)this.Select(elTD)
}
function _CListPopupRenderer_GenericOnKeyDown(){
var ev=this.oDocument.parentWindow.event
if(ev.keyCode==27)_CPopup_Hide()
}
function _CListPopupRenderer_OnKeyDown()
{
var el
var iRow=iCell=0
var ev=this.oDocument.parentWindow.event
var idList=this.oDocument.all.idList
var elTR=_CUtil_GetElement(this.elCurrent,"TR")
var elTD=_CUtil_GetElement(this.elCurrent,"TD")
if(elTR!=null)
{
iRow=elTR.rowIndex
iCell=elTD.cellIndex
}
switch(ev.keyCode)
{
case 37:
iCell--
if(iCell<0)
iCell=idList.rows[iRow].cells.length-1
break
case 38:
iRow--
if(iRow<0)
iRow=idList.rows.length-1
break
case 39:
iCell++
if(iCell>idList.rows[iRow].cells.length-1)
iCell=0
break
case 40:
iRow++
if(iRow>idList.rows.length-1)
iRow=0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -