📄 templateaddedit.aspx
字号:
return szRet
}
function setDefaultStyle(szValue)
{
g_state.css=szValue
if(g_state.bMode)
idEditbox.document.body.style.cssText=g_state.css
}
function setSkin(szSkin)
{
if(szSkin==null)
document.styleSheets.skin.cssText=g_state.defaultSkin
else
document.styleSheets.skin.cssText=szSkin
document.styleSheets.skin.disabled=false
}
function setToolbar(id,g_state)
{
var el=document.all[id]
if(el)
el.style.display=(g_state)?"":"none"
if(id=="tbmode"){
_setSize()
}
}
function setMode(bMode)
{
if (bMode!=g_state.bMode) {
g_state.bMode = bMode
var objBody = idEditbox.document.body
if (!bMode&& !g_state.bMode)
{
_CPopup_Hide()
objBody.bgColor = objBody.style.cssText = ""
if (g_state.customButtons)
idStandardBar.style.display = "none"
else
idToolbar.style.display = "none"
objBody.innerText = idEditbox.document.body.innerHTML
objBody.className = "textMode"
}
if ((bMode) && (g_state.bMode))
{
setDefaultStyle(g_state.css)
setBGColor(g_state.bgColor)
objBody.className = idStandardBar.style.display = idToolbar.style.display = ""
objBody.innerHTML = idEditbox.document.body.innerText
}
_setSize()
cbMode.checked = !bMode
setSelection(true)
setFocus()
}
return bMode
}
function _Format(szHow,szValue){
var oSel = g_state.GetSelection()
var sType = oSel.type
var oTarget = (sType == "None" ? idEditbox.document : oSel)
var oBlock = (oSel.parentElement != null ? _CUtil_GetBlock(oSel.parentElement()) : oSel.item(0))
setFocus()
switch(szHow)
{
case "BackColor":
var el = null
if (oSel.parentElement != null) {
el = _CUtil_GetElement(oSel.parentElement(),"TD")
if (!el) el = _CUtil_GetElement(oSel.parentElement(),"TH")
if (!el) el = _CUtil_GetElement(oSel.parentElement(),"TR")
if (!el) el = _CUtil_GetElement(oSel.parentElement(),"TABLE")
}
else
el = _CUtil_GetElement(oSel.item(0),"TABLE")
if (el)
el.bgColor = szValue
else
idEditbox.document.execCommand('backcolor','',szValue);
break;
case "excel":
sel = idEditbox.document.selection.createRange();
sel.pasteHTML(excel);
break;
case "line":
sel = idEditbox.document.selection.createRange();
sel.pasteHTML('<hr color=#FF0000>');
break;
case "Justify":
if(oBlock)
{
oBlock.style.textAlign=""
if(((oBlock.tagName=="TABLE")||(oBlock.tagName=="IMG"))&&(("left"==oBlock.align)&&("Left"==szValue))){
oBlock.align=""
break;
}
oBlock.align=szValue
if((oBlock.tagName=="HR")||((oBlock.tagName=="IMG")&&szValue!="Center"))break;
}
szHow=szHow+szValue
szValue=""
break
case "bigview":
window.open(hefolder+"bigview.htm","view","toolbar=yes,status=yes,resizable=yes,scrollbars=yes")
return true
case "insdate":
var d = new Date();
sel = idEditbox.document.selection.createRange();
sel.pasteHTML(d.toLocaleDateString());
break
case "picfile": //插入来自文件的图片
//window.open('../includes/picfile.aspx', 'myoffice','location=no scrollbars=no menubar=no left=200 top=100 width=380 height=50 fullscreen=no');
window.open('../includes/picfile.aspx','','left=200,top=100,scrollbars=no,width=380,height=50');
return true
default:
oTarget.execCommand(szHow,false,szValue)
break
}
g_state.RestoreSelection()
setFocus()
govalue()
return true
}
function _pageReady()
{
idEditbox.document.body.oncontextmenu = new Function("return false");
if (self.parent.RTELoaded)
self.parent.RTELoaded(self)
if (document.styleSheets.skin.disabled)
setSkin(null)
_setSize()
idEditor.style.visibility=""
g_state.bLoaded = true
var tr = idEditbox.document.body.createTextRange()
tr.select()
g_state.SaveSelection()
setSelection(false)
//控件赋值
setHTML(document.body.all("message").value)
}
function _fireFocus() {
if (self.parent.RTEFocus)
self.parent.RTEFocus(self)
}
//初始值设置
function _initEditor(){
g_state=new _CState()
window.onresize=_setSize
var sz=""
sz += ""
sz+="<STYLE>A{text-decoration:none}\nTD{font-size:12px}\n.textMode{border-top: 1px black solid;font-size:12px}\n.NOBORDER TD{border:1px #dddddd solid}BODY{border:1px black solid;border-top:none;font-size:12px}</STYLE><BODY ONCONTEXTMENU=\"return false\">"+L_RTEDEFAULTHTML_TEXT+"</BODY>"
_CPopup_Init()
//只读
if (document.body.all("eread").value==0)
{
idEditbox.document.designMode = "on"
}
idEditbox.document.open("text/html","replace")
idEditbox.document.write(sz)
idEditbox.document.close()
idEditbox.document.body.onblur = idEditbox.onblur = g_state.SaveSelection
idEditbox.document.onkeydown = _Editor_KeyDownHandler
idEditbox.document.onkeyup = govalue
idEditbox.document.onmousedown = _Editor_ClickHandler
idEditbox.document.ondblclick = _Editor_DblClickHandler
idEditbox.document.onmouseup= govalue
setTimeout("_pageReady()",100)
}
function _Editor_ClickHandler(){
g_state.selection=null
}
function _Editor_KeyDownHandler(){
var ev=this.parentWindow.event
if((ev.keyCode==78||ev.keyCode==72)&&ev.ctrlKey){
if(ev.keyCode==78)
window.open(parent.location)
ev.keyCode=0;ev.returnValue=false
}
if(ev.keyCode==9)
g_state.SaveSelection()
else
g_state.selection=null
}
function _Editor_DblClickHandler(){
var el = this.parentWindow.event.srcElement
if (el.tagName=="IMG") {
el.removeAttribute("width")
el.removeAttribute("height")
el.style.removeAttribute("width")
el.style.removeAttribute("height")
el.width = el.width
el.height = el.height
}
if (el.tagName=="TABLE")
_CPopup_Show('Table')
}
function _setSize(){
if (document.body.all("eheight").value!='100%')
{
document.all.idEditbox.style.pixelHeight=document.body.all("eheight").value
}
document.all.idPopup.style.pixelLeft =(document.body.clientWidth - idPopup.document.all.puRegion.offsetWidth) / 2
}
//生成工具条
function _drawToolbar()
{
var sz="<DIV ID=idStandardBar onmouseover=\"button_over(event.srcElement);\" onmouseout=\"button_out(event.srcElement)\">"
var tooltype=document.body.all("etype").value
//只读
if (document.body.all("eread").value==0)
{
switch(tooltype)
{
case "1":
sz+=toolb[1]+toolb[2]+toolb[3]+toolb[0]+toolb[26]+toolb[28]+toolb[0]+toolb[4]+toolb[5]+toolb[6]+toolb[7]+toolb[0]+toolb[22]+toolb[23]+toolb[0]+toolb[8]+toolb[9]+toolb[10]+toolb[0]+toolb[11]+toolb[12]+toolb[13]+toolb[0]
sz+=toolb[14]+toolb[15]+toolb[16]+toolb[0]+toolb[17]+toolb[18]+toolb[19]+toolb[20]+toolb[0]+toolb[21]+toolb[24]+toolb[0]+toolb[25]+toolb[27]
break
case "2":
//sz+=toolb[1]+toolb[2]+toolb[3]+toolb[0]+toolb[4]+toolb[0]+toolb[13]+toolb[14]+toolb[15]+toolb[0]+toolb[17]+toolb[18]+toolb[19]+toolb[20]+toolb[0]+toolb[21]+toolb[0]+toolb[25]
sz+=toolb[1]+toolb[2]+toolb[3]+toolb[0]+toolb[4]+toolb[5]+toolb[7]+toolb[0]+toolb[11]+toolb[12]+toolb[13]+toolb[0]
sz+=toolb[14]+toolb[15]+toolb[16]+toolb[0]+toolb[17]+toolb[18]+toolb[19]+toolb[20]+toolb[0]+toolb[21]+toolb[24]+toolb[0]+toolb[25]
break
default:
sz+=toolb[1]+toolb[2]+toolb[3]+/*toolb[0]+toolb[26]+*/toolb[0]+toolb[4]+toolb[5]+toolb[6]+toolb[7]+toolb[0]+toolb[22]+toolb[23]+toolb[0]+toolb[8]+toolb[9]+toolb[10]+toolb[0]+toolb[11]+toolb[12]+toolb[13]+toolb[0]
sz+=toolb[14]+toolb[15]+toolb[16]+toolb[0]+toolb[17]+toolb[18]+toolb[19]+toolb[20]+toolb[0]+toolb[21]+toolb[24]+toolb[0]+toolb[25]
break
}
}else{
//只读时,只显示放大按钮
sz+=toolb[26]+toolb[0]+toolb[28]
}
document.write(sz+"</DIV>")
}
function _drawModeSelect(){
var sz="<TABLE CELLSPACING=0 CELLPADDING=0 ID=idMode> <TR><TD><INPUT TYPE=hidden ID=cbMode ONCLICK=\"setMode(!this.checked)\" tabindex=\"-1\"></TD><TD><LABEL FOR=frm1.cbMode></LABEL>  </TD></TR> </TABLE>"
document.write(sz)
document.body.all("cbMode").checked=false
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -