Update {virtual,override,final} to follow C++11 style.
[chromium-blink-merge.git] / third_party / polymer / components / core-scaffold / core-scaffold.html
blobd789b19861fb546d0dcdfbe11a50ec01b2a3bf6f
1 <!--
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8 -->
10 <!--
11 `core-scaffold` provides general application layout, introducing a
12 responsive scaffold containing a header, toolbar, menu, title and
13 areas for application content.
15 Example:
17 <core-scaffold>
18 <core-header-panel navigation flex mode="seamed">
19 <core-toolbar>Application</core-toolbar>
20 <core-menu theme="core-light-theme">
21 <core-item icon="settings" label="item1"></core-item>
22 <core-item icon="settings" label="item2"></core-item>
23 </core-menu>
24 </core-header-panel>
25 <div tool>Title</div>
26 <div>Main content goes here...</div>
27 </core-scaffold>
29 Use `mode` to control the header and scrolling behavior of `core-header-panel`
30 and `responsiveWidth` to change the layout of the scaffold. Use 'disableSwipe'
31 to disable swipe-to-open on toolbar.
33 Use `rightDrawer` to move position of folding toolbar to the right instead of
34 left (default). This will also position content to the left of the menu button
35 instead of the right. You can use `flex` within your `tool` content to push the menu
36 button to the far right:
38 <core-scaffold rightDrawer>
39 <div tool flex >Title</div>
40 </core-scaffold>
42 You may also add `middle` or `bottom` classes to your `tool` content when using tall
43 modes to adjust vertical content positioning in the core-toolbar (e.g. when using
44 mode="waterfall-tall"):
46 <core-scaffold rightDrawer mode="waterfall-tall">
47 <div tool flex >Title</div>
48 <div tool horizontal layout flex center-justified class="middle">Title-middle</div>
49 <div tool horizontal layout flex end-justified class="bottom">Title-bottom</div>
50 </core-scaffold>
52 To have the content fit to the main area, use `fit` attribute.
54 <core-scaffold>
55 <core-header-panel navigation flex mode="seamed">
56 ....
57 </core-header-panel>
58 <div tool>Title</div>
59 <div fit>Content fits to the main area</div>
60 </core-scaffold>
62 @group Polymer Core Elements
63 @element core-scaffold
64 @homepage github.io
65 -->
67 <link rel="import" href="../core-toolbar/core-toolbar.html">
68 <link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
69 <link rel="import" href="../core-header-panel/core-header-panel.html">
70 <link rel="import" href="../core-icon-button/core-icon-button.html">
72 <polymer-element name="core-scaffold">
73 <template>
75 <style>
77 :host {
78 display: block;
81 [drawer] {
82 background-color: #fff;
83 box-shadow: 1px 0 1px rgba(0, 0, 0, 0.1);
86 [main] {
87 height: 100%;
88 background-color: #eee;
91 core-toolbar {
92 background-color: #526E9C;
93 color: #fff;
96 #drawerPanel:not([narrow]) #menuButton {
97 display: none;
100 </style>
102 <core-drawer-panel id="drawerPanel" narrow="{{narrow}}" drawerWidth="{{drawerWidth}}" rightDrawer="{{rightDrawer}}" responsiveWidth="{{responsiveWidth}}" disableSwipe="{{disableSwipe}}">
104 <div vertical layout drawer>
106 <content select="[navigation], nav"></content>
108 </div>
110 <core-header-panel id="headerPanel" main mode="{{mode}}">
112 <core-toolbar>
113 <template if="{{!rightDrawer}}">
114 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"></core-icon-button>
115 </template>
116 <content select="[tool]"></content>
117 <template if="{{rightDrawer}}">
118 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"></core-icon-button>
119 </template>
120 </core-toolbar>
122 <content select="*"></content>
124 </core-header-panel>
126 </core-drawer-panel>
128 </template>
129 <script>
131 Polymer('core-scaffold', {
134 * Fired when the main content has been scrolled. `event.detail.target` returns
135 * the scrollable element which you can use to access scroll info such as
136 * `scrollTop`.
138 * <core-scaffold on-scroll="{{scrollHandler}}">
139 * ...
140 * </core-scaffold>
143 * scrollHandler: function(event) {
144 * var scroller = event.detail.target;
145 * console.log(scroller.scrollTop);
148 * @event scroll
151 publish: {
154 * Width of the drawer panel.
156 * @attribute drawerWidth
157 * @type string
158 * @default '256px'
160 drawerWidth: '256px',
163 * When the browser window size is smaller than the `responsiveWidth`,
164 * `core-drawer-panel` changes to a narrow layout. In narrow layout,
165 * the drawer will be stacked on top of the main panel.
167 * @attribute responsiveWidth
168 * @type string
169 * @default '600px'
171 responsiveWidth: '600px',
174 * If true, position the drawer to the right. Also place menu icon to
175 * the right of the content instead of left.
177 * @attribute rightDrawer
178 * @type boolean
179 * @default false
181 rightDrawer: false,
184 * If true, swipe to open/close the drawer is disabled.
186 * @attribute disableSwipe
187 * @type boolean
188 * @default false
190 disableSwipe: false,
193 * Used to control the header and scrolling behaviour of `core-header-panel`
195 * @attribute mode
196 * @type string
197 * @default 'seamed'
199 mode: {value: 'seamed', reflect: true}
202 ready: function() {
203 this._scrollHandler = this.scroll.bind(this);
204 this.$.headerPanel.addEventListener('scroll', this._scrollHandler);
207 detached: function() {
208 this.$.headerPanel.removeEventListener('scroll', this._scrollHandler);
212 * Toggle the drawer panel
213 * @method togglePanel
215 togglePanel: function() {
216 this.$.drawerPanel.togglePanel();
220 * Open the drawer panel
221 * @method openDrawer
223 openDrawer: function() {
224 this.$.drawerPanel.openDrawer();
228 * Close the drawer panel
229 * @method closeDrawer
231 closeDrawer: function() {
232 this.$.drawerPanel.closeDrawer();
236 * Returns the scrollable element on the main area.
238 * @property scroller
239 * @type Object
241 get scroller() {
242 return this.$.headerPanel.scroller;
245 scroll: function(e) {
246 this.fire('scroll', {target: e.detail.target}, this, false);
251 </script>
252 </polymer-element>