PDA

View Full Version : How to create a plugin



galdaka
4 Dec 2007, 11:19 AM
I

tidal
4 Dec 2007, 11:33 AM
Hi!
I am working on a tutorial on how to create Plugins.
(I hope I will finish it soon, cause I do it in my spare time.)

There is not much documentation on Plugins out there right now.
The only doc source I know is the Config part of the Ext.Component
docs and its derived Elements.
This is:

plugins : Object/Array

An object or array of objects that will provide custom functionality for this component. The only requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component. When a component is created, if any plugins are available, the component will call the init method on each plugin, passing a reference to itself. Each plugin can then call methods or respond to events on the component as needed to provide its functionality.


I have experimented a lot with the plugin ability. So if you have a specific question,
may I can help you.

Timo

galdaka
4 Dec 2007, 11:44 AM
Thanks for your fast reply,

Sorry for my English,

I

tidal
4 Dec 2007, 12:18 PM
Hhm ok, lets try!

To be a plugin all your code needs is a init() method, which accepts
a reference to the Container. The Conatiner in this case is a Panel.
If this class Ext.ux.Domino.Outline is allready existing you can act in
two ways: You can give it a appropriate init() method or you can wrap
a plugin around it.
The second one might be the better solution.

Plugins can act in two ways:
They can be defined in the plugin config of the container (like in your code above).

[...]
plugins: new Ext.ux.MyPlugin(config)
[...]


But there is another way which they can act, when the Container has
allready been rendered (Because the init() method of plugins is called
in the constructor of the Container)


var container = new Ext.Panel(config);
[...]
var plug = new Ext.ux.MyPlugin(config);
plug.init(container);

If the second one works depends on the design of your plugin (What does it do?).

In your case I

galdaka
4 Dec 2007, 12:50 PM
Ok. I understand.

But I have a problem:


var menu = new Ext.ux.Domino.Outline(config);

Is asynchronous code, and
container.add(menu); is executed before than
var menu = new Ext.ux.Domino.Outline(config);

Any ideas?

Thanks in advance,

tidal
4 Dec 2007, 1:10 PM
Any ideas?


Yes! In that case you may take a look at my
Ext.ux.Plugin.RemoteComponent (http://extjs.com/forum/showthread.php?t=18023)

If it doesn

galdaka
4 Dec 2007, 2:28 PM
I finish the plugin without your remote component. Works perfect! ;)

Thanks for your help,

You can view the results in http://www.galdaka.es

brian.moeskau
4 Dec 2007, 2:51 PM
Please, please, do not ever resize my browser to full screen. Ever. Seriously.

My screen reso. is 2560 x 1600. If you are telling me that you know better than me how big my browser should be, then you at least better make sure your header is wide enough not to repeat. ;)

galdaka
5 Dec 2007, 11:19 AM
Please, please, do not ever resize my browser to full screen. Ever. Seriously.

My screen reso. is 2560 x 1600. If you are telling me that you know better than me how big my browser should be, then you at least better make sure your header is wide enough not to repeat. ;)

Ok. I removed the maximize script.

I make the header too big.

I can test with 2500x1600 resolution because my PC is old. You can view correctly http://www.galdaka.es

Thanks in advance,

brian.moeskau
5 Dec 2007, 3:06 PM
Thanks. Much better now. Your visitors will thank me :))