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.
9 base.require('ui.drag_handle');
10 base.require('ui.list_view');
11 base.require('analysis_view');
12 base.require('lthi_view');
13 base.requireStylesheet('model_view');
15 base.exportTo('ccfv', function() {
16 var ModelView = ui.define('x-model-view');
18 ModelView.prototype = {
19 __proto__: HTMLUnknownElement.prototype,
21 decorate: function() {
22 this.model_ = undefined;
24 this.lthiHistorySelector_ = document.createElement('select');
25 this.lthiHistorySelector_.addEventListener(
26 'change', this.onLTHISelectorChanged_);
28 this.lthiView_ = new ccfv.LTHIView();
29 this.lthiView_.addEventListener(
31 this.onLTHIViewSelectionChanged_.bind(this));
33 this.lthiList_ = new ui.ListView();
34 this.lthiList_.classList.add('lthi-list');
35 this.lthiList_.addEventListener(
37 this.updateLTHIView_.bind(this));
39 this.analysisView_ = new ccfv.AnalysisView();
41 var lthiPicker = document.createElement('div');
42 lthiPicker.className = 'lthi-picker';
43 lthiPicker.appendChild(this.lthiHistorySelector_);
45 var lthiAndAnalysisView = document.createElement('div');
46 lthiAndAnalysisView.className = 'lthi-and-analysis-view';
47 lthiAndAnalysisView.appendChild(this.lthiView_);
48 var dragHandle = new ui.DragHandle();
49 dragHandle.target = this.analysisView_;
50 lthiAndAnalysisView.appendChild(dragHandle);
51 lthiAndAnalysisView.appendChild(this.analysisView_);
53 var lthiView = document.createElement('div');
54 lthiView.className = 'lthi-view';
55 lthiView.appendChild(this.lthiList_);
56 lthiView.appendChild(lthiAndAnalysisView);
58 this.appendChild(lthiPicker);
59 this.appendChild(lthiView);
68 this.updateLTHISelector_();
71 updateLTHISelector_: function() {
72 this.lthiHistorySelector_.textContent = '';
73 this.lthiList_.textContent = '';
75 return this.updateLTHIList_();
77 var lthiHistories = base.dictionaryValues(this.model_.lthiHistories);
78 lthiHistories.forEach(function(lthiHistory) {
79 var option = document.createElement('option');
80 option.textContent = 'LTHI ' + lthiHistory.id;
81 option.lthiHistory = lthiHistory;
82 this.lthiHistorySelector_.appendChild(option);
84 this.updateLTHIList_();
87 onLTHISelectorChanged_: function() {
88 this.updateLTHIList_();
92 var el = this.lthiList_.selectedElement;
98 updateLTHIList_: function() {
100 this.lthiHistorySelector_.selectedOptions[0].lthiHistory;
101 this.lthiList_.textContent = '';
102 lthiHistory.lthiSnapshots.forEach(function(lthi, index) {
103 var lthiItem = document.createElement('div');
104 lthiItem.lthi = lthi;
105 this.lthiList_.appendChild(lthiItem);
107 lthiItem.selected = index == 0;
108 lthiItem.textContent = 'Frame ' + lthi.snapshotNumber;
110 this.updateLTHIView_();
113 updateLTHIView_: function() {
114 if (this.lthiView_.lthi != this.selectedLTHI)
115 this.lthiView_.lthi = this.selectedLTHI;
118 onLTHIViewSelectionChanged_: function(e) {
119 this.analysisView_.selection = e.selection;
124 ModelView: ModelView,