Make treemenu a singleton
Change-Id: I0cb71df1f80c0f5d9f134a7fcf4563c3719d2302
diff --git a/dev/js/src/match/treemenu.js b/dev/js/src/match/treemenu.js
index 4c9539d..6bcff44 100644
--- a/dev/js/src/match/treemenu.js
+++ b/dev/js/src/match/treemenu.js
@@ -15,26 +15,43 @@
* @param params The match menu items
* as an array of arrays.
*/
- create : function (info, list) {
+ create : function (list) {
var obj = Object.create(menuClass)
.upgradeTo(this)
._init(list, {itemClass : itemClass});
obj.limit(6);
- obj._info = info;
+
+ var e = obj.element();
// This is only domspecific
- obj.element().addEventListener('blur', function (e) {
+ e.addEventListener('blur', function (e) {
this.menu.hide();
});
-
+
+ e.setAttribute('id', 'treeMenu');
+
+ // Add menu to body
+ document.getElementsByTagName('body')[0].appendChild(e);
+
return obj;
},
/**
* The match information object of the menu.
*/
- info :function () {
+ info :function (infoVar) {
+ if (infoVar !== undefined)
+ this._info = infoVar;
+
return this._info;
+ },
+
+ // Attach menu to
+ attachTo : function (e) {
+ var bounding = e.getBoundingClientRect();
+ this._element.style.left = bounding.left + "px";
+ this._element.style.top = bounding.top + "px";
+ this.slider().reInit();
}
};
});