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

Unified Diff: appengine/swarming/elements/res/imp/common/interval-timer.html

Issue 2350853004: Make the buttons on task-page work (Closed) Base URL: git@github.com:luci/luci-py@task-page2
Patch Set: Rebuild 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/imp/common/interval-timer.html
diff --git a/appengine/swarming/elements/res/imp/common/interval-timer.html b/appengine/swarming/elements/res/imp/common/interval-timer.html
new file mode 100644
index 0000000000000000000000000000000000000000..8093dfa1d4fb75f848f0612c4339cbc1008e7005
--- /dev/null
+++ b/appengine/swarming/elements/res/imp/common/interval-timer.html
@@ -0,0 +1,51 @@
+<!--
+ Copyright 2016 The LUCI Authors. All rights reserved.
+ Use of this source code is governed under the Apache License, Version 2.0
+ that can be found in the LICENSE file.
+
+ The interval-timer element fires the trigger event repeatedly using a
+ configurable property.
+
+ Properties:
+ period - The number of seconds that should elapse before the trigger event fires. After
+ firing, the timer resets. If the period is changed, the timer is also reset. -1 means to
+ stop the timer.
+
+ Methods:
+ None.
+
+ Events:
+ trigger - The specified time has come to perform some event. The event object will have the
+ following attributes:
+ period: Number, the period that was used to create the event.
+-->
+<dom-module id="interval-timer">
+ <script>
+ (function() {
+ Polymer({
+ is: "interval-timer",
+
+ properties: {
+ period: {
+ type: Number,
+ value: -1, // by default, never fire.
+ observer: "_periodChanged",
+ },
+ },
+
+ _periodChanged: function(period) {
+ if (this.timeout) {
jcgregorio 2016/09/21 14:22:03 rename timeout -> _timeout since it isn't a public
kjlubick 2016/09/21 14:51:38 Done.
+ window.clearTimeout(this.timeout);
+ }
+ if (period > 0) {
+ this.timeout = window.setTimeout(function() {
+ this.fire('trigger');
+ // refire event
+ this._periodChanged(period);
+ }.bind(this), period * 1000);
+ }
+ },
+ });
+ }());
+ </script>
+</dom-module>

Powered by Google App Engine
This is Rietveld 408576698