重写Ext.form.HtmlEditor
来源:互联网 发布:sql语句更改字段类型 编辑:程序博客网 时间:2024/05/19 15:39
Ext.override(Ext.form.HtmlEditor, { initEditor : function(){ var dbody = this.getEditorBody(); var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat'); ss['background-attachment'] = 'fixed'; ss['background-color'] = 'white'; dbody.bgProperties = 'fixed'; Ext.DomHelper.applyStyles(dbody, ss); if(this.doc){ try{ Ext.EventManager.removeAll(this.doc); }catch(e){} } this.doc = this.getDoc(); Ext.EventManager.on(this.doc, { 'mousedown': this.onEditorEvent, 'dblclick': this.onEditorEvent, 'click': this.onEditorEvent, 'keyup': this.onEditorKeyUpEvent, 'keydown': this.onEditorKeyDownEvent, 'keypress': this.onEditorKeyPressEvent, buffer:100, scope: this }); if(Ext.isGecko){ Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this); } if(Ext.isIE || Ext.isSafari || Ext.isOpera){ Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this); } this.initialized = true; this.fireEvent('initialize', this); this.doc.editorInitialized = true; this.pushValue(); }, initComponent: function () { this.addEvents( 'initialize', 'activate', 'beforesync', 'beforepush', 'sync', 'push', 'editmodechange', 'keydown', 'keyup', 'keypress' ); }, onEditorKeyPressEvent : function(e){ this.updateToolbar(); this.fireEvent("keypress", this, e); }, onEditorKeyUpEvent : function(e){ this.updateToolbar(); this.fireEvent("keyup", this, e); }, onEditorKeyDownEvent : function(e){ this.updateToolbar(); this.fireEvent("keydown", this, e); } }); Ext.ns("Ext.hoo.editor"); Ext.hoo.editor.HTMLEditor = Ext.extend(Ext.form.HtmlEditor, { constructor: function () { Ext.hoo.editor.HTMLEditor.superclass.constructor.call(this, { renderTo: Ext.getBody(), fieldLabel:'Biography', height:200, listeners: { "keydown": function (editor, e) { alert("keydown:" + editor.getValue()); }, "keyup": function (editor, e) { alert("keyup:" + editor.getValue()); }, "keypress": function (editor, e) { alert("keypress:" + editor.getValue()); } } }); } });