Skip to content

Commit 5c687be

Browse files
committed
Menu: Refactoring flyout menu in prepartion for merging into menu
1 parent 6bd95ef commit 5c687be

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tests/visual/menu/flyoutmenu.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $.widget("ui.flyoutmenu", {
1616

1717
_create: function() {
1818
var self = this;
19-
this.active = this.element;
2019
this.activeItem = this.element.children("li").first();
2120
// hide submenus and create indicator icons
2221
this.element.find("ul").addClass("ui-menu-flyout").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>');
@@ -26,12 +25,13 @@ $.widget("ui.flyoutmenu", {
2625
self._select(event);
2726
},
2827
focus: function(event, ui) {
29-
self.active = ui.item.parent();
3028
self.activeItem = ui.item;
29+
ui.item.parent().focus();
3130
ui.item.parent().find("ul").hide();
3231
var nested = $(">ul", ui.item);
3332
if (nested.length && event.originalEvent && /^mouse/.test(event.originalEvent.type)) {
3433
self._open(nested);
34+
nested.focus();
3535
}
3636
}
3737
}).keydown(function(event) {
@@ -60,7 +60,7 @@ $.widget("ui.flyoutmenu", {
6060
_open: function(submenu) {
6161
// TODO restrict to widget
6262
//only one menu can have items open at a time.
63-
$(document).find(".ui-menu-flyout").not(submenu.parents()).hide();
63+
$(document).find(".ui-menu-flyout").not(submenu.parents()).hide().data("menu").blur();
6464

6565
var position = $.extend({}, {
6666
of: this.activeItem
@@ -93,16 +93,12 @@ $.widget("ui.flyoutmenu", {
9393
}
9494
},
9595
activate: function(event, item) {
96-
if (item) {
97-
item.parent().data("menu").widget().show();
98-
item.parent().data("menu").focus(event, item);
99-
}
96+
var parent = item.parent();
97+
parent.data("menu").focus(event, item);
10098
this.activeItem = item;
101-
this.active = item.parent("ul")
102-
this.active.focus();
99+
parent.focus();
103100
},
104101
show: function() {
105-
this.active = this.element;
106102
this.element.show();
107103
},
108104
hide: function() {

0 commit comments

Comments
 (0)