vendor/assets/javascripts/jquery.ui.menu.js in jquery-ui-rails-3.0.1 vs vendor/assets/javascripts/jquery.ui.menu.js in jquery-ui-rails-4.0.0
- old
+ new
@@ -1,14 +1,14 @@
//= require jquery.ui.core
//= require jquery.ui.widget
//= require jquery.ui.position
/*!
- * jQuery UI Menu 1.9.2
+ * jQuery UI Menu 1.10.0
* http://jqueryui.com
*
- * Copyright 2012 jQuery Foundation and other contributors
+ * Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/menu/
*
@@ -17,14 +17,12 @@
* jquery.ui.widget.js
* jquery.ui.position.js
*/
(function( $, undefined ) {
-var mouseHandled = false;
-
$.widget( "ui.menu", {
- version: "1.9.2",
+ version: "1.10.0",
defaultElement: "<ul>",
delay: 300,
options: {
icons: {
submenu: "ui-icon-carat-1-e"
@@ -42,10 +40,13 @@
select: null
},
_create: function() {
this.activeMenu = this.element;
+ // flag used to prevent firing of the click handler
+ // as the event bubbles up through nested menus
+ this.mouseHandled = false;
this.element
.uniqueId()
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
.attr({
@@ -75,12 +76,12 @@
"click .ui-state-disabled > a": function( event ) {
event.preventDefault();
},
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target ).closest( ".ui-menu-item" );
- if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
- mouseHandled = true;
+ if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+ this.mouseHandled = true;
this.select( event );
// Open submenu on click
if ( target.has( ".ui-menu" ).length ) {
this.expand( event );
@@ -132,20 +133,20 @@
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
this.collapseAll( event );
}
// Reset the mouseHandled flag
- mouseHandled = false;
+ this.mouseHandled = false;
}
});
},
_destroy: function() {
// Destroy (sub)menus
this.element
.removeAttr( "aria-activedescendant" )
- .find( ".ui-menu" ).andSelf()
+ .find( ".ui-menu" ).addBack()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
.removeAttr( "role" )
.removeAttr( "tabIndex" )
.removeAttr( "aria-labelledby" )
.removeAttr( "aria-expanded" )
@@ -175,10 +176,11 @@
// Destroy menu dividers
this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
},
_keydown: function( event ) {
+ /*jshint maxcomplexity:20*/
var match, prev, character, skip, regex,
preventDefault = true;
function escape( value ) {
return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
@@ -342,9 +344,18 @@
_itemRole: function() {
return {
menu: "menuitem",
listbox: "option"
}[ this.options.role ];
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "icons" ) {
+ this.element.find( ".ui-menu-icon" )
+ .removeClass( this.options.icons.submenu )
+ .addClass( value.submenu );
+ }
+ this._super( key, value );
},
focus: function( event, item ) {
var nested, focused;
this.blur( event, event && event.type === "focus" );