Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 1 | // Copyright 2015 the V8 project 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 | class View { |
| 8 | constructor(id, broker) { |
| 9 | this.divElement = d3.select("#" + id); |
| 10 | this.divNode = this.divElement[0][0]; |
| 11 | this.parentNode = this.divNode.parentNode; |
| 12 | this.hide(); |
| 13 | } |
| 14 | |
| 15 | isScrollable() { |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | show(data, rememberedSelection) { |
| 20 | this.parentNode.appendChild(this.divElement[0][0]); |
| 21 | this.initializeContent(data, rememberedSelection); |
| 22 | this.resizeToParent(); |
| 23 | this.divElement.attr(VISIBILITY, 'visible'); |
| 24 | } |
| 25 | |
| 26 | resizeToParent() { |
| 27 | var view = this; |
| 28 | var documentElement = document.documentElement; |
| 29 | var y = this.parentNode.clientHeight || documentElement.clientHeight; |
| 30 | this.parentNode.style.height = y + 'px'; |
| 31 | } |
| 32 | |
| 33 | hide() { |
| 34 | this.divElement.attr(VISIBILITY, 'hidden'); |
| 35 | this.deleteContent(); |
| 36 | this.parentNode.removeChild(this.divNode); |
| 37 | } |
| 38 | |
| 39 | detachSelection() { |
| 40 | return null; |
| 41 | } |
| 42 | } |