Skip to content

Instantly share code, notes, and snippets.

@pyriand3r
Last active January 16, 2021 03:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyriand3r/be5f91ee2de560a62a82 to your computer and use it in GitHub Desktop.
Save pyriand3r/be5f91ee2de560a62a82 to your computer and use it in GitHub Desktop.
Container to integrate an Ext4/Ext5 Container into an Ext3.4 environment with use of the Ext4/Ext5 sandbox mode. This Class uses a Ext.Panel to host the Ext4-Container.
/**
* @class pyriand3r.util.Ext5Container
* This class provides a panel for an Ext5 application inside an Ext3.4 environment.
*
* @extends Ext.Panel
*/
pyriand3r.util.Ext5Container = Ext.extend(Ext.Panel, {
/**
* @constructor
* Initiate panel with Ext5 container.
*/
initComponent: function () {
var me = this;
this.components = {};
Ext.applyIf(this, {
containerConfig: {}
});
Ext.applyIf(this.containerConfig, {
layout: {
type: 'fit',
align: 'stretch'
}
});
Ext.apply(this.containerConfig, {
renderTo: this.getContainerId()
});
Ext.apply(this, {
html: '<div style="width: 100%; height: 100%;" id="' + me.getContainerId() + '"></div>',
items: {}
});
pyriand3r.util.Ext5Container.superclass.initComponent.call(this);
this.addListener('afterrender', function () {
me.getContainer();
}
);
this.addListener('resize', function (that, adjWidth, adjHeight) {
me.getContainer().setSize(adjWidth, adjHeight);
}
);
this.addListener('destroy', function () {
me.getContainer().destroy();
});
},
/**
* @method
* Return the ext5 container. Lazy
*
* @returns {Ext5.container.Container}
*/
getContainer: function () {
if (!Ext.isObject(this.components.container)) {
this.components.container = new Ext5.container.Container(this.containerConfig);
}
return this.components.container;
},
/**
* @methdo
* Return the id of the container-div.
*
* @returns {string}
*/
getContainerId: function () {
return this.id + '_container';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment