Removes caching of active element.

This commit is contained in:
zorkow 2015-08-28 12:29:19 +01:00
parent 1c07cf3189
commit 0d60b0654b

View File

@ -495,25 +495,16 @@
} }
return nodes; return nodes;
}, },
GetActive: function() { ActiveNode: function() {
return MENU.active; return document.activeElement;
},
SetActive: function(node) {
MENU.active = node;
}, },
// //
// Focus is a global affair, since we only ever want a single focused item. // Focus is a global affair, since we only ever want a single focused item.
// //
Focus: function(menu) { Focus: function(menu) {
if (!MENU.posted) { !MENU.posted ? MENU.Activate(menu) : MENU.ActiveNode().tabIndex = -1;
MENU.Activate(menu); menu.tabIndex = 0;
} menu.focus();
if (MENU.GetActive()) {
MENU.GetActive().tabIndex = -1;
}
MENU.SetActive(menu);
MENU.GetActive().tabIndex = 0;
MENU.GetActive().focus();
}, },
Activate: function(event, menu) { Activate: function(event, menu) {
var jaxs = MENU.AllNodes(); var jaxs = MENU.AllNodes();
@ -523,8 +514,7 @@
MENU.posted = true; MENU.posted = true;
}, },
Unfocus: function() { Unfocus: function() {
MENU.GetActive().tabIndex = -1; MENU.ActiveNode().tabIndex = -1;
MENU.SetActive(null);
var jaxs = MENU.AllNodes(); var jaxs = MENU.AllNodes();
for (var j = 0, jax; jax = jaxs[j]; j++) { for (var j = 0, jax; jax = jaxs[j]; j++) {
jax.tabIndex = 0; jax.tabIndex = 0;
@ -591,10 +581,7 @@
this.node = node; this.node = node;
}, },
GetMenuNode: function() { GetMenuNode: function() {
return this.menu; return this.GetNode().parentNode;
},
SetMenuNode: function(menu) {
this.menu = menu;
}, },
Attributes: function(def) { Attributes: function(def) {
@ -612,14 +599,13 @@
var label = this.Label(def,menu); var label = this.Label(def,menu);
var node = HTML.addElement(menu, "div", def, label); var node = HTML.addElement(menu, "div", def, label);
this.SetNode(node); this.SetNode(node);
this.SetMenuNode(menu);
} }
}, },
Name: function () {return _(this.name[0],this.name[1])}, Name: function () {return _(this.name[0],this.name[1])},
Mouseover: function (event,menu) { Mouseover: function (event,menu) {
if (menu.parentNode === MENU.GetActive().parentNode) { if (menu.parentNode === MENU.ActiveNode().parentNode) {
this.Deactivate(MENU.GetActive()); this.Deactivate(MENU.ActiveNode());
} }
this.Activate(event, menu); this.Activate(event, menu);
}, },