OLD | NEW |
(Empty) | |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 'use strict'; |
| 6 |
| 7 base.require('tile_view'); |
| 8 base.require('ui'); |
| 9 base.require('ui.list_and_associated_view'); |
| 10 |
| 11 base.requireStylesheet('analysis_view'); |
| 12 |
| 13 base.exportTo('ccfv', function() { |
| 14 var TileView = ccfv.TileView; |
| 15 |
| 16 var AnalysisView = ui.define('x-analysis-view'); |
| 17 |
| 18 AnalysisView.prototype = { |
| 19 __proto__: HTMLUnknownElement.prototype, |
| 20 |
| 21 decorate: function() { |
| 22 this.selection_ = undefined; |
| 23 this.updateChildren_(); |
| 24 }, |
| 25 |
| 26 set selection(selection) { |
| 27 if (this.selection_) |
| 28 this.selection_.deactivate(); |
| 29 this.selection_ = selection; |
| 30 if (this.selection_) |
| 31 this.selection_.activate(); |
| 32 this.updateChildren_(); |
| 33 }, |
| 34 |
| 35 get selection() { |
| 36 return this.selection_; |
| 37 }, |
| 38 |
| 39 updateChildren_: function() { |
| 40 if (!this.selection_) { |
| 41 this.textContent = 'Select something'; |
| 42 return; |
| 43 } |
| 44 if (this.selection_.tiles) { |
| 45 this.updateChildrenGivenTiles_(this.selection_.tiles); |
| 46 return; |
| 47 } |
| 48 throw new Error('I am confused about what you selected'); |
| 49 }, |
| 50 |
| 51 updateChildrenGivenTiles_: function(tiles) { |
| 52 this.textContent = ''; |
| 53 var tileListEl = new ui.ListAndAssociatedView(); |
| 54 tileListEl.view = new TileView(); |
| 55 tileListEl.viewProperty = 'tile'; |
| 56 tileListEl.list = tiles; |
| 57 tileListEl.listProperty = 'title'; |
| 58 this.appendChild(tileListEl); |
| 59 }, |
| 60 }; |
| 61 |
| 62 return { |
| 63 AnalysisView: AnalysisView |
| 64 } |
| 65 }); |
| 66 |
OLD | NEW |