OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 /** |
| 6 * The status view at the top of the page. It displays what mode net-internals |
| 7 * is in (capturing, viewing only, viewing loaded log), and may have extra |
| 8 * information and actions depending on the mode. |
| 9 */ |
| 10 var TopBarView = (function() { |
| 11 'use strict'; |
| 12 |
| 13 // We inherit from View. |
| 14 var superClass = DivView; |
| 15 |
| 16 /** |
| 17 * Main entry point. Called once the page has loaded. |
| 18 * @constructor |
| 19 */ |
| 20 function TopBarView() { |
| 21 assertFirstConstructorCall(TopBarView); |
| 22 |
| 23 superClass.call(this, TopBarView.BOX_ID); |
| 24 |
| 25 this.nameToSubView_ = { |
| 26 loaded: new LoadedStatusView() |
| 27 }; |
| 28 |
| 29 this.activeSubView_ = null; |
| 30 } |
| 31 |
| 32 TopBarView.BOX_ID = 'top-bar-view'; |
| 33 |
| 34 cr.addSingletonGetter(TopBarView); |
| 35 |
| 36 TopBarView.prototype = { |
| 37 // Inherit the superclass's methods. |
| 38 __proto__: superClass.prototype, |
| 39 |
| 40 switchToSubView: function(name) { |
| 41 var newSubView = this.nameToSubView_[name]; |
| 42 |
| 43 if (!newSubView) |
| 44 throw Error('Invalid subview name'); |
| 45 |
| 46 var prevSubView = this.activeSubView_; |
| 47 this.activeSubView_ = newSubView; |
| 48 |
| 49 if (prevSubView) |
| 50 prevSubView.show(false); |
| 51 newSubView.show(this.isVisible()); |
| 52 |
| 53 // Let the subview change the color scheme of the top bar. |
| 54 $(TopBarView.BOX_ID).className = name + '-status-view'; |
| 55 |
| 56 return newSubView; |
| 57 }, |
| 58 }; |
| 59 |
| 60 return TopBarView; |
| 61 })(); |
| 62 |
OLD | NEW |