Chinaunix首页 | 论坛 | 博客
  • 博客访问: 740334
  • 博文数量: 60
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 2090
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-27 12:33
文章分类

全部博文(60)

文章存档

2008年(60)

我的朋友

分类: 系统运维

2008-03-05 21:47:34

var oFCKeditorOptions = {
    BasePath : 'fckeditor/',   
    Config : {   
        ProcessHTMLEntities : true,   
        ProcessNumericEntities : false,   
        StartupShowBlocks : false,   
        ToolbarCanCollapse : false       
    },   
    ToolbarSet : 'Default'  
};

Ext.form.FCKeditor = function(config){
 Ext.form.FCKeditor.superclass.constructor.call(this, config);
 this.FCKid=0;
 this.MyisLoaded=false;
 this.MyValue='';
};

Ext.extend(Ext.form.FCKeditor, Ext.form.TextArea,  {
 onRender : function(ct, position){
        if(!this.el){
            this.defaultAutoCreate = {
                tag: "textarea",
                style:"width:100px;height:60px;",
                autocomplete: "off"
            };
        }
        Ext.form.TextArea.superclass.onRender.call(this, ct, position);
        if(this.grow){
            this.textSizeEl = Ext.DomHelper.append(document.body, {
                tag: "pre", cls: "x-form-grow-sizer"
            });
            if(this.preventScrollbars){
                this.el.setStyle("overflow", "hidden");
            }
            this.el.setHeight(this.growMin);
        }
  if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value()
  setTimeout("loadFCKeditor('"+this.name+"');",100);
    },
    setValue : function(value){
     this.MyValue=value;
     if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value()
     FCKeditorSetValue(this.FCKid,this.name,value)
     Ext.form.TextArea.superclass.setValue.apply(this,[value]);
    },
   
  
   
    getValue : function(){
     if (this.MyisLoaded){
      value=FCKeditorGetValue(this.name);
      Ext.form.TextArea.superclass.setValue.apply(this,[value]);
   return Ext.form.TextArea.superclass.getValue(this);
     }else{
      return this.MyValue;
     }
    },
   
    getRawValue : function(){
     if (this.MyisLoaded){
      value=FCKeditorGetValue(this.name);
      Ext.form.TextArea.superclass.setRawValue.apply(this,[value]);
   return Ext.form.TextArea.superclass.getRawValue(this);
     }else{
      return this.MyValue;
     }
    }
});
Ext.reg('fckeditor', Ext.form.FCKeditor);


function loadFCKeditor(element){
 oFCKeditor = new FCKeditor( element ) ;
 oFCKeditor.ToolbarSet = sFCKeditorToolbar ;
 oFCKeditor.Config['SkinPath'] = sFCKeditorSkinPath ;
 oFCKeditor.Config['PreloadImages'] = sFCKeditorSkinPath + 'images/toolbar.start.gif' + ';' +
    sFCKeditorSkinPath + 'images/toolbar.end.gif' + ';' +
    sFCKeditorSkinPath + 'images/toolbar.bg.gif' + ';' +
    sFCKeditorSkinPath + 'images/toolbar.buttonarrow.gif' ;
 oFCKeditor.BasePath = sFCKeditorBasePath ;
 oFCKeditor.Config['BaseHref'] = sFCKeditorBaseHref ;
 oFCKeditor.Height = 260 ;
 oFCKeditor.ReplaceTextarea() ;

}
function FCKeditor_OnComplete(editorInstance){

    Ext.getCmp(editorInstance.Name).MyisLoaded=true;

    editorInstance.Events.AttachEvent('OnStatusChange', function(){
     Ext.getCmp(editorInstance.Name).setValue();
    })
}
var FCKeditor_value=new Array();
function FCKeditorSetValue(id,name,value){
 if ((id!=undefined)&&(name!=undefined)){
  if (value!=undefined) FCKeditor_value[id]=value;
  else if (FCKeditor_value[id]==undefined) FCKeditor_value[id]='';
  var oEditor = FCKeditorAPI.GetInstance(name) ;
  
  if(oEditor!=undefined) oEditor.SetData(FCKeditor_value[id])
 }
}
function FCKeditorGetValue(name){
 if ((id!=undefined)&&(name!=undefined)){
  var oEditor = FCKeditorAPI.GetInstance(name) ;
  data='';
  if(oEditor!=undefined) data=oEditor.GetData()
  return data;
 }
}
var FCKeditor_id_value;
function get_FCKeditor_id_value(){
 if (!FCKeditor_id_value){
  FCKeditor_id_value=0;
 }
 FCKeditor_id_value=FCKeditor_id_value+1;
 return FCKeditor_id_value;
}

 

{   
                xtype: 'fckeditor',   
                name: 'n_context',   
                id: 'n_context',   
                fieldLabel: '内容',   
                height: 550
            }

 

 

测试成功

哈哈哈哈!!!!!!!!!!!!!!!!!

阅读(3553) | 评论(3) | 转发(0) |
0

上一篇:没有了

下一篇:FCKeditor JS API

给主人留下些什么吧!~~

chinaunix网友2008-12-07 00:21:24

按你这个不成功,官方论坛里的那个也没搞成,总是提示fckeditAPI错误,有啥问题啊?

xiang5882008-03-09 16:01:41

重新在EXT的官方论坛上找到了个源码 问题解决 哈哈哈 需要的加我QQ

chinaunix网友2008-03-08 08:41:18

你好!在EXT2.0中整合FCKeditor出现问题,也按照你所提供的以上代码也不行,能把EXT2.0中整合FCKeditor关键的地方说明下.谢谢! 我的邮件:myflying07@126.com