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 The interval-timer element fires the trigger event repeatedly using a | |
| 7 configurable property. | |
| 8 | |
| 9 Properties: | |
| 10 period - The number of seconds that should elapse before the trigger event f ires. After | |
| 11 firing, the timer resets. If the period is changed, the timer is also res et. -1 means to | |
| 12 stop the timer. | |
| 13 | |
| 14 Methods: | |
| 15 None. | |
| 16 | |
| 17 Events: | |
| 18 trigger - The specified time has come to perform some event. The event obje ct will have the | |
| 19 following attributes: | |
| 20 period: Number, the period that was used to create the event. | |
| 21 --> | |
| 22 <dom-module id="interval-timer"> | |
| 23 <script> | |
| 24 (function() { | |
| 25 Polymer({ | |
| 26 is: "interval-timer", | |
| 27 | |
| 28 properties: { | |
| 29 period: { | |
| 30 type: Number, | |
| 31 value: -1, // by default, never fire. | |
| 32 observer: "_periodChanged", | |
| 33 }, | |
| 34 }, | |
| 35 | |
| 36 _periodChanged: function(period) { | |
| 37 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.
| |
| 38 window.clearTimeout(this.timeout); | |
| 39 } | |
| 40 if (period > 0) { | |
| 41 this.timeout = window.setTimeout(function() { | |
| 42 this.fire('trigger'); | |
| 43 // refire event | |
| 44 this._periodChanged(period); | |
| 45 }.bind(this), period * 1000); | |
| 46 } | |
| 47 }, | |
| 48 }); | |
| 49 }()); | |
| 50 </script> | |
| 51 </dom-module> | |
| OLD | NEW |