Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!-- | |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | |
| 4 that can be found in the LICENSE file. | |
| 5 | |
| 6 Listens for 'error-sk' events that bubble up to the document | |
| 7 and displays them. | |
| 8 | |
| 9 The 'error-sk' event should have 'detail' of the form: | |
| 10 | |
| 11 { | |
| 12 message: "The error message to display goes here.", | |
|
jcgregorio
2016/09/06 20:40:56
Document duration in the example.
kjlubick
2016/09/07 12:00:20
Done.
| |
| 13 } | |
| 14 | |
| 15 Attributes: | |
| 16 None | |
| 17 Events: | |
| 18 Methods: | |
| 19 --> | |
| 20 <link rel="import" href="/res/imp/bower_components/paper-toast/paper-toast.html" /> | |
| 21 | |
| 22 <dom-module id="error-toast"> | |
| 23 <template> | |
| 24 <paper-toast id=toast></paper-toast> | |
| 25 </template> | |
| 26 </dom-module> | |
| 27 | |
| 28 <script> | |
| 29 Polymer({ | |
| 30 is: "error-toast", | |
| 31 ready: function() { | |
| 32 document.addEventListener('error-sk', function(e) { | |
| 33 this.$.toast.close(); | |
| 34 if (e.detail.message) { | |
| 35 this.$.toast.text = e.detail.message; | |
| 36 var duration = 10000; | |
| 37 // duration = 0 is a valid input for "keep open indefinitely". | |
| 38 if (e.detail.duration !== undefined) { | |
| 39 duration = e.detail.duration; | |
| 40 } | |
| 41 this.$.toast.duration = duration; | |
| 42 this.$.toast.show(); | |
| 43 } else { | |
| 44 console.log("Empty message?", e); | |
| 45 } | |
| 46 }.bind(this)); | |
| 47 }, | |
| 48 }); | |
| 49 </script> | |
| OLD | NEW |