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 5import { GNode } from "./node"; 6 7export abstract class View { 8 protected container: HTMLElement; 9 protected divNode: HTMLElement; 10 protected abstract createViewElement(): HTMLElement; 11 12 constructor(idOrContainer: string | HTMLElement) { 13 this.container = typeof idOrContainer == "string" ? document.getElementById(idOrContainer) : idOrContainer; 14 this.divNode = this.createViewElement(); 15 } 16 17 public show(): void { 18 this.container.appendChild(this.divNode); 19 } 20 21 public hide(): void { 22 this.container.removeChild(this.divNode); 23 } 24} 25 26export abstract class PhaseView extends View { 27 public abstract initializeContent(data: any, rememberedSelection: Map<string, GNode>): void; 28 public abstract detachSelection(): Map<string, GNode>; 29 public abstract onresize(): void; 30 public abstract searchInputAction(searchInput: HTMLInputElement, e: Event, onlyVisible: boolean): void; 31 32 constructor(idOrContainer: string | HTMLElement) { 33 super(idOrContainer); 34 } 35} 36