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.", | |
| 13 duration: Integer, the number of ms to display or 0 for indefinitely. | |
| 14 Defaults to 10000 (10s) | |
| 15 } | |
| 16 | |
| 17 Attributes: | |
| 18 None | |
| 19 Events: | |
|
jcgregorio
2016/09/07 12:12:48
Blank lines before Events: and Methods:
kjlubick
2016/09/07 12:36:38
Done.
| |
| 20 Methods: | |
| 21 --> | |
| 22 <link rel="import" href="/res/imp/bower_components/paper-toast/paper-toast.html" /> | |
| 23 | |
| 24 <dom-module id="error-toast"> | |
| 25 <template> | |
| 26 <paper-toast id=toast></paper-toast> | |
| 27 </template> | |
| 28 </dom-module> | |
| 29 | |
| 30 <script> | |
| 31 Polymer({ | |
| 32 is: "error-toast", | |
| 33 ready: function() { | |
|
jcgregorio
2016/09/07 12:12:48
Blank line before ready:
kjlubick
2016/09/07 12:36:38
Done.
| |
| 34 document.addEventListener('error-sk', function(e) { | |
| 35 this.$.toast.close(); | |
| 36 if (e.detail.message) { | |
| 37 this.$.toast.text = e.detail.message; | |
| 38 var duration = 10000; | |
| 39 // duration = 0 is a valid input for "keep open indefinitely". | |
| 40 if (e.detail.duration !== undefined) { | |
| 41 duration = e.detail.duration; | |
| 42 } | |
| 43 this.$.toast.duration = duration; | |
| 44 this.$.toast.show(); | |
| 45 } else { | |
| 46 console.log("Empty message?", e); | |
| 47 } | |
| 48 }.bind(this)); | |
| 49 }, | |
| 50 }); | |
| 51 </script> | |
| OLD | NEW |