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="results-comparison" attributes="type urlsByKind"> | |
esprehn
2014/06/22 05:15:20
You should really pick a prefix for your app and u
ojan
2014/06/22 06:33:19
Yeah, I started with gom-results-comparison, but t
abarth-chromium
2014/06/22 14:43:51
Yeah, we need a prefix. Don't worry about it bein
ojan
2014/06/22 22:49:22
At esprehns suggestion, I went with ct- for chromi
| |
8 <template> | |
9 <style> | |
10 :host { | |
11 display: flex; | |
12 flex-wrap: wrap; | |
13 width: 100%; | |
14 } | |
15 .container { | |
16 flex: 1; | |
17 min-width: 300px; | |
18 } | |
19 .result { | |
20 border: 1px solid gray; | |
21 } | |
22 iframe { | |
23 border: none; | |
24 width: 100%; | |
25 height: 400px; | |
26 } | |
27 img { | |
28 width: 100%; | |
29 } | |
30 </style> | |
31 | |
32 <div class="container"> | |
33 <h2>Expected</h2> | |
34 <div id="expected" class="result"></div> | |
35 </div> | |
36 | |
37 <div class="container"> | |
38 <h2>Actual</h2> | |
39 <div id="actual" class="result"></div> | |
40 </div> | |
41 | |
42 <div class="container"> | |
43 <h2>Diff</h2> | |
44 <div id="diff" class="result"></div> | |
45 </div> | |
46 </template> | |
47 <script> | |
48 Polymer("results-comparison", { | |
49 type: "", | |
50 urlsByKind: null, | |
51 | |
52 _update: function() { | |
53 if (!this.type || !this.urlsByKind) | |
54 return; | |
55 | |
56 for (var kind in this.urlsByKind) { | |
57 var container = this.$[kind]; | |
58 if (!container) | |
59 throw new Error('Passed in an invalid comparison kind: ' + kind); | |
60 | |
61 var result; | |
62 if (this.type == results.kImageType) { | |
63 result = document.createElement('img'); | |
esprehn
2014/06/22 05:15:20
This can actually be new Image() and the below one
ojan
2014/06/22 06:33:19
Why is that better? Seems better to me to use docu
ojan
2014/06/22 22:49:22
This is also gone now.
| |
64 } else if (this.type == results.kAudioType) { | |
65 result = document.createElement('audio'); | |
66 result.controls = 'controls'; | |
67 } else { | |
68 result = document.createElement('iframe'); | |
esprehn
2014/06/22 05:15:20
else if (this.type == == results.kIframeType) ?
O
| |
69 } | |
70 | |
71 result.src = this.urlsByKind[kind]; | |
72 result.classList.add(kind); | |
73 | |
74 container.innerHTML = ''; | |
75 container.appendChild(result); | |
76 } | |
77 }, | |
abarth-chromium
2014/06/22 14:43:51
Why not use <template> to do this work? You're re
ojan
2014/06/22 22:49:22
Lol. Just wasn't thinking as I copy-pasted the cod
| |
78 | |
79 typeChanged: function(oldValue, newValue) { | |
80 this._update(); | |
81 }, | |
82 | |
83 urlsByKindChanged: function(oldValue, newValue) { | |
84 this._update(); | |
85 }, | |
86 }); | |
87 </script> | |
88 </polymer-element> | |
OLD | NEW |