Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!-- | |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 | |
| 7 <polymer-element name="ct-last-updated" attributes="date"> | |
|
ojan
2014/08/08 06:05:13
Please add a test for this. It's confusing because
teravest
2014/08/08 22:21:28
Done.
| |
| 8 <template> | |
| 9 <style> | |
| 10 :host { | |
| 11 display: flex; | |
|
ojan
2014/08/08 06:05:13
I don't think you need this element to be a flexbo
teravest
2014/08/08 22:21:28
Removed.
| |
| 12 } | |
| 13 | |
| 14 .message { | |
| 15 flex: 1; | |
| 16 overflow: hidden; | |
| 17 text-overflow: ellipsis; | |
| 18 white-space: nowrap; | |
|
ojan
2014/08/08 06:05:12
It's tricky deciding where to put which CSS stylin
teravest
2014/08/08 22:21:28
I've removed the styling here.
| |
| 19 } | |
| 20 | |
| 21 </style> | |
| 22 <div class="message">Updated {{ delta_min }} min ago @ {{ date_hours }}:{{ d ate_minutes }}.</div> | |
|
ojan
2014/08/08 06:05:12
I don't think this wrapper div is needed.
teravest
2014/08/08 22:21:28
Removed.
| |
| 23 </template> | |
| 24 <script> | |
| 25 (function() { | |
| 26 Polymer({ | |
| 27 date: 0, // seconds from epoch | |
| 28 delta_min: 0, | |
| 29 date_hours: 0, | |
| 30 date_minutes: 0, | |
| 31 | |
| 32 dateChanged: function() { | |
| 33 this.update(); | |
| 34 }, | |
| 35 | |
| 36 update: function() { | |
|
ojan
2014/08/08 06:05:13
You don't need the update function. Better is to l
teravest
2014/08/08 22:21:28
That's much better, thanks!
| |
| 37 this.delta_min = Math.floor(((Date.now() / 1000) - this.date) / 60); | |
| 38 this.date_hours = new Date(this.date * 1000).getHours(); | |
| 39 this.date_minutes = new Date(this.date * 1000).getMinutes(); | |
|
ojan
2014/08/08 06:05:12
sugarjs, which we include, has nice methods to get
teravest
2014/08/08 22:21:27
Excellent. Done.
| |
| 40 }, | |
| 41 | |
| 42 }); | |
| 43 })(); | |
| 44 | |
| 45 </script> | |
| 46 </polymer-element> | |
| OLD | NEW |