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

📄 fckeditorcode_gecko_2.js

📁 一套能快速建立多语言
💻 JS
📖 第 1 页 / 共 2 页
字号:
FCK.RedirectNamedCommands=new Object();
FCK.ExecuteNamedCommand=function(A,B,C)
{
	if (!C&&FCK.RedirectNamedCommands[A]!=null) FCK.ExecuteRedirectedNamedCommand(A,B);
	else
	{
		FCK.Focus();
		FCK.EditorDocument.execCommand(A,false,B);
		FCK.Events.FireEvent('OnSelectionChange');
	};
};
FCK.GetNamedCommandState=function(A)
{
	try
	{
		if (!FCK.EditorDocument.queryCommandEnabled(A)) return FCK_TRISTATE_DISABLED;
		else return FCK.EditorDocument.queryCommandState(A)?FCK_TRISTATE_ON:FCK_TRISTATE_OFF;
	}
	catch (e)
	{
		return FCK_TRISTATE_OFF;
	};
};
FCK.SwitchEditMode=function()
{
	var A=(FCK.EditMode==FCK_EDITMODE_WYSIWYG);
	document.getElementById('eWysiwyg').style.display=A?'none':'';
	document.getElementById('eSource').style.display=A?'':'none';
	if (A)
	{
		document.getElementById('eSourceField').value=FCK.GetXHTML(FCKConfig.FormatSource);
	}
	else FCK.SetHTML(document.getElementById('eSourceField').value,true);
	FCK.EditMode=A?FCK_EDITMODE_SOURCE:FCK_EDITMODE_WYSIWYG;
	FCKToolbarSet.RefreshModeState();
	FCK.Focus();
};
FCK.CreateElement=function(A)
{
	var e=FCK.EditorDocument.createElement(A);
	return FCK.InsertElementAndGetIt(e);
};
FCK.InsertElementAndGetIt=function(e)
{
	e.setAttribute('__FCKTempLabel',1);
	this.InsertElement(e);
	var A=FCK.EditorDocument.getElementsByTagName(e.tagName);
	for (var i=0;i<A.length;i++)
	{
		if (A[i].getAttribute('__FCKTempLabel'))
		{
			A[i].removeAttribute('__FCKTempLabel');
			return A[i];
		};
	};
	return null;
};
FCK._BaseGetNamedCommandState=FCK.GetNamedCommandState;
FCK.GetNamedCommandState=function(A)
{
	switch (A)
	{
		case 'Unlink':return FCKSelection.HasAncestorNode('A')?FCK_TRISTATE_OFF:FCK_TRISTATE_DISABLED;
		default:return FCK._BaseGetNamedCommandState(A);
	};
};
FCK.AttachToOnSelectionChange=function(A)
{
	this.Events.AttachEvent('OnSelectionChange',A);
};
FCK.InsertHtml=function(A)
{
	A=FCKConfig.ProtectedSource.Protect(A);
	A=FCK.ProtectUrls(A);
	var B=FCKSelection.Delete();
	var C=B.getRangeAt(0);
	var D=C.createContextualFragment(A);
	var E=D.lastChild;
	C.insertNode(D);
	FCKSelection.SelectNode(E);
	FCKSelection.Collapse(false);
	this.Focus();
};
FCK.InsertElement=function(A)
{
	var B=FCKSelection.Delete();
	var C=B.getRangeAt(0);
	C.insertNode(A);
	FCKSelection.SelectNode(A);
	FCKSelection.Collapse(false);
	this.Focus();
};
FCK.CreateLink=function(A)
{
	FCK.ExecuteNamedCommand('Unlink');
	if (A.length>0)
	{
		var B='javascript:void(0);/*'+(new Date().getTime())+'*/';
		FCK.ExecuteNamedCommand('CreateLink',B);
		var C=document.evaluate("//a[@href='"+B+"']",this.EditorDocument.body,null,9,null).singleNodeValue;
		if (C)
		{
			C.href=A;
			return C;
		};
	};
};
var FCKSelection=new Object();
FCK.Selection=FCKSelection;
FCKSelection.GetType=function()
{
	this._Type='Text';
	var A;
	try
	{
		A=FCK.EditorWindow.getSelection();
	}
	catch (e)
	{
	};
	if (A&&A.rangeCount==1)
	{
		var B=A.getRangeAt(0);
		if (B.startContainer==B.endContainer&&(B.endOffset-B.startOffset)==1) this._Type='Control';
	};
	return this._Type;
};
FCKSelection.GetSelectedElement=function()
{
	if (this.GetType()=='Control')
	{
		var A=FCK.EditorWindow.getSelection();
		return A.anchorNode.childNodes[A.anchorOffset];
	};
};
FCKSelection.GetParentElement=function()
{
	if (this.GetType()=='Control') return FCKSelection.GetSelectedElement().parentNode;
	else
	{
		var A=FCK.EditorWindow.getSelection();
		if (A)
		{
			var B=A.anchorNode;
			while (B&&B.nodeType!=1) B=B.parentNode;
			return B;
		};
	};
};
FCKSelection.SelectNode=function(A)
{
	FCK.Focus();
	var B=FCK.EditorDocument.createRange();
	B.selectNode(A);
	var C=FCK.EditorWindow.getSelection();
	C.removeAllRanges();
	C.addRange(B);
};
FCKSelection.Collapse=function(A)
{
	var B=FCK.EditorWindow.getSelection();
	if (A==null||A===true) B.collapseToStart();
	else B.collapseToEnd();
};
FCKSelection.HasAncestorNode=function(A)
{
	var B=this.GetSelectedElement();
	if (!B&&FCK.EditorWindow)
	{
		try
		{
			B=FCK.EditorWindow.getSelection().getRangeAt(0).startContainer;
		}
		catch(e)
		{
		};
	};
	while (B)
	{
		if (B.nodeType==1&&B.tagName==A) return true;
		B=B.parentNode;
	};
	return false;
};
FCKSelection.MoveToAncestorNode=function(A)
{
	var B;
	var C=this.GetSelectedElement();
	if (!C) C=FCK.EditorWindow.getSelection().getRangeAt(0).startContainer;
	while (C)
	{
		if (C.tagName==A) return C;
		C=C.parentNode;
	};
	return null;
};
FCKSelection.Delete=function()
{
	var A=FCK.EditorWindow.getSelection();
	for (var i=0;i<A.rangeCount;i++)
	{
		A.getRangeAt(i).deleteContents();
	};
	return A;
};
var FCKPanel=function(A)
{
	this.IsRTL=false;
	this.IsContextMenu=false;
	this._IsOpened=false;
	if (A) this._Window=A;
	else
	{
		this._Window=window;
		while (this._Window!=window.top)
		{
			try
			{
				if (this._Window.parent.document.body.tagName=='FRAMESET') break;
			}
			catch (e)
			{
				break;
			};
			this._Window=this._Window.parent;
		};
	};
	var B=this._IFrame=this._Window.document.createElement('iframe');
	B.frameBorder='0';
	B.scrolling='no';
	B.style.position='absolute';
	B.width=B.height=0;
	B.style.zIndex=FCKConfig.FloatingPanelsZIndex;
	this._Window.document.body.appendChild(B);
	this.Document=B.contentWindow.document;
	this.Document.open();
	this.Document.write('<html><head></head><body><\/body><\/html>');
	this.Document.close();
	this.Document.body.style.margin=this.Document.body.style.padding='0px';
	this._IFrame.contentWindow.onblur=this.Hide;
	B.contentWindow.Panel=this;
	this.PanelDiv=this.Document.body.appendChild(this.Document.createElement('DIV'));
	this.PanelDiv.className='FCK_Panel';
	this.EnableContextMenu(false);
	this.SetDirection(FCKLang.Dir);
};
FCKPanel.prototype.EnableContextMenu=function(A)
{
	this.Document.oncontextmenu=A?null:FCKTools.CancelEvent;
};
FCKPanel.prototype.AppendStyleSheet=function(A)
{
	FCKTools.AppendStyleSheet(this.Document,A);
};
FCKPanel.prototype.SetDirection=function(A)
{
	this.IsRTL=(A=='rtl');
	this.Document.dir=A;
	this.PanelDiv.style.cssFloat=(A=='rtl'?'right':'left');
};
FCKPanel.prototype.Load=function()
{
};
FCKPanel.prototype.Show=function(x,y,A,B,C)
{
	this.PanelDiv.style.width=B?B+'px':'';
	this.PanelDiv.style.height=C?C+'px':'';
	if (!B)	this._IFrame.width=1;
	if (!C)	this._IFrame.height=1;
	var D=FCKTools.GetElementPosition(A,this._Window);
	x+=D.X;
	y+=D.Y;
	if (this.IsRTL)
	{
		if (this.IsContextMenu) x=x-this.PanelDiv.offsetWidth+1;
		else if (A) x=x+(A.offsetWidth-this.PanelDiv.offsetWidth);
	}
	else
	{
		if ((x+this.PanelDiv.offsetWidth)>this._Window.document.body.clientWidth) x-=x+this.PanelDiv.offsetWidth-this._Window.document.body.clientWidth;
	};
	if (x<0) x=0;
	this._IFrame.style.left=x+'px';
	this._IFrame.style.top=y+'px';
	var E=this.PanelDiv.offsetWidth;
	var F=this.PanelDiv.offsetHeight;
	this._IFrame.width=E;
	this._IFrame.height=F;
	this._IFrame.contentWindow.focus();
	this._IsOpened=true;
};
FCKPanel.prototype.Hide=function()
{
	var A=this.Panel?this.Panel:this;
	if (!A._IsOpened) return;
	A._IFrame.width=A._IFrame.height=0;
	if (A._OnHide) A._OnHide(A);
	A._IsOpened=false;
};
FCKPanel.prototype.CheckIsOpened=function()
{
	return this._IsOpened;
};
FCKPanel.prototype.AttachToOnHideEvent=function(A)
{
	this._OnHide=A;
}
var FCKNamedCommand=function(A)
{
	this.Name=A;
};
FCKNamedCommand.prototype.Execute=function()
{
	FCK.ExecuteNamedCommand(this.Name);
};
FCKNamedCommand.prototype.GetState=function()
{
	return FCK.GetNamedCommandState(this.Name);
};
var FCKDialogCommand=function(A,B,C,D,E,F,G)
{
	this.Name=A;
	this.Title=B;
	this.Url=C;
	this.Width=D;
	this.Height=E;
	this.GetStateFunction=F;
	this.GetStateParam=G;
};
FCKDialogCommand.prototype.Execute=function()
{
	FCKDialog.OpenDialog('FCKDialog_'+this.Name,this.Title,this.Url,this.Width,this.Height);
};
FCKDialogCommand.prototype.GetState=function()
{
	if (this.GetStateFunction) return this.GetStateFunction(this.GetStateParam);
	else return FCK_TRISTATE_OFF;
};
var FCKUndefinedCommand=function()
{
	this.Name='Undefined';
};
FCKUndefinedCommand.prototype.Execute=function()
{
	alert(FCKLang.NotImplemented);
};
FCKUndefinedCommand.prototype.GetState=function()
{
	return FCK_TRISTATE_OFF;
};
var FCKSourceCommand=function()
{
	this.Name='Source';
};
FCKSourceCommand.prototype.Execute=function()
{
	if (FCKBrowserInfo.IsGecko)
	{
		var A=FCKConfig.ScreenWidth*0.65;
		var B=FCKConfig.ScreenHeight*0.65;
		FCKDialog.OpenDialog('FCKDialog_Source',FCKLang.Source,'dialog/fck_source.html',A,B,null,null,true);
	}
	else FCK.SwitchEditMode();
};
FCKSourceCommand.prototype.GetState=function()
{
	return (FCK.EditMode==FCK_EDITMODE_WYSIWYG?FCK_TRISTATE_OFF:FCK_TRISTATE_ON);
};
var FCKTextColorCommand=function(A)
{
	this.Name=A=='TextColor';
	this.Type=A;
	this._Panel=new FCKPanel();
	this._Panel.AppendStyleSheet(FCKConfig.SkinPath+'fck_contextmenu.css');
	this._CreatePanelBody(this._Panel.Document,this._Panel.PanelDiv);
	FCKTools.DisableSelection(this._Panel.Document.body);
};
FCKTextColorCommand.prototype.Execute=function(A,B,C)
{
	FCK._ActiveColorPanelType=this.Type;
	this._Panel.Show(A,B,C);
};
FCKTextColorCommand.prototype.SetColor=function(A)
{
	if (FCK._ActiveColorPanelType=='ForeColor') FCK.ExecuteNamedCommand('ForeColor',A);
	else if (FCKBrowserInfo.IsGecko) FCK.ExecuteNamedCommand('hilitecolor',A);
	delete FCK._ActiveColorPanelType;
};
FCKTextColorCommand.prototype.GetState=function()
{
	return FCK_TRISTATE_OFF;
};
function FCKTextColorCommand_OnMouseOver()
{
	this.className='ColorSelected';
};
function FCKTextColorCommand_OnMouseOut()
{
	this.className='ColorDeselected';

⌨️ 快捷键说明

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