太牛了,在ext里面用fckeditor~~~
softfire
2008-08-13
转自:http://www.17ext.com/showtopic-250.aspx
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 } ![]() |
|
rikugun
2008-08-14
|
|
vb2005xu
2008-08-21
感觉这个太复杂了,可以参考我写的'EXT/FCKEditor 集成 -- AJAX UI -- 一种web开发的新的思维',没有多少行代码,
|
|
vb2005xu
2008-08-21
Ext.onReady(function() { var fckFormObj = new Ext.FormPanel({ labelWidth:75, url:"", title:"EXT/FCKEditor 集成 -- vb2005xu | cdlinux.ys168.com", bodyStyle:"padding:5px 5px 0", defaultType:"form", buttons:[ { text:"Save" , type:'submit', handler: function(){ //获取fckeditor内容赋给textarea Ext.get('fckInstance').dom.value = "jjj";//fckobj.GetXHTML(true) + '提交后'; Ext.MessageBox.alert('FCK内容',Ext.get('fckInstance').dom.value); if (fckFormObj.form.isValid()) { //创建响应测试函数 var fckobj_temp = FCKeditorAPI.GetInstance('fckInstance'); //fckobj_temp.UpdateLinkedField();//此方法被绑定到submit事件 fckFormObj.form.doAction('submit',{ url:'submit.php', method:'post', waitMsg:'正在提交,请稍等...', success:function(form,action){//成功 showInfo('Success',fckobj_temp.GetXHTML(true)); } , failure:function(form,action){//失败 showInfo('Failed','网络中断造成连接失败'); } }); } } }, { text:"Cancel" } ], items:[{ xtype:"textarea", fieldLabel:"编辑", labelSeparator:":", id:"fckInstance", //div节点,这里要挂接FCKeditor编辑器 name:"fckInstance", width:736, height:371 }] }); fckFormObj.render(document.body); /*创建Fckeditor对象 -- 构造函数指出了Fckeditor要挂接的id,上文中的xtype : 'textarea'指定*/ //在页面上要求挂载fckeditor/fckeditor.js文件 var fckobj = new FCKeditor('fckInstance',810,350); fckobj.BasePath = "/ucren/fckeditor/" ; fckobj.ToolbarSet = 'Default' ; fckobj.ReplaceTextarea(); //创建响应测试函数 function msgBox() { var fckobj_temp = FCKeditorAPI.GetInstance('fckInstance'); fckobj_temp.UpdateLinkedField();//此方法被绑定到submit事件 Ext.MessageBox.alert('FCK内容',fckobj_temp.GetXHTML( true )); } function showInfo(tip,str){ var win = new Ext.Window({ title: '信息提交应答提示 -- ' + tip, width: 400 , height: 200 ,autoScroll: true , html: '<h1>'+ str +'</h1>' }); win.show(); } }); |
相关讨论
相关资源推荐
- 《深度探索C++对象模型》..............
- [读书笔记] - 《深度探索C++对象模型》第5章 构造、解构、拷贝语意学
- 深度探索C++对象模型 侯捷
- C++对象构造与析构全流程
- Inside The C++ Object Model(五)构造、拷贝、析构语意学
- Apache+php+mysql在windows下的安装与配置图解
- 网络编程资源大集合(包含前端、java、linux、安卓、github开源项目、开发工具等)
- GitHub 优秀的 Android 开源项目 淘宝技术牛p博客整理开发中最常用的GitHub上 优秀的 Android 开源项目整理(精品)...
- 【Android 应用开发】GitHub 优秀的 Android 开源项目
- 浪潮实习第七天