Home | History | Annotate | Download | only in demo
      1 <!doctype html>
      2 <!--
      3 @license
      4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
      5 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
      6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
      7 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
      8 Code distributed by Google as part of the polymer project is also
      9 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
     10 -->
     11 <html>
     12 
     13 <head>
     14 
     15   <title>simple-overlay demo</title>
     16 
     17   <meta charset="utf-8">
     18   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     19   <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
     20 
     21   <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
     22 
     23   <link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
     24   <link rel="import" href="simple-overlay.html">
     25   <link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
     26   <link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html">
     27 
     28   <style is="custom-style" include="demo-pages-shared-styles">
     29     demo-snippet {
     30       --demo-snippet-code: {
     31         max-height: 250px;
     32       }
     33     }
     34   </style>
     35 
     36 </head>
     37 
     38 <body unresolved class="centered">
     39 
     40   <h3>An element with <code>IronOverlayBehavior</code> can be opened, closed, toggled.</h3>
     41   <demo-snippet>
     42     <template>
     43       <button onclick="plain.open()">Plain overlay</button>
     44       <simple-overlay id="plain" tabindex=-1>
     45         <h2>Hello world!</h2>
     46         <p>This can be closed by pressing the ESC key too.</p>
     47         <button onclick="plain.close()">Close</button>
     48       </simple-overlay>
     49     </template>
     50   </demo-snippet>
     51 
     52   <h3>Use <code>with-backdrop</code> to add a backdrop to your overlay. Tabbing will be trapped within the overlay.</h3>
     53   <demo-snippet>
     54     <template>
     55       <button onclick="backdrop.open()">Overlay with backdrop</button>
     56       <simple-overlay id="backdrop" with-backdrop>
     57         <p>Hello world!</p>
     58         <button>Button</button>
     59         <button onclick="backdrop.close()">Close</button>
     60       </simple-overlay>
     61     </template>
     62   </demo-snippet>
     63 
     64   <h3>Use <code>restore-focus-on-close</code> to return the focus to the element that opened the overlay when it gets closed.</h3>
     65   <demo-snippet>
     66     <template>
     67       <button onclick="returnFocus.open()">Overlay that restores focus</button>
     68       <simple-overlay id="returnFocus" restore-focus-on-close>
     69         <p>Hello world!</p>
     70         <button onclick="returnFocus.close()">Close</button>
     71       </simple-overlay>
     72     </template>
     73   </demo-snippet>
     74 
     75   <h3>The child with <code>autofocus</code> gets focused when opening the overlay.</h3>
     76   <demo-snippet>
     77     <template>
     78       <button onclick="withAutofocus.open()">Overlay with autofocus child</button>
     79       <simple-overlay id="withAutofocus">
     80         <p>Hello world!</p>
     81         <button autofocus>autofocus</button>
     82         <button onclick="withAutofocus.close()">Close</button>
     83       </simple-overlay>
     84     </template>
     85   </demo-snippet>
     86 
     87   <h3>Multiple overlays can be opened.</h3>
     88   <demo-snippet>
     89     <template>
     90       <button onclick="multiple.open()">Open first overlay</button>
     91       <simple-overlay id="multiple" tabindex=-1>
     92         <p>click to open another overlay</p>
     93         <button onclick="multiple2.open()">Open second overlay</button>
     94         <button onclick="multiple.close()">Close this</button>
     95       </simple-overlay>
     96       <simple-overlay id="multiple2" tabindex=-1>
     97         <h2>Hi!</h2>
     98         <button onclick="multiple2.close()">Close</button>
     99       </simple-overlay>
    100     </template>
    101   </demo-snippet>
    102 
    103   <h3>Use <code>always-on-top</code> to keep the overlay on top of others.</h3>
    104   <demo-snippet>
    105     <template>
    106       <button onclick="onTop.open()">Open always-on-top</button>
    107       <simple-overlay id="onTop" always-on-top tabindex=-1>
    108         <h2>Always on top</h2>
    109         <button onclick="backdrop2.open()">Open with backdrop</button>
    110         <button onclick="onTop.close()">Close this</button>
    111       </simple-overlay>
    112       <simple-overlay id="backdrop2" with-backdrop tabindex=-1>
    113         <h2>With backdrop</h2>
    114         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    115         <button onclick="backdrop2.close()">Close</button>
    116       </simple-overlay>
    117     </template>
    118   </demo-snippet>
    119 
    120   <h3>An element with <code>IronOverlayBehavior</code> can be scrollable or contain scrollable content.</h3>
    121   <demo-snippet>
    122     <template>
    123       <style>
    124         .with-margin {
    125           margin: 24px 40px;
    126         }
    127         .scrollable {
    128           max-height: 300px;
    129           overflow: auto;
    130         }
    131       </style>
    132       <button onclick="scrolling.open()">Scrolling overlay</button>
    133 
    134       <simple-overlay id="scrolling" class="with-margin scrollable" tabindex=-1>
    135         <h2>This dialog scrolls internally.</h2>
    136         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    137           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    138         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    139           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    140         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    141           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    142         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    143           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    144         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    145           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    146         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    147           dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    148         <button onclick="scrolling.close()">Close</button>
    149       </simple-overlay>
    150 
    151       <button onclick="scrolling2.open()">Scrolling content</button>
    152 
    153       <simple-overlay id="scrolling2" class="with-margin" tabindex=-1>
    154         <h2>This dialog has a scrolling child.</h2>
    155         <div class="scrollable">
    156           <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    157             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    158           <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    159             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    160           <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    161             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    162           <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    163             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    164           <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    165             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    166           <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    167             dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    168         </div>
    169         <p>
    170           <button onclick="scrolling2.close()">Close</button>
    171         </p>
    172 
    173       </simple-overlay>
    174     </template>
    175   </demo-snippet>
    176 
    177 </body>
    178 
    179 </html>
    180