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 `paper-toast` provides lightweight feedback about an operation in a small popup |
| 12 at the base of the screen on mobile and at the lower left on desktop. Toasts are
|
| 13 above all other elements on screen, including the FAB. |
| 14 |
| 15 Toasts automatically disappear after a timeout or after user interaction |
| 16 elsewhere on the screen, whichever comes first. Toasts can be swiped off |
| 17 screen. There can be only one on the screen at a time. |
| 18 |
| 19 Example: |
| 20 |
| 21 <paper-toast text="Your draft has been discarded." onclick="discardDraft(el)
"></paper-toast> |
| 22 |
| 23 <script> |
| 24 function discardDraft(el) { |
| 25 el.show(); |
| 26 } |
| 27 </script> |
| 28 |
| 29 An action button can be presented in the toast. |
| 30 |
| 31 Example (using Polymer's data-binding features): |
| 32 |
| 33 <paper-toast id="toast2" text="Connection timed out. Showing limited message
s."> |
| 34 <div style="color: blue;" on-tap="{{retry}}">Retry</div> |
| 35 </paper-toast> |
| 36 |
| 37 Positioning toast: |
| 38 |
| 39 A standard toast appears near the lower left of the screen. You can change the |
| 40 position by overriding bottom and left positions. |
| 41 |
| 42 paper-toast { |
| 43 bottom: 40px; |
| 44 left: 10px; |
| 45 } |
| 46 |
| 47 To make it fit at the bottom of the screen: |
| 48 |
| 49 paper-toast { |
| 50 bottom: 0; |
| 51 left: 0; |
| 52 width: 100%; |
| 53 } |
| 54 |
| 55 When the screen size is smaller than the `responsiveWidth` (default to 480px), |
| 56 the toast will automatically fits at the bottom of the screen. |
| 57 |
| 58 @group Paper Elements |
| 59 @element paper-toast |
| 60 @homepage github.io |
| 61 --> |
| 62 |
| 63 <link rel="import" href="../core-overlay/core-overlay.html"> |
| 64 <link rel="import" href="../core-transition/core-transition-css.html"> |
| 65 <link rel="import" href="../core-media-query/core-media-query.html"> |
| 66 |
| 67 <polymer-element name="paper-toast" attributes="text duration opened responsiveW
idth swipeDisabled" role="status" assetpath=""> |
| 68 |
| 69 <template> |
| 70 |
| 71 <link rel="stylesheet" href="paper-toast.css"> |
| 72 |
| 73 <core-overlay opened="{{opened}}" target="{{}}" sizingtarget="{{$.container}}"
transition="core-transition-bottom"></core-overlay> |
| 74 |
| 75 <div class="toast-container" horizontal="" layout=""> |
| 76 |
| 77 <div class="toast-text" flex="">{{text}}</div> |
| 78 |
| 79 <div class="toast-text toast-action" on-tap="{{dismiss}}"> |
| 80 <content></content> |
| 81 </div> |
| 82 |
| 83 </div> |
| 84 |
| 85 <core-media-query query="max-width: {{responsiveWidth}}" querymatches="{{narro
wMode}}"></core-media-query> |
| 86 |
| 87 </template> |
| 88 |
| 89 </polymer-element> |
| 90 <script src="paper-toast-extracted.js"></script> |
OLD | NEW |