PDA

View Full Version : AddToHome Customizable Plugin!



MPeg
8 Oct 2011, 2:01 AM
Hi guys!
I just released my AddToHome plugin on my blog and GitHub.

This plugin creates a floating panel with "add to home" behavior. The panel position itself near the links icon in both iPhone and iPad.

There are several customizable built in options such html, dimensions, modal behavior, toolbar and "Ok" button and you can use it as base step to build your own!

(http://goo.gl/T6l1w)http://www.movableapp.com/2011/10/plugin-add-to-home/
Please posts your comments and suggestions in my blog page!

mitchellsimoens
10 Oct 2011, 6:13 AM
Why do you do this?


constructor: function(config) {
Ext.apply(this,config);
MovableApp.plugins.AddToHome.superclass.constructor.apply(this,arguments);
},

Instead of a Panel, why not use Sheet? It handles the sizing even when orientation changes.

MPeg
11 Oct 2011, 4:07 AM
Hi mitchellsimoens,
first thing: i'm new to sencha... i'm studing it since a few days so all my code may need optimization. Every comments and suggestion are welcome!




Ext.apply(this,config);

This line apply plugin's instance configuration to the object configuration itself. It is usefull to setup custom messages, ui controls etc.



MovableApp.plugins.AddToHome.superclass.constructor.apply(this,arguments);


This line call the parent class constructor to maintain initialization hierarchy. I'm on right?
After your comment i tested my component commenting and decommenting this line but things does not changes...

Can you teach me how to optimize this code?

Thank you!

mitchellsimoens
11 Oct 2011, 4:35 AM
If you don't do anything in a method then you don't need to override it. Apply the config stuff to this isn't really needed as after the constructor it will be on 'this'. You say things don't change with or without the constructor method in your plugin so that tells you that you don't need it.

MPeg
11 Oct 2011, 5:22 AM
I need to override the "construct" method because of this line.



Ext.apply(this,config);

If i comment this line the plugin will not inherit its configuration.

How to make my code better?
(I will study sheet component next days!)