mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Menu: Implement delaying of opening and closing submenus
This commit is contained in:
parent
2ddf83faf3
commit
a077047fb3
18
ui/jquery.ui.menu.js
vendored
18
ui/jquery.ui.menu.js
vendored
@ -17,6 +17,7 @@ var idIncrement = 0;
|
||||
|
||||
$.widget("ui.menu", {
|
||||
defaultElement: "<ul>",
|
||||
delay: 150,
|
||||
options: {
|
||||
position: {
|
||||
my: "left top",
|
||||
@ -220,10 +221,12 @@ $.widget("ui.menu", {
|
||||
// see http://groups.google.com/group/jquery-a11y/msg/929e0c1e8c5efc8f
|
||||
this.element.removeAttr("aria-activedescendant").attr("aria-activedescendant", self.itemId)
|
||||
|
||||
self._close();
|
||||
self.timer = setTimeout(function() {
|
||||
self._close();
|
||||
}, self.delay)
|
||||
var nested = $(">ul", item);
|
||||
if (nested.length && /^mouse/.test(event.type)) {
|
||||
self._open(nested);
|
||||
self._startOpening(nested);
|
||||
}
|
||||
this.activeMenu = item.parent();
|
||||
|
||||
@ -235,6 +238,8 @@ $.widget("ui.menu", {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(this.timer);
|
||||
|
||||
this.active.children( "a" ).removeClass( "ui-state-focus" );
|
||||
// remove only generated id
|
||||
$( "#" + this.menuId + "-activedescendant" ).removeAttr( "id" );
|
||||
@ -243,6 +248,15 @@ $.widget("ui.menu", {
|
||||
this.active = null;
|
||||
},
|
||||
|
||||
_startOpening: function(submenu) {
|
||||
clearTimeout(this.timer);
|
||||
var self = this;
|
||||
self.timer = setTimeout(function() {
|
||||
self._close();
|
||||
self._open(submenu);
|
||||
}, self.delay);
|
||||
},
|
||||
|
||||
_open: function(submenu) {
|
||||
this.element.find(".ui-menu").not(submenu.parents()).hide();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user