2 * @class Ext.container.Viewport
3 * @extends Ext.container.Container
5 A specialized container representing the viewable application area (the browser viewport).
7 The Viewport renders itself to the document body, and automatically sizes itself to the size of
8 the browser viewport and manages window resizing. There may only be one Viewport created
11 Like any {@link Ext.container.Container Container}, a Viewport will only perform sizing and positioning
12 on its child Components if you configure it with a {@link #layout}.
14 A Common layout used with Viewports is {@link Ext.layout.container.Border border layout}, but if the
15 required layout is simpler, a different layout should be chosen.
17 For example, to simply make a single child item occupy all available space, use {@link Ext.layout.container.Fit fit layout}.
19 To display one "active" item at full size from a choice of several child items, use {@link Ext.layout.container.Card card layout}.
21 Inner layouts are available by virtue of the fact that all {@link Ext.panel.Panel Panel}s
22 added to the Viewport, either through its {@link #items}, or through the items, or the {@link #add}
23 method of any of its child Panels may themselves have a layout.
25 The Viewport does not provide scrolling, so child Panels within the Viewport should provide
26 for scrolling if needed using the {@link #autoScroll} config.
27 {@img Ext.container.Viewport/Ext.container.Viewport.png Ext.container.Viewport component}
28 An example showing a classic application border layout:
30 Ext.create('Ext.container.Viewport', {
32 renderTo: Ext.getBody(),
35 html: '<h1 class="x-panel-header">Page Title</h1>',
44 // could use a TreePanel or AccordionLayout for navigational items
49 html: 'Information goes here',
61 xtype: 'tabpanel', // TabPanel itself has no title
62 activeTab: 0, // First tab active by default
65 html: 'The first tab\'s content. Others may be added dynamically'
71 * Create a new Viewport
72 * @param {Object} config The config object
76 Ext.define('Ext.container.Viewport', {
77 extend: 'Ext.container.Container',
78 alias: 'widget.viewport',
79 requires: ['Ext.EventManager'],
80 alternateClassName: 'Ext.Viewport',
83 * Privatize config options which, if used, would interfere with the
84 * correct operation of the Viewport as the sole manager of the
85 * layout of the document body.
88 * @cfg {Mixed} applyTo @hide
91 * @cfg {Boolean} allowDomMove @hide
94 * @cfg {Boolean} hideParent @hide
97 * @cfg {Mixed} renderTo @hide
100 * @cfg {Boolean} hideParent @hide
103 * @cfg {Number} height @hide
106 * @cfg {Number} width @hide
109 * @cfg {Boolean} autoHeight @hide
112 * @cfg {Boolean} autoWidth @hide
115 * @cfg {Boolean} deferHeight @hide
118 * @cfg {Boolean} monitorResize @hide
123 ariaRole: 'application',
124 initComponent : function() {
126 html = Ext.fly(document.body.parentNode),
128 me.callParent(arguments);
129 html.addCls(Ext.baseCSSPrefix + 'viewport');
131 html.setStyle('overflow', 'auto');
133 me.el = el = Ext.getBody();
134 el.setHeight = Ext.emptyFn;
135 el.setWidth = Ext.emptyFn;
136 el.setSize = Ext.emptyFn;
137 el.dom.scroll = 'no';
138 me.allowDomMove = false;
139 //this.autoWidth = true;
140 //this.autoHeight = true;
141 Ext.EventManager.onWindowResize(me.fireResize, me);
145 fireResize : function(w, h){
146 // setSize is the single entry point to layouts
148 //this.fireEvent('resize', this, w, h, w, h);