| OLD | NEW |
| (Empty) |
| 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.g
ithub.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/CONTRI
BUTORS.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/PATEN
TS.txt | |
| 8 --> | |
| 9 | |
| 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. | |
| 14 | |
| 15 Example: | |
| 16 | |
| 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> | |
| 28 | |
| 29 Use `mode` to control the header and scrolling behavior of `core-header-panel` | |
| 30 and `responsiveWidth` to change the layout of the scaffold. | |
| 31 | |
| 32 To have the content fits to the main area, use `fit` attribute. | |
| 33 | |
| 34 <core-scaffold> | |
| 35 <core-header-panel navigation flex mode="seamed"> | |
| 36 .... | |
| 37 </core-header-panel> | |
| 38 <div tool>Title</div> | |
| 39 <div fit>Content fits to the main area</div> | |
| 40 </core-scaffold> | |
| 41 | |
| 42 @group Polymer Core Elements | |
| 43 @element core-scaffold | |
| 44 @homepage github.io | |
| 45 --> | |
| 46 | |
| 47 <link rel="import" href="../core-toolbar/core-toolbar.html"> | |
| 48 <link rel="import" href="../core-drawer-panel/core-drawer-panel.html"> | |
| 49 <link rel="import" href="../core-header-panel/core-header-panel.html"> | |
| 50 <link rel="import" href="../core-icon-button/core-icon-button.html"> | |
| 51 | |
| 52 <polymer-element name="core-scaffold"> | |
| 53 <template> | |
| 54 | |
| 55 <style> | |
| 56 | |
| 57 :host { | |
| 58 display: block; | |
| 59 } | |
| 60 | |
| 61 [drawer] { | |
| 62 background-color: #fff; | |
| 63 box-shadow: 1px 0 1px rgba(0, 0, 0, 0.1); | |
| 64 } | |
| 65 | |
| 66 [main] { | |
| 67 height: 100%; | |
| 68 background-color: #eee; | |
| 69 } | |
| 70 | |
| 71 core-toolbar { | |
| 72 background-color: #526E9C; | |
| 73 color: #fff; | |
| 74 } | |
| 75 | |
| 76 #drawerPanel:not([narrow]) #menuButton { | |
| 77 display: none; | |
| 78 } | |
| 79 | |
| 80 </style> | |
| 81 | |
| 82 <core-drawer-panel id="drawerPanel" narrow="{{narrow}}" responsiveWidth="{{res
ponsiveWidth}}"> | |
| 83 | |
| 84 <div vertical layout drawer> | |
| 85 | |
| 86 <content select="[navigation], nav"></content> | |
| 87 | |
| 88 </div> | |
| 89 | |
| 90 <core-header-panel id="headerPanel" main mode="{{mode}}"> | |
| 91 | |
| 92 <core-toolbar> | |
| 93 <core-icon-button id="menuButton" icon="menu" on-tap="{{togglePanel}}"><
/core-icon-button> | |
| 94 <content select="[tool]"></content> | |
| 95 </core-toolbar> | |
| 96 | |
| 97 <content select="*"></content> | |
| 98 | |
| 99 </core-header-panel> | |
| 100 | |
| 101 </core-drawer-panel> | |
| 102 | |
| 103 </template> | |
| 104 <script> | |
| 105 | |
| 106 Polymer('core-scaffold', { | |
| 107 | |
| 108 /** | |
| 109 * Fired when the main content has been scrolled. `event.detail.target` ret
urns | |
| 110 * the scrollable element which you can use to access scroll info such as | |
| 111 * `scrollTop`. | |
| 112 * | |
| 113 * <core-scaffold on-scroll="{{scrollHandler}}"> | |
| 114 * ... | |
| 115 * </core-scaffold> | |
| 116 * | |
| 117 * | |
| 118 * scrollHandler: function(event) { | |
| 119 * var scroller = event.detail.target; | |
| 120 * console.log(scroller.scrollTop); | |
| 121 * } | |
| 122 * | |
| 123 * @event scroll | |
| 124 */ | |
| 125 | |
| 126 publish: { | |
| 127 /** | |
| 128 * When the browser window size is smaller than the `responsiveWidth`, | |
| 129 * `core-drawer-panel` changes to a narrow layout. In narrow layout, | |
| 130 * the drawer will be stacked on top of the main panel. | |
| 131 * | |
| 132 * @attribute responsiveWidth | |
| 133 * @type string | |
| 134 * @default '600px' | |
| 135 */ | |
| 136 responsiveWidth: '600px', | |
| 137 | |
| 138 /** | |
| 139 * Used to control the header and scrolling behaviour of `core-header-pane
l` | |
| 140 * | |
| 141 * @attribute mode | |
| 142 * @type string | |
| 143 * @default 'seamed' | |
| 144 */ | |
| 145 mode: {value: 'seamed', reflect: true} | |
| 146 }, | |
| 147 | |
| 148 ready: function() { | |
| 149 this._scrollHandler = this.scroll.bind(this); | |
| 150 this.$.headerPanel.addEventListener('scroll', this._scrollHandler); | |
| 151 }, | |
| 152 | |
| 153 detached: function() { | |
| 154 this.$.headerPanel.removeEventListener('scroll', this._scrollHandler); | |
| 155 }, | |
| 156 | |
| 157 /** | |
| 158 * Toggle the drawer panel | |
| 159 * @method togglePanel | |
| 160 */ | |
| 161 togglePanel: function() { | |
| 162 this.$.drawerPanel.togglePanel(); | |
| 163 }, | |
| 164 | |
| 165 /** | |
| 166 * Open the drawer panel | |
| 167 * @method openDrawer | |
| 168 */ | |
| 169 openDrawer: function() { | |
| 170 this.$.drawerPanel.openDrawer(); | |
| 171 }, | |
| 172 | |
| 173 /** | |
| 174 * Close the drawer panel | |
| 175 * @method closeDrawer | |
| 176 */ | |
| 177 closeDrawer: function() { | |
| 178 this.$.drawerPanel.closeDrawer(); | |
| 179 }, | |
| 180 | |
| 181 scroll: function(e) { | |
| 182 this.fire('scroll', {target: e.detail.target}, this, false); | |
| 183 } | |
| 184 | |
| 185 }); | |
| 186 | |
| 187 </script> | |
| 188 </polymer-element> | |
| OLD | NEW |