不做浮躁的人
正在行走的人...
posts - 171,  comments - 51,  trackbacks - 0

在弹出窗口上访问编辑器:
1、如何在编辑器中插入文本:

前置约定:
插件名:insertvariables
插件位置:editor/plugins/insertvariables/

//创建自己的命令,不采用FCKDialogCommand的目的是FCKDialogCommand使用的是fck的缺省布局。
var InsertVariableCommand=function(){
};
InsertVariableCommand.prototype.Execute=function(){
}
//让按钮不能点击。
InsertVariableCommand.GetState=function() {
        return FCK_TRISTATE_OFF; }
//打开弹出窗口
InsertVariableCommand.Execute=function() {
        window.open('insertVariable.do', 'insertVariable', 'width=500,height=400,scrollbars=no,scrolling=no,location=no,toolbar=no');
}
//注册命令:
FCKCommands.RegisterCommand('Insert_Variables', InsertVariableCommand );
//注册按钮
var oInsertVariables = new FCKToolbarButton('Insert_Variables', 'insert variable');
oInsertVariables.IconPath = FCKConfig.PluginsPath + 'insertvariables/variable.gif';
FCKToolbarItems.RegisterItem( 'Insert_Variables', oInsertVariables );

//插入变量的请求页面:insertVariable.do
<html><head> etc...
<script language="javascript">
        <!--
        var variable            = null;
        var FCK                 = window.opener.FCK;
        function ok() {
                if(variable != null) {
                        FCK.Focus();
                        //只在ie中有效 var B = FCK.EditorDocument.selection.createRange(); B.text = variable; } window.close(); } //--> </script> </head> <body> etc.. <a href="#" onClick="variable='this is a test'; ok();">insert text</a> </body> </html>

//在fckconfig.js文件中加入以下字段
FCKConfig.Plugins.Add( 'insertvariables' ) ;
FCKConfig.ToolbarSets["myToolbar"] = [
        ['Bold','Italic','Underline'],['Insert_Variables']
] ;
				2、关联上下文菜单选项:
将插件的command注册到上下文菜单中:
FCK.ContextMenu.RegisterListener( { AddItems : function( menu, tag, tagName ) { // 符合条件显示:if ( tagName == 'IMG' && !tag.getAttribute( '_fckfakelement' ) )
if ( tagName == 'SPAN' && tag._fckplaceholder ) { // 显示分隔符
menu.AddSeparator() ; // 需要注册命令名,标题,以及图片路径。
   menu.AddItem( 'placeholder', FCKLang.PlaceholderDlgTitle, oPlaceholderItem.IconPath ) ; } }} );
posted on 2007-04-10 20:21 不做浮躁的人 阅读(1183) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(9)

随笔分类(31)

随笔档案(75)

文章分类(1)

文章档案(3)

搜索

  •  

最新评论

阅读排行榜

评论排行榜