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

📄 editor.js

📁 很经典的Blog程序,呵呵
💻 JS
📖 第 1 页 / 共 5 页
字号:
  this.btnXHTMLFullSource=false;this.btnXHTMLSource=false;
  this.btnClearAll=false;

    //*** CMS FUNCTIONS ***
    this.cmdAssetManager="";

	this.cmdFileManager="";
	this.cmdImageManager="";
	this.cmdMediaManager="";
	this.cmdFlashManager="";

    this.btnContentBlock=false;
    this.cmdContentBlock=";";//needs ;
    this.btnInternalLink=false;
    this.cmdInternalLink=";";//needs ;
    this.insertLink=insertLink;
    this.btnCustomObject=false;
    this.cmdCustomObject=";";//needs ;
	this.btnInternalImage=false;
	this.cmdInternalImage=";";//needs ;
    //**********

    this.arrStyle=[];
	this.isCssLoaded=false;
	this.openStyleSelect=openStyleSelect;

    this.arrParagraph=[[getTxt("Heading 1"),"H1"],
        [getTxt("Heading 2"),"H2"],
        [getTxt("Heading 3"),"H3"],
        [getTxt("Heading 4"),"H4"],
        [getTxt("Heading 5"),"H5"],
        [getTxt("Heading 6"),"H6"],
        [getTxt("Preformatted"),"PRE"],
        [getTxt("Normal (P)"),"P"],
        [getTxt("Normal (DIV)"),"DIV"]];

    this.arrFontName=["Arial","Arial Black","Arial Narrow",
        "Book Antiqua","Bookman Old Style","Century Gothic",
        "Comic Sans MS","Courier New","Franklin Gothic Medium",
        "Garamond","Georgia","Impact","Lucida Console",
        "Lucida Sans","Lucida Unicode","Modern",
        "Monotype Corsiva","Palatino Linotype","Roman",
        "Script","Small Fonts","Symbol","Tahoma",
        "Times New Roman","Trebuchet MS","Verdana",
        "Webdings","Wingdings","serif","sans-serif",
        "cursive","fantasy","monoscape"];

    this.arrFontSize=[[getTxt("Size 1"),"1"],
        [getTxt("Size 2"),"2"],
        [getTxt("Size 3"),"3"],
        [getTxt("Size 4"),"4"],
        [getTxt("Size 5"),"5"],
        [getTxt("Size 6"),"6"],
        [getTxt("Size 7"),"7"]];

    this.arrCustomTag=[];//eg.[["Full Name","{%full_name%}"],["Email","{%email%}"]];

    this.docType="";
    this.html="<html>";
    this.headContent="";
    this.preloadHTML="";

    this.onSave=function(){document.getElementById("iwe_btnSubmit"+this.oName).click()};

    this.onFullScreen=function(){return true;};
    this.onNormalScreen=function(){return true;};

    this.initialRefresh=false;//not used

    this.doUndo=doUndo;
    this.doRedo=doRedo;
    this.saveForUndo=saveForUndo;
    this.doUndoRedo=doUndoRedo;

    this.arrUndoList=[];
    this.arrRedoList=[];

    this.useTagSelector=true;
    this.TagSelectorPosition="bottom";
    this.moveTagSelector=moveTagSelector;
    this.selectElement=selectElement;
    this.removeTag=removeTag;
    this.doClick_TabCreate=doClick_TabCreate;
    this.doRefresh_TabCreate=doRefresh_TabCreate;

    this.arrCustomButtons = [["CustomName1","alert(0)","caption here","btnSave.gif"],
                            ["CustomName2","alert(0)","caption here","btnSave.gif"]];

    this.onSelectionChanged=function(){return true;};

	this.spellCheckMode="ieSpell";

	this.REPLACE=REPLACE;
	this.mode="HTMLBody";
	this.idTextArea;

    editor[editor.length] = this;
    return this;
    }

/*** Undo/Redo ***/
function saveForUndo()
    {
    var oEditor=document.getElementById("idContent"+this.oName).contentWindow;
    var obj=this;
    if(obj.arrUndoList[0])
        if(oEditor.document.body.innerHTML==obj.arrUndoList[0][0])return;
    for(var i=20;i>1;i--)obj.arrUndoList[i-1]=obj.arrUndoList[i-2];
    obj.focus();
    var oSel=oEditor.getSelection();
    var range = oSel.getRangeAt(0);
    obj.arrUndoList[0]=[oEditor.document.body.innerHTML, range.cloneRange()];

    this.arrRedoList=[];//clear redo list

	if(this.btnUndo) makeEnableNormal(document.getElementById("btnUndo"+this.oName));
	if(this.btnRedo) makeDisabled(document.getElementById("btnRedo"+this.oName));
    }
function doUndo() 
	{
    this.doUndoRedo(this.arrUndoList, this.arrRedoList);
	}

function doRedo() 
	{
    this.doUndoRedo(this.arrRedoList, this.arrUndoList);
	}
function doUndoRedo(listA, listB)
    {
    var oEditor=document.getElementById("idContent"+this.oName).contentWindow;
    var obj=this;
    if(!listA[0])return; //return of undo/redo array empty

    for(var i=20;i>1;i--)listB[i-1]=listB[i-2];
    var oSel=oEditor.getSelection();
    var range = oSel.getRangeAt(0);
    listB[0]=[oEditor.document.body.innerHTML, range.cloneRange()];

    sHTML=listA[0][0];

    oEditor.document.body.innerHTML=sHTML;

    oSel = oEditor.getSelection();
    oSel.removeAllRanges();
    oSel.addRange(listA[0][1]);

    for(var i=0;i<19;i++)listA[i]=listA[i+1];
    listA[19]=null;
    realTime(this);
    }

/*** RENDER ***/
var bOnSubmitOriginalSaved=false;
function REPLACE(idTextArea)
	{
	this.idTextArea=idTextArea;
	var oTextArea=document.getElementById(idTextArea);
	oTextArea.style.display="none";
	var oForm=GetElement(oTextArea,"FORM");
	if(oForm)
		{
		if(!bOnSubmitOriginalSaved)
			{
			if(oForm.onsubmit)
			onsubmit_original=oForm.onsubmit;
			
			bOnSubmitOriginalSaved=true;	
			}
		oForm.onsubmit = new Function("return onsubmit_new()");
		}

	var sContent=document.getElementById(idTextArea).value;
	sContent=sContent.replace(/&/g,"&amp;");
	sContent=sContent.replace(/</g,"&lt;");
	sContent=sContent.replace(/>/g,"&gt;");

	this.RENDER(sContent);
	}
function onsubmit_new()
	{
	var sContent;
	for(var i=0;i<oUtil.arrEditor.length;i++)
		{
		var oEdit=eval(oUtil.arrEditor[i]);
		if(oEdit.mode=="HTMLBody")sContent=oEdit.getHTMLBody();
		if(oEdit.mode=="HTML")sContent=oEdit.getHTML();
		if(oEdit.mode=="XHTMLBody")sContent=oEdit.getXHTMLBody();
		if(oEdit.mode=="XHTML")sContent=oEdit.getXHTML();
		document.getElementById(oEdit.idTextArea).value=sContent;
		}
	if(onsubmit_original)return onsubmit_original();
	}
function onsubmit_original(){}

function RENDER(sPreloadHTML)
    {
	/*** icons related ***/
	iconHeight=this.iconHeight;
	iconHeight2=2*iconHeight;
	iconHeight3=3*iconHeight;
	iconHeight4=4*iconHeight;
	iconOffsetTop=this.iconOffsetTop;
	
    /*** Tetap Ada (For downgrade compatibility) ***/    
    if(sPreloadHTML.substring(0,4)=="<!--" &&
	sPreloadHTML.substring(sPreloadHTML.length-3)=="-->")
	sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-3);

	if(sPreloadHTML.substring(0,4)=="<!--" &&
	sPreloadHTML.substring(sPreloadHTML.length-6)=="--&gt;")
	sPreloadHTML=sPreloadHTML.substring(4,sPreloadHTML.length-6);
	
	/*** Converting back HTML-encoded content (kalau tdk encoded tdk masalah) ***/	
	sPreloadHTML=sPreloadHTML.replace(/&lt;/g,"<");
	sPreloadHTML=sPreloadHTML.replace(/&gt;/g,">");
	sPreloadHTML=sPreloadHTML.replace(/&amp;/g,"&");

	/*** enable required buttons ***/
	if(this.cmdContentBlock!=";")this.btnContentBlock=true;
	if(this.cmdInternalLink!=";")this.btnInternalLink=true;
	if(this.cmdInternalImage!=";")this.btnInternalImage=true;	
	if(this.cmdCustomObject!=";")this.btnCustomObject=true;
	if(this.arrCustomTag.length>0)this.btnCustomTag=true;
	if(this.mode=="HTMLBody"){this.btnXHTMLSource=false;this.btnXHTMLFullSource=false;}
	if(this.mode=="HTML"){this.btnXHTMLFullSource=false;this.btnXHTMLSource=false;}
	if(this.mode=="XHTMLBody"){this.btnXHTMLSource=true;this.btnXHTMLFullSource=false;}
	if(this.mode=="XHTML"){this.btnXHTMLFullSource=true;this.btnXHTMLSource=false;}

    /*** features ***/
    var bUseFeature=false;
    if(this.features.length>0)
        {
        bUseFeature=true;
        for(var i=0;i<this.buttonMap.length;i++)
            eval(this.oName+".btn"+this.buttonMap[i]+"=true");//ex: oEdit1.btnStyleAndFormatting=true (no problem), oEdit1.btn|=true (no problem), oEdit1.btnBRK=true (no problem)

        this.btnTextFormatting=false;this.btnListFormatting=false;
        this.btnBoxFormatting=false;this.btnParagraphFormatting=false;
        this.btnCssText=false;this.btnCssBuilder=false;
        for(var j=0;j<this.features.length;j++)
            eval(this.oName+".btn"+this.features[j]+"=true");//ex: oEdit1.btnTextFormatting=true

        for(var i=0;i<this.buttonMap.length;i++)
            {
            sButtonName=this.buttonMap[i];          
            bBtnExists=false;

⌨️ 快捷键说明

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