blob: 2eb5dd087c53940c53cacb0b4420fcb5c5c38cad [file] [log] [blame]
Akron537bc522018-07-13 19:06:27 +02001/**
2 * Create a view that can be added to a panel,
3 * like a tree view or the metadata view.
4 */
5
6define(['buttongroup', 'util'], function (buttonGroupClass) {
7
8 return {
9
10 // TODO:
11 // Support classes
12 create : function () {
13 return Object.create(this)._init();
14 },
15
16 _init : function () {
17 // ..
18 this.panel = undefined;
19
20 // The buttonclass is bind to the view
21 this.actions = buttonGroupClass.create(['action', 'view']).bind(this);
22 this.actions.add('close', ['button-icon','close'], function (e) {
23 this.close();
24 });
25
26 return this;
27 },
28
29 /**
30 * Element of the view
31 */
32 element : function () {
33 if (this._element)
34 return this._element;
35
36 // Create panel element
37 var e = document.createElement('div');
38 e.classList.add('view');
39
40 e.appendChild(this.actions.element());
41
42 this._element = e;
43 return e;
44 },
45
46 /**
47 * Close the view.
48 */
49 close : function () {
50 var e = this.element();
51 e.parentNode.removeChild(e);
52 this.panel.delView(this);
53 }
54 };
55});