Permalink
Browse files

Menu: Add _isDivider method

Ability to prevent generation of dividers from items

Fixes #9701
  • Loading branch information...
fnagel committed Dec 18, 2013
1 parent 0cc8554 commit a6806ab17a9a5b332dc7d0c947a0a7a512dc2579
Showing with 8 additions and 4 deletions.
  1. +8 −4 ui/jquery.ui.menu.js
View
@@ -274,10 +274,10 @@ $.widget( "ui.menu", {
},
refresh: function() {
var menus,
items,
var that = this,
icon = this.options.icons.submenu,
submenus = this.element.find( this.options.menus );
submenus = this.element.find( this.options.menus ),
menus, items;

This comment has been minimized.

Show comment
Hide comment
@scottgonzalez

scottgonzalez Dec 18, 2013

Member

Uninitialized variables go at the top, on a single line:

var menus, items,
    that = this,
    ...
@scottgonzalez

scottgonzalez Dec 18, 2013

Member

Uninitialized variables go at the top, on a single line:

var menus, items,
    that = this,
    ...
this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
@@ -310,7 +310,7 @@ $.widget( "ui.menu", {
items.not( ".ui-menu-item" ).each(function() {
var item = $( this );
// hyphen, em dash, en dash

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer Jan 8, 2014

Member

This comment should go into the new _isDivider() method.

@jzaefferer

jzaefferer Jan 8, 2014

Member

This comment should go into the new _isDivider() method.

if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
if ( that._isDivider( item ) ) {
item.addClass( "ui-widget-content ui-menu-divider" );
}
});
@@ -496,6 +496,10 @@ $.widget( "ui.menu", {
return !$( event.target ).closest( ".ui-menu" ).length;
},
_isDivider: function( item ) {
return !/[^\-\u2014\u2013\s]/.test( item.text() );
},
collapse: function( event ) {
var newItem = this.active &&
this.active.parent().closest( ".ui-menu-item", this.element );

0 comments on commit a6806ab

Please sign in to comment.