⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rte.js

📁 PHP留言本 设计流程: 1.需求分析: 留言本要是实现的功能是用户留言
💻 JS
📖 第 1 页 / 共 3 页
字号:
this.aLinks        = new Array()
this.szSearch        = location.search.substring(1)
this.aBindings        = new Array()
this.aListPopups        = new Object()
this.aCache        = new Object()
this.RestoreSelection        = _CState_RestoreSelection
this.GetSelection        = _CState_GetSelection
this.SaveSelection        = _CState_SaveSelection
}
function _CState_RestoreSelection()
{
if (this.selection) this.selection.select()
}
function _CState_GetSelection()
{
var oSel = this.selection
if (!oSel) {
oSel = idEditbox.document.selection.createRange()
oSel.type = idEditbox.document.selection.type
}
return oSel
}
function _CState_SaveSelection()
{
g_state.selection = idEditbox.document.selection.createRange()
g_state.selection.type = idEditbox.document.selection.type
}
// POPUP (Link, table and image popup need to be worked on)
function _CPopup_Init()
{
var sz = ""
+ "<HTML ID=popup>"
+        "<STYLE>"
+        document.styleSheets.defPopupSkin.cssText
+        "\n"
+        document.styleSheets.popupSkin.cssText
+        "</STYLE>"
+        "<SCRIPT>function IMAGELoaded(w) {parent._IMAGELoaded(w,self)}</SCRIPT>"
+        "<BODY "
+        "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()\">"
+        L_CLOSEBUTTON_TEXT
+        "</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_InsertDatabound(eSelect)
{
if (eSelect.selectedIndex != 0)
{
var sElemName = eSelect.options[eSelect.selectedIndex].text;
var iLen = sElemName.length
sElemName = sElemName.replace(/"/g, '&#034;')
insertHTML('<INPUT CLASS=DataBound SIZE=' + (iLen + 2) + ' NAME="' + sElemName +'" VALUE=" ' + sElemName + ' ">')
eSelect.selectedIndex = 0;

// commented out by Bob..
//idEditbox.focus()
}
}
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
// commented out by Bob..
//idEditbox.focus()
}
function _CPopup_Show(szType)
{
var oRenderer, szCacheKey = "PopupRenderer." + szType
if (idPopup.document._type == szType)
_CPopup_Hide()
else
{
document.all.idPopup.style.zIndex = -1
oRenderer = g_state.aCache[szCacheKey]
if ((!oRenderer) || ("Link"==szType))
        //
        // changed by Bob
        //
        if (szType=="Image") {
                inlineimage();
                return false;
        }
        if (szType=="BackColor") {
                popupimage();
                return false;
        }
g_state.aCache[szCacheKey] = oRenderer = new _CPopupRenderer(szType)
// Force Sizing
document.all.idPopup.style.visibility = ""
idPopup.document.all.puRegion.style.pixelHeight = idPopup.document.all.puRegion.style.pixelWidth = 100
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 + "')",0)
}
}
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 "BackColor":
                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        = L_PUTITLEPARAGRAPHSTYLE_TEXT
                        this.PrepareHTML        = _CFormatBlockPopupRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                break
                case "font":
                        this.szCaption        = L_PUTITLEFONTFACE_TEXT
                        this.PrepareHTML        = _CFontFacesPopupRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                break
                case "fontsize":
                        this.szCaption        = L_PUTITLEFONTSIZE_TEXT
                        this.PrepareHTML        =_CFontSizesPopupRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                break
                case "Link":
                        this.szCaption        = L_PUTITLELINK_TEXT
                        this.PrepareHTML        = _CLinkPopupRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                break
                case "Table":
                        this.szCaption        = L_PUTITLENEWTABLE_TEXT
                        this.PrepareHTML        = _CTablePopupRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                break
                case "Image":
                        alert("pom");
                        return false;
                        //this.szCaption        = L_PUTITLEIMAGE_TEXT
                        //this.PrepareHTML        = _CImagePopupRenderer_PrepareHTML
                        //this.szHTML        = this.PrepareHTML()
                        //this.autoSize        = false
                break
                case "BackColor":
                        this.szCaption        = L_PUTITLEBGCOLOR_TEXT
                        this.szHTML        = "<DIV ID=ColorPopup ALIGN=CENTER>" + _CUtil_BuildColorTable("") + "</DIV>"
                break
                case "ForeColor":
                        this.szCaption        = L_PUTITLETEXTCOLOR_TEXT
                        this.szHTML        = "<DIV ID=ColorPopup ALIGN=CENTER>" + _CUtil_BuildColorTable("") + "</DIV>"
                break
                case "Emoticon":
                        this.szCaption        = L_PUTITLEEMOTICON_TEXT
                        this.PrepareHTML        = _CEmoticonRenderer_PrepareHTML
                        this.szHTML        = this.PrepareHTML()
                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 _CEmoticonRenderer_PrepareHTML() {
var sz = "<DIV ALIGN=center>"
for (var i=0; i < arEmoticons.length; i++)
{
sz += "<IMG TABINDEX=" + (i+1) + " ONCLICK=\"parent._CEmoticonRenderer_Select(this)\" CLASS=emoticon SRC=\"" + L_EMOTICONPATH_TEXT + arEmoticons[i] + "\" WIDTH=12 HEIGHT=12 HSPACE=3 VSPACE=3>"
if ((i+1)%8==0) sz+="<BR>"
}
if (i%8!=0) sz+="<BR>"
for (var i=0; i < arBigEmoticons.length; i++)
{
sz += "<IMG TABINDEX=" + (i+arEmoticons.length) + " ONCLICK=\"parent._CEmoticonRenderer_Select(this)\" CLASS=emoticon SRC=\"" + L_EMOTICONPATH_TEXT + arBigEmoticons[i] + "\" WIDTH=16 HEIGHT=16 HSPACE=4 VSPACE=4>"
if ((i+1)%6==0) sz+="<BR>"
}
sz+="</DIV>"
return sz
}
function _CEmoticonRenderer_Select(elImg) {
insertHTML("<IMG SRC=\"" + elImg.src + "\" WIDTH=" + elImg.width + " HEIGHT=" + elImg.height + ">")
g_state.RestoreSelection()
_CPopup_Hide()
}
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 + ">"
+        L_STYLESAMPLE_TEXT + "(" + 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++)
{
sz += ""
+ "<TR>"
+        "<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>"
+ "</TR>"
}
//        sz += "<TR><TD ONCLICK=\"parent._CFontFacesPopupRenderer_InsertOther(this)\" ALIGN=center _item=\"custom\" STYLE=\"margin:0pt;padding:0pt\" NOWRAP><FONT ID=customFont>" + L_CUSTOMFONT_TEXT + "</FONT></TR>"
sz += "</TABLE>"
return sz
}
function _CFontFacesPopupRenderer_InsertOther(el) {
if (el._item=="custom") {
el._item = "input"
// onfocus disabled door bob..
var sz = "<INPUT ONSELECTSTART=\"event.cancelBubble=true\" ONKEYDOWN=\"event.cancelBubble=true\" ONKEYPRESS=\"if (event.keyCode==13) {this.face=this.value;document._renderer.Select(this.parentElement)};event.cancelBubble=true\" VALUE=\"" + L_CUSTOMFONTENTRY_TEXT + "\" ONxFOCUS=\"if (this.value==this.defaultValue) this.select()\" TYPE=text>"
el.innerHTML = sz
// commented out by Bob..
// el.children[0].focus()
}
el.document.parentWindow.event.cancelBubble = true
}
function _CFormatBlockPopupRenderer_PrepareHTML()
{
var sz, defaultParagraphs = new Array()
defaultParagraphs[0] = new Array("<P>", L_STYLENORMAL_TEXT + " (P)")
for (var i=1; i <= 6; i++)
defaultParagraphs[i] = new Array("<H"+i+">", L_STYLEHEADING_TEXT + i + " (H" + i + ")")
defaultParagraphs[7] = new Array("<PRE>", L_STYLEFORMATTED_TEXT + "(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 _CImagePopupRenderer_PrepareHTML()
{
return "<IFRAME ID=idPhotos WIDTH=98% HEIGHT=90% STYLE=\"visibility: hidden;border: none\" SRC=\"photos/photos.htm" + ((g_state.szSearch!="") ? ("?" + g_state.szSearch) : "") + "\"></IFRAME>"
}
function _IMAGELoaded(wPhotos,wPopup) {
wPhotos.setBGColor("#F1F1F1")
wPopup.document.all.idPhotos.style.visibility = ""
}
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')\">"
+        L_TABLEROWSANDCOLS_TEXT
+        "</A>"
+        "<BR>"
+        "<A HREF=\"javascript:parent._CTablePopupRenderer_Select(this,'" + szID + "','prop2')\">"
+        L_TABLEPADDINGANDSPACING_TEXT
+        "</A>"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -