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"> |
| 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'); |
| 64 } else if (this.type == results.kAudioType) { |
| 65 result = document.createElement('audio'); |
| 66 result.controls = 'controls'; |
| 67 } else { |
| 68 result = document.createElement('iframe'); |
| 69 } |
| 70 |
| 71 result.src = this.urlsByKind[kind]; |
| 72 result.classList.add(kind); |
| 73 |
| 74 container.innerHTML = ''; |
| 75 container.appendChild(result); |
| 76 } |
| 77 }, |
| 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 |