diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-06-18 10:57:20 +0200 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-06-18 10:57:20 +0200 |
commit | b376fa8dda91aefb50c7a5a7d9ab8dace9eccd0d (patch) | |
tree | 3616367e043bd706c9cd6a39493ede16695287b3 /ui/jquery.ui.menu.js | |
parent | 921e40faff55584a1dd3bc884efb2fab5830b682 (diff) | |
download | jquery-ui-b376fa8dda91aefb50c7a5a7d9ab8dace9eccd0d.tar.gz jquery-ui-b376fa8dda91aefb50c7a5a7d9ab8dace9eccd0d.zip |
Menu: Implemented destroy method and disabled option, modified test to pass html-compare-destroy test and extended default visual test for testing destroy and disabled features
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r-- | ui/jquery.ui.menu.js | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 895a6a806..e761549e1 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -23,6 +23,9 @@ $.widget("ui.menu", { "aria-activedescendant": "ui-active-menuitem" }) .click(function( event ) { + if (self.options.disabled) { + return false; + } if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) { return; } @@ -36,6 +39,9 @@ $.widget("ui.menu", { this.options.input = this.element.attr("tabindex", 0); } this.options.input.bind("keydown.menu", function(event) { + if (self.options.disabled) { + return; + } switch (event.keyCode) { case $.ui.keyCode.PAGE_UP: self.previousPage(); @@ -67,8 +73,21 @@ $.widget("ui.menu", { }, destroy: function() { - // TODO implement destroy - $.Widget.prototype.apply(this, arguments); + $.Widget.prototype.destroy.apply(this, arguments); + + this.element + .removeClass("ui-menu ui-widget ui-widget-content ui-corner-all") + .removeAttr("tabindex") + .removeAttr("role") + .removeAttr("aria-activedescendant"); + + this.element.children(".ui-menu-item") + .removeClass("ui-menu-item") + .removeAttr("role") + .children("a") + .removeClass("ui-corner-all") + .removeAttr("tabindex") + .unbind(".menu"); }, refresh: function() { @@ -83,10 +102,16 @@ $.widget("ui.menu", { .addClass("ui-corner-all") .attr("tabindex", -1) // mouseenter doesn't work with event delegation - .mouseenter(function( event ) { + .bind("mouseenter.menu", function( event ) { + if (self.options.disabled) { + return; + } self.activate( event, $(this).parent() ); }) - .mouseleave(function() { + .bind("mouseleave.menu", function() { + if (self.options.disabled) { + return; + } self.deactivate(); }); }, |