Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: appengine/swarming/elements/res/imp/common/error-toast.html

Issue 2306103002: Add aliases to bot-page and refactor duplicated code (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@fix-buttons
Patch Set: rebase again Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
20 Events:
21 None
22
23 Methods:
24 None
25 -->
26 <link rel="import" href="/res/imp/bower_components/paper-toast/paper-toast.html" />
27
28 <dom-module id="error-toast">
29 <template>
30 <paper-toast id=toast></paper-toast>
31 </template>
32 </dom-module>
33
34 <script>
35 Polymer({
36 is: "error-toast",
37
38 ready: function() {
39 document.addEventListener('error-sk', function(e) {
40 this.$.toast.close();
41 if (e.detail.message) {
42 this.$.toast.text = e.detail.message;
43 var duration = 10000;
44 // duration = 0 is a valid input for "keep open indefinitely".
45 if (e.detail.duration !== undefined) {
46 duration = e.detail.duration;
47 }
48 this.$.toast.duration = duration;
49 this.$.toast.show();
50 } else {
51 console.log("Empty message?", e);
52 }
53 }.bind(this));
54 },
55 });
56 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698