aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2011-03-17 10:37:37 +0100
committerjzaefferer <joern.zaefferer@gmail.com>2011-03-17 10:37:37 +0100
commita077047fb3d89acca276358be9a544d45fa58d32 (patch)
treef874c153a73afb99cb9c32de03bfb6b58391c319 /ui
parent2ddf83faf3cd5e0e0bf0a43b2e0d16463b0c3cf8 (diff)
downloadjquery-ui-a077047fb3d89acca276358be9a544d45fa58d32.tar.gz
jquery-ui-a077047fb3d89acca276358be9a544d45fa58d32.zip
Menu: Implement delaying of opening and closing submenus
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.menu.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 2addba37e..ad2fa3092 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -17,6 +17,7 @@ var idIncrement = 0;
$.widget("ui.menu", {
defaultElement: "<ul>",
+ delay: 150,
options: {
position: {
my: "left top",
@@ -219,11 +220,13 @@ $.widget("ui.menu", {
// need to remove the attribute before adding it for the screenreader to pick up the change
// 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,9 +248,18 @@ $.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();
-
+
var position = $.extend({}, {
of: this.active
}, $.type(this.options.position) == "function"