3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.Viewport"></div>/**
\r
15 * @class Ext.Viewport
\r
16 * @extends Ext.Container
\r
17 * <p>A specialized container representing the viewable application area (the browser viewport).</p>
\r
18 * <p>The Viewport renders itself to the document body, and automatically sizes itself to the size of
\r
19 * the browser viewport and manages window resizing. There may only be one Viewport created
\r
20 * in a page. Inner layouts are available by virtue of the fact that all {@link Ext.Panel Panel}s
\r
21 * added to the Viewport, either through its {@link #items}, or through the items, or the {@link #add}
\r
22 * method of any of its child Panels may themselves have a layout.</p>
\r
23 * <p>The Viewport does not provide scrolling, so child Panels within the Viewport should provide
\r
24 * for scrolling if needed using the {@link #autoScroll} config.</p>
\r
25 * <p>An example showing a classic application border layout:</p><pre><code>
\r
30 html: '<h1 class="x-panel-header">Page Title</h1>',
\r
37 title: 'Navigation',
\r
39 // the west region might typically utilize a {@link Ext.tree.TreePanel TreePanel} or a Panel with {@link Ext.layout.AccordionLayout Accordion layout}
\r
42 title: 'Title for Panel',
\r
44 html: 'Information goes here',
\r
50 title: 'Title for the Grid Panel',
\r
55 // remaining grid configuration not shown ...
\r
56 // notice that the GridPanel is added directly as the region
\r
57 // it is not "overnested" inside another Panel
\r
60 xtype: 'tabpanel', // TabPanel itself has no title
\r
62 title: 'Default Tab',
\r
63 html: 'The first tab\'s content. Others may be added dynamically'
\r
69 * Create a new Viewport
\r
70 * @param {Object} config The config object
\r
73 Ext.Viewport = Ext.extend(Ext.Container, {
\r
75 * Privatize config options which, if used, would interfere with the
\r
76 * correct operation of the Viewport as the sole manager of the
\r
77 * layout of the document body.
\r
79 <div id="cfg-Ext.Viewport-applyTo"></div>/**
\r
80 * @cfg {Mixed} applyTo @hide
\r
82 <div id="cfg-Ext.Viewport-allowDomMove"></div>/**
\r
83 * @cfg {Boolean} allowDomMove @hide
\r
85 <div id="cfg-Ext.Viewport-hideParent"></div>/**
\r
86 * @cfg {Boolean} hideParent @hide
\r
88 <div id="cfg-Ext.Viewport-renderTo"></div>/**
\r
89 * @cfg {Mixed} renderTo @hide
\r
91 <div id="cfg-Ext.Viewport-hideParent"></div>/**
\r
92 * @cfg {Boolean} hideParent @hide
\r
94 <div id="cfg-Ext.Viewport-height"></div>/**
\r
95 * @cfg {Number} height @hide
\r
97 <div id="cfg-Ext.Viewport-width"></div>/**
\r
98 * @cfg {Number} width @hide
\r
100 <div id="cfg-Ext.Viewport-autoHeight"></div>/**
\r
101 * @cfg {Boolean} autoHeight @hide
\r
103 <div id="cfg-Ext.Viewport-autoWidth"></div>/**
\r
104 * @cfg {Boolean} autoWidth @hide
\r
106 <div id="cfg-Ext.Viewport-deferHeight"></div>/**
\r
107 * @cfg {Boolean} deferHeight @hide
\r
109 <div id="cfg-Ext.Viewport-monitorResize"></div>/**
\r
110 * @cfg {Boolean} monitorResize @hide
\r
112 initComponent : function() {
\r
113 Ext.Viewport.superclass.initComponent.call(this);
\r
114 document.getElementsByTagName('html')[0].className += ' x-viewport';
\r
115 this.el = Ext.getBody();
\r
116 this.el.setHeight = Ext.emptyFn;
\r
117 this.el.setWidth = Ext.emptyFn;
\r
118 this.el.setSize = Ext.emptyFn;
\r
119 this.el.dom.scroll = 'no';
\r
120 this.allowDomMove = false;
\r
121 this.autoWidth = true;
\r
122 this.autoHeight = true;
\r
123 Ext.EventManager.onWindowResize(this.fireResize, this);
\r
124 this.renderTo = this.el;
\r
127 fireResize : function(w, h){
\r
128 this.fireEvent('resize', this, w, h, w, h);
\r
131 Ext.reg('viewport', Ext.Viewport);</pre>