Introduce fieldType guesser in VC deserialization
Change-Id: Id279582a5e238e3fb494ca0706783a57b47c05ce
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index 6a242e2..0f0d92a 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -21,6 +21,7 @@
return obj;
},
+
/**
* Register callback for click event.
*/
@@ -28,12 +29,26 @@
this._cb = cb;
},
+
/**
* A click event was released
*/
release : function (key, type) {
if (this._cb !== undefined)
this._cb(key, type);
+ },
+
+ /**
+ * Return a key type based on a key.
+ * This is a linear search, but should work okay for small
+ * VCs and small key lists.
+ */
+ typeOf : function (key) {
+ for (i in this._items) {
+ if (this._items[i].key() === key) {
+ return this._items[i].type();
+ }
+ };
}
};
});