mitch_feaster
13 Aug 2009, 2:01 PM
Update: Issues with actually being able to use the htmleditor with the HtmlEditorResizer have been "fixed".
I just did a page with an htmleditor and found myself writing a few simple plugins to make my life easier that I thought I'd share :-)
The first one makes the htmleditor resizable.
The second one lets you check to see if the content in the htmleditor (or anything that extends field) has changed. I used this to simulate a "change" event on the htmleditor.
See attached screenshots. Now for some examples:
HtmlEditorResizer:
new Ext.form.HtmlEditor({
renderTo: Ext.getBody()
,width: 420
,height: 200
,plugins: [new Ext.ux.plugins.HtmlEditorResizer()] //provides resizing on htmleditor
});
You can also pass in an object with a resizeCfg property which will be applied to the Ext.Resizable created on the htmleditor:
new Ext.ux.plugins.HtmlEditorResizer({resizeCfg: {pinned: false}})StateKeeper:
var h = new Ext.form.HtmlEditor({
renderTo: Ext.getBody()
,width: 420
,height: 200
,plugins: [new Ext.ux.plugins.StateKeeper()] //provides the setMark and changedSinceMark functions
});
h.setMark('mark1')
//Do stuff
h.setMark()
//Do more stuff
h.changedSinceMark('mark1') //returns true if content in editor has changed since h.setMark('mark1')
h.changedSinceMark() //returns true if content in editor has changed since h.setMark()
I simulated a "change" event by doing this on my htmleditor config:
listeners: {
'sync': {
fn: function(editor, html) {
if (editor.changedSinceMark()) {
//changed!
this.enableSave(); //do whatever you want to do here
}
editor.setMark();
}
,scope: this //the panel
,buffer: 1000 //delay on checking for changes in editor
}
Todo: make this an actual event...
Tested in Firefox {3,3.5}, Chrome, IE 8
Screenshot:
http://extjs.com/forum/attachment.php?attachmentid=15646&stc=1&d=1250200247
I just did a page with an htmleditor and found myself writing a few simple plugins to make my life easier that I thought I'd share :-)
The first one makes the htmleditor resizable.
The second one lets you check to see if the content in the htmleditor (or anything that extends field) has changed. I used this to simulate a "change" event on the htmleditor.
See attached screenshots. Now for some examples:
HtmlEditorResizer:
new Ext.form.HtmlEditor({
renderTo: Ext.getBody()
,width: 420
,height: 200
,plugins: [new Ext.ux.plugins.HtmlEditorResizer()] //provides resizing on htmleditor
});
You can also pass in an object with a resizeCfg property which will be applied to the Ext.Resizable created on the htmleditor:
new Ext.ux.plugins.HtmlEditorResizer({resizeCfg: {pinned: false}})StateKeeper:
var h = new Ext.form.HtmlEditor({
renderTo: Ext.getBody()
,width: 420
,height: 200
,plugins: [new Ext.ux.plugins.StateKeeper()] //provides the setMark and changedSinceMark functions
});
h.setMark('mark1')
//Do stuff
h.setMark()
//Do more stuff
h.changedSinceMark('mark1') //returns true if content in editor has changed since h.setMark('mark1')
h.changedSinceMark() //returns true if content in editor has changed since h.setMark()
I simulated a "change" event by doing this on my htmleditor config:
listeners: {
'sync': {
fn: function(editor, html) {
if (editor.changedSinceMark()) {
//changed!
this.enableSave(); //do whatever you want to do here
}
editor.setMark();
}
,scope: this //the panel
,buffer: 1000 //delay on checking for changes in editor
}
Todo: make this an actual event...
Tested in Firefox {3,3.5}, Chrome, IE 8
Screenshot:
http://extjs.com/forum/attachment.php?attachmentid=15646&stc=1&d=1250200247