PDA

View Full Version : wRite a Plugins



abys
2 Feb 2008, 1:40 PM
can you help me, it tryed to write a plugins, but some there are some errors :
I try to add a button in the HtmlEditor. Directly in the "onready" my script work perfectly, but i want to transform my scipt to a plugins or is there a good tuto to make plugins. Thanks

var scriptEditor = new Ext.form.HtmlEditor({
id:'htmlEd',
fieldLabel:'',
width:550,
height:200,
plugins: new Ext.ux.plugins.scriptEditor([{arg1:'test
}])
});


//Plugins

Ext.namespace('Ext.ux', 'Ext.ux.plugins');

Ext.ux.plugins.scriptEditor = function(config) {
Ext.apply(this, config);
};
Ext.extend(Ext.ux.plugins.GroupHeaderGrid, Ext.util.Observable, {
init : function(htmlEditor) {
alert (htmlEditor);
this.editor = htmlEditor;
this.editor.on('render', onRender, this);
};

inputTextButton : function(){
var range;
if(Ext.isIE) {
range = this.editor.doc.selection.createRange();
range.select();
}
var dbody = this.editor.getEditorBody();
Ext.DomHelper.insertHtml('afterbegin', dbody,'<input id="test" style="LEFT: 0px; POSITION: absolute; TOP: 20px" type=text>');
}

onRender : function () {
if (!Ext.isSafari) {
var tb = this.editor.getToolbar();
tb.addSeparator();
var spellBtn = new Ext.Toolbar.Button ({
icon: '{/literal}{$j_themepath}{literal}images/btn-arrow.gif',
id: 'spelling',
cls: 'x-btn-text-icon',
tooltip: 'Infos',
//handler:inputTextButton,
disabled :false

});
tb.addButton (spellBtn);
}
}
)};

halkon_polako
3 Feb 2008, 12:15 PM
Please, put your code inside [ code ] and [ /code ] tags to can read it easier.
A tutorial (theory and coding) to writing a plugin is on http://extjs.com/learn/Tutorial:Writing_Ext_2_Plugins.

But, by now, I can see in your code:


....
Ext.extend(Ext.ux.plugins.GroupHeaderGrid, Ext.util.Observable,
....

Be careful with copy&paste. /:)