cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / resources / net_internals / top_mid_bottom_view.js
blob586482d1bf622c173c4c587cc37d3245fd3c8f25
1 // Copyright (c) 2011 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.
5 var TopMidBottomView = (function() {
6   'use strict';
8   // We inherit from View.
9   var superClass = View;
11   /**
12    * This view stacks three boxes -- one at the top, one at the bottom, and
13    * one that fills the remaining space between those two.  Either the top
14    * or the bottom bar may be null.
15    *
16    *  +----------------------+
17    *  |      topbar          |
18    *  +----------------------+
19    *  |                      |
20    *  |                      |
21    *  |                      |
22    *  |                      |
23    *  |      middlebox       |
24    *  |                      |
25    *  |                      |
26    *  |                      |
27    *  |                      |
28    *  |                      |
29    *  +----------------------+
30    *  |     bottombar        |
31    *  +----------------------+
32    *
33    *  @constructor
34    */
35   function TopMidBottomView(topView, midView, bottomView) {
36     superClass.call(this);
38     this.topView_ = topView;
39     this.midView_ = midView;
40     this.bottomView_ = bottomView;
41   }
43   TopMidBottomView.prototype = {
44     // Inherit the superclass's methods.
45     __proto__: superClass.prototype,
47     setGeometry: function(left, top, width, height) {
48       superClass.prototype.setGeometry.call(this, left, top, width, height);
50       // Calculate the vertical split points.
51       var topbarHeight = 0;
52       if (this.topView_)
53         topbarHeight = this.topView_.getHeight();
54       var bottombarHeight = 0;
55       if (this.bottomView_)
56         bottombarHeight = this.bottomView_.getHeight();
57       var middleboxHeight = height - (topbarHeight + bottombarHeight);
58       if (middleboxHeight < 0)
59         middleboxHeight = 0;
61       // Position the boxes using calculated split points.
62       if (this.topView_)
63         this.topView_.setGeometry(left, top, width, topbarHeight);
64       this.midView_.setGeometry(left, top + topbarHeight, width,
65                                 middleboxHeight);
66       if (this.bottomView_) {
67         this.bottomView_.setGeometry(left, top + topbarHeight + middleboxHeight,
68                                      width, bottombarHeight);
69       }
70     },
72     show: function(isVisible) {
73       superClass.prototype.show.call(this, isVisible);
74       if (this.topView_)
75         this.topView_.show(isVisible);
76       this.midView_.show(isVisible);
77       if (this.bottomView_)
78         this.bottomView_.show(isVisible);
79     }
80   };
82   return TopMidBottomView;
83 })();