4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-container-Viewport'>/**
19 </span> * @class Ext.container.Viewport
20 * @extends Ext.container.Container
22 A specialized container representing the viewable application area (the browser viewport).
24 The Viewport renders itself to the document body, and automatically sizes itself to the size of
25 the browser viewport and manages window resizing. There may only be one Viewport created
28 Like any {@link Ext.container.Container Container}, a Viewport will only perform sizing and positioning
29 on its child Components if you configure it with a {@link #layout}.
31 A Common layout used with Viewports is {@link Ext.layout.container.Border border layout}, but if the
32 required layout is simpler, a different layout should be chosen.
34 For example, to simply make a single child item occupy all available space, use {@link Ext.layout.container.Fit fit layout}.
36 To display one "active" item at full size from a choice of several child items, use {@link Ext.layout.container.Card card layout}.
38 Inner layouts are available by virtue of the fact that all {@link Ext.panel.Panel Panel}s
39 added to the Viewport, either through its {@link #items}, or through the items, or the {@link #add}
40 method of any of its child Panels may themselves have a layout.
42 The Viewport does not provide scrolling, so child Panels within the Viewport should provide
43 for scrolling if needed using the {@link #autoScroll} config.
44 {@img Ext.container.Viewport/Ext.container.Viewport.png Ext.container.Viewport component}
45 An example showing a classic application border layout:
47 Ext.create('Ext.container.Viewport', {
49 renderTo: Ext.getBody(),
52 html: '<h1 class="x-panel-header">Page Title</h1>',
61 // could use a TreePanel or AccordionLayout for navigational items
66 html: 'Information goes here',
78 xtype: 'tabpanel', // TabPanel itself has no title
79 activeTab: 0, // First tab active by default
82 html: 'The first tab\'s content. Others may be added dynamically'
89 Ext.define('Ext.container.Viewport', {
90 extend: 'Ext.container.Container',
91 alias: 'widget.viewport',
92 requires: ['Ext.EventManager'],
93 alternateClassName: 'Ext.Viewport',
96 * Privatize config options which, if used, would interfere with the
97 * correct operation of the Viewport as the sole manager of the
98 * layout of the document body.
100 <span id='Ext-container-Viewport-cfg-applyTo'> /**
101 </span> * @cfg {Mixed} applyTo @hide
103 <span id='Ext-container-Viewport-cfg-allowDomMove'> /**
104 </span> * @cfg {Boolean} allowDomMove @hide
106 <span id='Ext-container-Viewport-cfg-hideParent'> /**
107 </span> * @cfg {Boolean} hideParent @hide
109 <span id='Ext-container-Viewport-cfg-renderTo'> /**
110 </span> * @cfg {Mixed} renderTo @hide
112 <span id='Ext-container-Viewport-cfg-hideParent'> /**
113 </span> * @cfg {Boolean} hideParent @hide
115 <span id='Ext-container-Viewport-cfg-height'> /**
116 </span> * @cfg {Number} height @hide
118 <span id='Ext-container-Viewport-cfg-width'> /**
119 </span> * @cfg {Number} width @hide
121 <span id='Ext-container-Viewport-cfg-autoHeight'> /**
122 </span> * @cfg {Boolean} autoHeight @hide
124 <span id='Ext-container-Viewport-cfg-autoWidth'> /**
125 </span> * @cfg {Boolean} autoWidth @hide
127 <span id='Ext-container-Viewport-cfg-deferHeight'> /**
128 </span> * @cfg {Boolean} deferHeight @hide
130 <span id='Ext-container-Viewport-cfg-monitorResize'> /**
131 </span> * @cfg {Boolean} monitorResize @hide
136 ariaRole: 'application',
137 initComponent : function() {
139 html = Ext.fly(document.body.parentNode),
141 me.callParent(arguments);
142 html.addCls(Ext.baseCSSPrefix + 'viewport');
144 html.setStyle('overflow', 'auto');
146 me.el = el = Ext.getBody();
147 el.setHeight = Ext.emptyFn;
148 el.setWidth = Ext.emptyFn;
149 el.setSize = Ext.emptyFn;
150 el.dom.scroll = 'no';
151 me.allowDomMove = false;
152 Ext.EventManager.onWindowResize(me.fireResize, me);
154 me.width = Ext.core.Element.getViewportWidth();
155 me.height = Ext.core.Element.getViewportHeight();
158 fireResize : function(w, h){
159 // setSize is the single entry point to layouts