Modernize VC scripts
Change-Id: I260af56726ba75a56857a5af97c373432d69a910
diff --git a/dev/js/src/vc/item.js b/dev/js/src/vc/item.js
index f9267e8..59589d8 100644
--- a/dev/js/src/vc/item.js
+++ b/dev/js/src/vc/item.js
@@ -1,4 +1,6 @@
// Field menu item
+"use strict";
+
define(['menu/item', 'util'], function (itemClass) {
const loc = KorAP.Locale;
@@ -18,22 +20,26 @@
._init(params);
},
+
// Initialize item object
_init : function (params) {
+ const t = this;
+
if (params[0] === undefined)
throw new Error("Missing parameters");
- this._key = params[0];
- this._type = params[1];
+ t._key = params[0];
+ t._type = params[1];
- var k = this._key;
- this._name = loc["VC_" + k] ? loc["VC_" + k] : k;
+ const k = t._key;
+ t._name = loc["VC_" + k] ? loc["VC_" + k] : k;
- this._lcField = ' ' + this._name.toLowerCase();
+ t._lcField = ' ' + t._name.toLowerCase();
- return this;
+ return t;
},
+
/**
* Override click event by passing all clicks
* to the menu object.
@@ -46,6 +52,7 @@
e.halt();
},
+
/**
* Get the name of the item.
* This is a potential localized version
@@ -55,6 +62,7 @@
return this._name;
},
+
/**
* Get the type of the item.
*/
@@ -62,6 +70,7 @@
return this._type;
},
+
/**
* Get the key of the item.
*/
@@ -69,26 +78,29 @@
return this._key;
},
+
/**
* Get the HTML element associated with the item.
*/
element : function () {
+ const t = this;
// already defined
- if (this._element !== undefined)
- return this._element;
+ if (t._element !== undefined)
+ return t._element;
// Create list item
var li = document.createElement("li");
- if (this._type)
- li.setAttribute("data-type", this._type);
- li.setAttribute("data-key", this._key);
+ if (t._type)
+ li.setAttribute("data-type", t._type);
+
+ li.setAttribute("data-key", t._key);
// Connect action
- li["onclick"] = this.onclick.bind(this);
+ li["onclick"] = t.onclick.bind(t);
- li.addT(this._name);
- return this._element = li;
+ li.addT(t._name);
+ return t._element = li;
}
};
});