mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Menu: Refactoring flyout menu in prepartion for merging into menu
This commit is contained in:
parent
6bd95efe5e
commit
5c687be331
@ -16,7 +16,6 @@ $.widget("ui.flyoutmenu", {
|
|||||||
|
|
||||||
_create: function() {
|
_create: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.active = this.element;
|
|
||||||
this.activeItem = this.element.children("li").first();
|
this.activeItem = this.element.children("li").first();
|
||||||
// hide submenus and create indicator icons
|
// hide submenus and create indicator icons
|
||||||
this.element.find("ul").addClass("ui-menu-flyout").hide().prev("a").prepend('<span class="ui-icon ui-icon-carat-1-e"></span>');
|
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", {
|
|||||||
self._select(event);
|
self._select(event);
|
||||||
},
|
},
|
||||||
focus: function(event, ui) {
|
focus: function(event, ui) {
|
||||||
self.active = ui.item.parent();
|
|
||||||
self.activeItem = ui.item;
|
self.activeItem = ui.item;
|
||||||
|
ui.item.parent().focus();
|
||||||
ui.item.parent().find("ul").hide();
|
ui.item.parent().find("ul").hide();
|
||||||
var nested = $(">ul", ui.item);
|
var nested = $(">ul", ui.item);
|
||||||
if (nested.length && event.originalEvent && /^mouse/.test(event.originalEvent.type)) {
|
if (nested.length && event.originalEvent && /^mouse/.test(event.originalEvent.type)) {
|
||||||
self._open(nested);
|
self._open(nested);
|
||||||
|
nested.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).keydown(function(event) {
|
}).keydown(function(event) {
|
||||||
@ -60,7 +60,7 @@ $.widget("ui.flyoutmenu", {
|
|||||||
_open: function(submenu) {
|
_open: function(submenu) {
|
||||||
// TODO restrict to widget
|
// TODO restrict to widget
|
||||||
//only one menu can have items open at a time.
|
//only one menu can have items open at a time.
|
||||||
$(document).find(".ui-menu-flyout").not(submenu.parents()).hide();
|
$(document).find(".ui-menu-flyout").not(submenu.parents()).hide().data("menu").blur();
|
||||||
|
|
||||||
var position = $.extend({}, {
|
var position = $.extend({}, {
|
||||||
of: this.activeItem
|
of: this.activeItem
|
||||||
@ -93,16 +93,12 @@ $.widget("ui.flyoutmenu", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
activate: function(event, item) {
|
activate: function(event, item) {
|
||||||
if (item) {
|
var parent = item.parent();
|
||||||
item.parent().data("menu").widget().show();
|
parent.data("menu").focus(event, item);
|
||||||
item.parent().data("menu").focus(event, item);
|
|
||||||
}
|
|
||||||
this.activeItem = item;
|
this.activeItem = item;
|
||||||
this.active = item.parent("ul")
|
parent.focus();
|
||||||
this.active.focus();
|
|
||||||
},
|
},
|
||||||
show: function() {
|
show: function() {
|
||||||
this.active = this.element;
|
|
||||||
this.element.show();
|
this.element.show();
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user