Modernize view scripts and improve specifications
Change-Id: Ie45465c8c29aef272c719942290f4ab0c9dc8550
diff --git a/dev/js/src/view.js b/dev/js/src/view.js
index 27d1ab2..77f8d60 100644
--- a/dev/js/src/view.js
+++ b/dev/js/src/view.js
@@ -3,6 +3,8 @@
* like a tree view or the metadata view.
*/
+"use strict";
+
define(['buttongroup', 'util'], function (buttonGroupClass) {
const loc = KorAP.Locale;
@@ -20,7 +22,7 @@
this._shown = false;
// The buttonclass is bind to the view
- var c = ['action', 'button-view'];
+ const c = ['action', 'button-view'];
if (classes)
c.push.apply(c,classes);
@@ -36,6 +38,7 @@
return this;
},
+
/**
* Element of the view
*/
@@ -46,30 +49,28 @@
};
// Create panel element
- var e = document.createElement('div');
+ const e = document.createElement('div');
+ const cl = e.classList;
- var cl = e.classList;
cl.add('view', 'show');
if (this._classes)
cl.add.apply(cl, this._classes);
// TODO: The show may need to be wrapped in another DIV!
if (this.show !== undefined) {
- let s = this.show();
+ const s = this.show();
if (s) {
e.appendChild(s);
} else {
return e
- }
+ };
}
this._shown = true;
e.appendChild(this.actions.element());
- this._element = e;
-
- return e;
+ return this._element = e;
},
@@ -90,8 +91,10 @@
}
},
+
// onClose : function () {},
+
/**
* Close the view.
*/
@@ -101,7 +104,7 @@
if (this.onClose)
this.onClose();
- var e = this.element();
+ const e = this.element();
if (e.parentNode) {
e.parentNode.removeChild(e);
};
@@ -109,6 +112,7 @@
this._shown = false;
},
+
/**
* Upgrade this object to another object,
* while private data stays intact.
@@ -116,7 +120,7 @@
* @param {Object] An object with properties.
*/
upgradeTo : function (props) {
- for (var prop in props) {
+ for (let prop in props) {
this[prop] = props[prop];
};
return this;