当前位置:编程学习 > 网站相关 >>

修改增加fcd编辑按钮 功能方法

第一步:在toolbar中添加功能按钮

fckconfig.js:fckconfig.toolbarsets[“default”] 中添加按钮名称
fckconfig.toolbarsets["default"] = [
['bold','italic','-','about', 'mydiy']
] ;

第二步:

为按钮添加中文名称和英文名称

zh-cn.js:为你的按钮起个中文名字
mydiy : “我的自定义按钮"

en.js:为你的按钮起个英文名字
mydiy:"mydiybutton"

第三步:在toolbar中显示该按钮

fckeditorcode_gecko.js(fckeditorcode_ie.js):
查找:

case 'newpage':b=new fcktoolbarbutton('newpage',fcklang.newpage,null,null,true,null,4);break;


在break后插入你的代码

比如case 'mydiy':b=new fcktoolbarbutton('mydiy',fcklang.mydiy,null,null,false,true,50);(这个50是按钮的显示图片,要让你的自定义按钮显示为插入图片那个按钮的图片,可以填入37)
这样就可以在toolbar中显示你的按钮了

第四步:定义按钮功能原型

ckeditorcode_gecko.js(fckeditorcode_ie.js):

查找:

var fcknewpagecommand=function(){this.name='newpage';};
fcknewpagecommand.prototype.execute=function(){fckundo.saveundostep();fck.sethtml('');fckundo.typing=true;};
fcknewpagecommand.prototype.getstate=function(){return fck_tristate_off;};

定义功能原型:(这里直接复newpage的实现代码放到后面,然后进行修改)

比如:var fckmydiycommand=function(){this.name='mydiy';};fckmydiycommand.prototype.execute=function(){ 这里写你所需要执行的代码或者函数,比如alert("i am here !");};fckmydiycommand.prototype.getstate=function(){return 0;};
将上面代码插入到查找内容之后。

第五步:按钮功能实例化:

ckeditorcode_gecko.js(fckeditorcode_ie.js):

查找:

case 'newpage':b=new fcknewpagecommand();break;


功能实例化:

case 'mydiy':b=new fckmydiycommand();break;


将上面代码插入到查找内容之后。

ok,这样就可以在为fckeditor加上自定义的按钮了。

如果要为按钮加上快捷键,可以在fckconfig.js中:fckconfig.keystrokes = []加上
[ ctrl + 71 /*g*/, 'mydiy' ],

补充:网页制作,设计基础 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,