PDA

View Full Version : I want to make this plug more genric and use it in 10 places in page.please explain



naveen.kumar
18 May 2012, 4:28 AM
Here is the code

ToolBarPlugin = function()
{
this.init = function(buttonGroup) {
var toolbarSeprator = Ext.extend(Ext.toolbar.Separator,{
border : 1,
cls : 'seprator'
});

var toolbarButton = Ext.extend(Ext.button.Button,{
overCls : 'blank',
listeners : {
mouseover: function() {
this.setIconCls(this.iconCls+'-hover');
},
mouseout: function() {
this.setIconCls(this.iconCls.substring(0,this.iconCls.lastIndexOf("-")));
}
}
});


var toolgroup=new Ext.create('Ext.container.ButtonGroup', {
bodyBorder : false,
border : false,
renderTo : 'header',
items: [
new toolbarButton({iconCls:'chat'}),
new toolbarSeprator(),
new toolbarButton({iconCls:'copy'}),
new toolbarSeprator(),
new toolbarButton({iconCls:'bookmark'}),
new toolbarSeprator(),
new toolbarButton({iconCls:'cut'}),
new toolbarSeprator(),
new toolbarButton({iconCls:'plus'}),
]
});

};
};


i want to use this plugin in ten places in a page.Please provide that kind of solution and also give me some links where plugin are discussed in details from starting point.

Thanks

scottmartin
18 May 2012, 9:51 AM
Moved to Q&A

Scott.

mitchellsimoens
25 May 2012, 11:05 AM
First you should not use Ext.extend, it's deprecated, Ext.define is the correct method. Each class should be in it's own file and you should not use Ext.define within application code like you are with Ext.extend. If you are using Ext.create you do not need the new keyword before it.

What is this plugin even doing? Looks like it just creates class definitions.