dockview
Version:
Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support
69 lines (68 loc) • 2.24 kB
JavaScript
import { ActionContainer } from '../../../actionbar/actionsContainer';
import { addDisposableListener } from '../../../events';
import { toggleClass } from '../../../dom';
import { CompositeDisposable } from '../../../lifecycle';
export class Watermark extends CompositeDisposable {
constructor() {
super();
this._element = document.createElement('div');
this._element.className = 'watermark';
const title = document.createElement('div');
title.className = 'watermark-title';
const emptySpace = document.createElement('span');
emptySpace.style.flexGrow = '1';
const content = document.createElement('div');
content.className = 'watermark-content';
this._element.appendChild(title);
this._element.appendChild(content);
const actions = new ActionContainer();
title.appendChild(emptySpace);
title.appendChild(actions.element);
const closeAnchor = document.createElement('a');
closeAnchor.className = 'close-action';
actions.add(closeAnchor);
this.addDisposables(addDisposableListener(closeAnchor, 'click', (ev) => {
var _a;
ev.preventDefault();
if (this.group) {
(_a = this.params) === null || _a === void 0 ? void 0 : _a.containerApi.removeGroup(this.group);
}
}));
}
get id() {
return 'watermark';
}
update(event) {
// noop
}
focus() {
// noop
}
toJSON() {
return {};
}
layout(width, height) {
// noop
}
init(params) {
this.params = params;
this.addDisposables(this.params.containerApi.onDidLayoutChange((event) => {
this.render();
}));
this.render();
}
updateParentGroup(group, visible) {
this.group = group;
this.render();
}
get element() {
return this._element;
}
render() {
const isOneGroup = !!(this.params && this.params.containerApi.size <= 1);
toggleClass(this.element, 'has-actions', isOneGroup);
}
dispose() {
super.dispose();
}
}