Introduced benchmark system
diff --git a/dev/js/src/hint/menu.js b/dev/js/src/hint/menu.js
index df27a11..1763306 100644
--- a/dev/js/src/hint/menu.js
+++ b/dev/js/src/hint/menu.js
@@ -13,7 +13,11 @@
create : function (hint, context, params) {
var obj = Object.create(menuClass)
.upgradeTo(this)
- ._init(itemClass, prefixClass, lengthFieldClass, params);
+ ._init(params, {
+ itemClass : itemClass,
+ prefixClass : prefixClass,
+ lengthFieldClass : lengthFieldClass
+ });
obj._context = context;
obj._element.classList.add('hint');
obj._hint = hint;
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 3b911b6..8fcc162 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -1,3 +1,15 @@
+/*
+ * TODO: Create lazy loading of objects including
+ * - obj.hint()
+ * - obj.alertify()
+ * - obj.session()
+ * - obj.tutorial()
+ * - obj.vc() // toggle
+ * - obj.matchCreate() (using webpack)
+ * - obj.koral() (show result, parse for errors ...)
+ * - obj.alignment() // toggle
+ */
+
define([
'match',
'hint',
@@ -104,6 +116,7 @@
if (this._match !== undefined)
this._match.open();
else {
+ // lazyLoad
matchClass.create(this).open();
};
e.halt();
@@ -116,6 +129,7 @@
if (this._match !== undefined)
this._match.toggle();
else {
+ // lazyLoad
matchClass.create(this).open();
};
e.halt();
diff --git a/dev/js/src/match/tree.js b/dev/js/src/match/tree.js
index dcecd5e..5e39a1a 100644
--- a/dev/js/src/match/tree.js
+++ b/dev/js/src/match/tree.js
@@ -1,6 +1,8 @@
/**
* Visualize span annotations as a tree
* using Dagre.
+ *
+ * This should be lazy loaded!
*/
define(['lib/dagre'], function (dagre) {
"use strict";
diff --git a/dev/js/src/match/treemenu.js b/dev/js/src/match/treemenu.js
index fec7703..5af4619 100644
--- a/dev/js/src/match/treemenu.js
+++ b/dev/js/src/match/treemenu.js
@@ -18,7 +18,7 @@
create : function (info, params) {
var obj = Object.create(menuClass)
.upgradeTo(this)
- ._init(itemClass, undefined, undefined, params);
+ ._init(params, {itemClass : itemClass});
obj.limit(6);
obj._info = info;
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index e8028ea..9ed6e7c 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -41,23 +41,30 @@
* Create new Menu based on the action prefix
* and a list of menu items.
*
+ *
+ * Accepts an associative array containg the elements
+ * itemClass, prefixClass, lengthFieldClass
+ *
* @this {Menu}
* @constructor
* @param {string} Context prefix
* @param {Array.<Array.<string>>} List of menu items
*/
- create : function (params) {
- return Object.create(this)._init(params);
+ create : function (list, params) {
+ return Object.create(this)._init(list, params);
},
// Initialize list
- _init : function (itemClass, prefixClass, lengthFieldClass, params) {
+ _init : function (list, params) {
- this._itemClass = itemClass || defaultItemClass;
+ if (params === undefined)
+ params = {};
+
+ this._itemClass = params["itemClass"] || defaultItemClass;
// Add prefix object
- if (prefixClass !== undefined) {
- this._prefix = prefixClass.create();
+ if (params["prefixClass"] !== undefined) {
+ this._prefix = params["prefixClass"].create();
}
else {
this._prefix = defaultPrefixClass.create();
@@ -65,8 +72,8 @@
this._prefix._menu = this;
// Add lengthField object
- if (lengthFieldClass !== undefined) {
- this._lengthField = lengthFieldClass.create();
+ if (params["lengthFieldClass"] !== undefined) {
+ this._lengthField = params["lengthFieldClass"].create();
}
else {
this._lengthField = defaultLengthFieldClass.create();
@@ -116,12 +123,12 @@
var i = 0;
// Initialize item list based on parameters
- for (i in params) {
- var obj = this._itemClass.create(params[i]);
+ for (i in list) {
+ var obj = this._itemClass.create(list[i]);
// This may become circular
obj["_menu"] = this;
- this._lengthField.add(params[i]);
+ this._lengthField.add(list[i]);
this._items.push(obj);
};
@@ -405,7 +412,7 @@
if (active < 0) {
active = 0;
}
- else if (active > this.liveLength()) {
+ else if (active >= this.liveLength()) {
active = this.liveLength() - 1;
};
diff --git a/dev/js/src/menu/item.js b/dev/js/src/menu/item.js
index 8278d17..873d81b 100644
--- a/dev/js/src/menu/item.js
+++ b/dev/js/src/menu/item.js
@@ -170,7 +170,6 @@
// Highlight a certain substring of the menu item
_highlight : function (elem, prefix) {
-
if (elem.nodeType === 3) {
var text = elem.nodeValue;
@@ -228,7 +227,7 @@
this._action = params[1];
this._lcField = ' ' + this.content().textContent.toLowerCase();
- this._highlight = null;
+ this._prefix = null;
return this;
},
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index fddb3f0..5840438 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -6,7 +6,7 @@
create : function (params) {
var obj = Object.create(menuClass)
.upgradeTo(this)
- ._init(itemClass, undefined, undefined, params);
+ ._init(params, {itemClass : itemClass});
obj.limit(6);
// This is only domspecific