Skip to content

Menu: Fix style issues #1491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//>>css.structure: ../themes/base/menu.css
//>>css.theme: ../themes/base/theme.css

(function( factory ) {
( function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define([
define( [
"jquery",
"./core",
"./widget",
Expand All @@ -31,7 +31,7 @@
// Browser globals
factory( jQuery );
}
}(function( $ ) {
}( function( $ ) {

return $.widget( "ui.menu", {
version: "@VERSION",
Expand Down Expand Up @@ -64,18 +64,18 @@ return $.widget( "ui.menu", {
this.mouseHandled = false;
this.element
.uniqueId()
.attr({
.attr( {
role: this.options.role,
tabIndex: 0
});
} );

if ( this.options.disabled ) {
this._addClass( null, "ui-state-disabled" );
this.element.attr( "aria-disabled", "true" );
}

this._addClass( "ui-menu", "ui-widget ui-widget-content" );
this._on({
this._on( {

// Prevent focus from sticking to links inside menu after clicking
// them (focus should always stay on UL during navigation).
Expand Down Expand Up @@ -134,14 +134,14 @@ return $.widget( "ui.menu", {
}
},
blur: function( event ) {
this._delay(function() {
if ( !$.contains( this.element[0], $.ui.safeActiveElement( this.document[0] ) ) ) {
this._delay( function() {
if ( !$.contains( this.element[ 0 ], $.ui.safeActiveElement( this.document[ 0 ] ) ) ) {
this.collapseAll( event );
}
});
} );
},
keydown: "_keydown"
});
} );

this.refresh();

Expand All @@ -155,7 +155,7 @@ return $.widget( "ui.menu", {
// Reset the mouseHandled flag
this.mouseHandled = false;
}
});
} );
},

_destroy: function() {
Expand All @@ -181,12 +181,12 @@ return $.widget( "ui.menu", {
.removeUniqueId()
.show();

submenus.children().each(function() {
submenus.children().each( function() {
var elem = $( this );
if ( elem.data( "ui-menu-submenu-caret" ) ) {
elem.remove();
}
});
} );
},

_keydown: function( event ) {
Expand Down Expand Up @@ -256,7 +256,7 @@ return $.widget( "ui.menu", {
if ( match.length ) {
this.focus( event, match );
this.previousFilter = character;
this.filterTimer = this._delay(function() {
this.filterTimer = this._delay( function() {
delete this.previousFilter;
}, 1000 );
} else {
Expand Down Expand Up @@ -290,12 +290,12 @@ return $.widget( "ui.menu", {
// Initialize nested menus
newSubmenus = submenus.filter( ":not(.ui-menu)" )
.hide()
.attr({
.attr( {
role: this.options.role,
"aria-hidden": "true",
"aria-expanded": "false"
})
.each(function() {
} )
.each( function() {
var menu = $( this ),
item = menu.prev(),
submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
Expand All @@ -305,30 +305,30 @@ return $.widget( "ui.menu", {
.attr( "aria-haspopup", "true" )
.prepend( submenuCaret );
menu.attr( "aria-labelledby", item.attr( "id" ) );
});
} );

this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );

menus = submenus.add( this.element );
items = menus.find( this.options.items );

// Initialize menu-items containing spaces and/or dashes only as dividers
items.not( ".ui-menu-item" ).each(function() {
items.not( ".ui-menu-item" ).each( function() {
var item = $( this );
if ( that._isDivider( item ) ) {
that._addClass( item, "ui-menu-divider", "ui-widget-content" );
}
});
} );

// Don't refresh list items that are already adapted
newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
newWrappers = newItems.children()
.not( ".ui-menu" )
.uniqueId()
.attr({
.attr( {
tabIndex: -1,
role: this._itemRole()
});
} );
this._addClass( newItems, "ui-menu-item" )
._addClass( newWrappers, "ui-menu-item-wrapper" );

Expand Down Expand Up @@ -388,14 +388,14 @@ return $.widget( "ui.menu", {
if ( event && event.type === "keydown" ) {
this._close();
} else {
this.timer = this._delay(function() {
this.timer = this._delay( function() {
this._close();
}, this.delay );
}

nested = item.children( ".ui-menu" );
if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
this._startOpening(nested);
this._startOpening( nested );
}
this.activeMenu = item.parent();

Expand All @@ -405,8 +405,8 @@ return $.widget( "ui.menu", {
_scrollIntoView: function( item ) {
var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
if ( this._hasScroll() ) {
borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
scroll = this.activeMenu.scrollTop();
elementHeight = this.activeMenu.height();
Expand Down Expand Up @@ -445,14 +445,14 @@ return $.widget( "ui.menu", {
return;
}

this.timer = this._delay(function() {
this.timer = this._delay( function() {
this._close();
this._open( submenu );
}, this.delay );
},

_open: function( submenu ) {
var position = $.extend({
var position = $.extend( {
of: this.active
}, this.options.position );

Expand All @@ -470,7 +470,7 @@ return $.widget( "ui.menu", {

collapseAll: function( event, all ) {
clearTimeout( this.timer );
this.timer = this._delay(function() {
this.timer = this._delay( function() {
// If we were passed an event, look for the submenu that contains the event
var currentMenu = all ? this.element :
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
Expand Down Expand Up @@ -527,16 +527,16 @@ return $.widget( "ui.menu", {
var newItem = this.active &&
this.active
.children( ".ui-menu " )
.find( this.options.items )
.first();
.find( this.options.items )
.first();

if ( newItem && newItem.length ) {
this._open( newItem.parent() );

// Delay so Firefox will not hide activedescendant change in expanding submenu from AT
this._delay(function() {
this._delay( function() {
this.focus( event, newItem );
});
} );
}
},

Expand Down Expand Up @@ -589,10 +589,10 @@ return $.widget( "ui.menu", {
if ( this._hasScroll() ) {
base = this.active.offset().top;
height = this.element.height();
this.active.nextAll( ".ui-menu-item" ).each(function() {
this.active.nextAll( ".ui-menu-item" ).each( function() {
item = $( this );
return item.offset().top - base - height < 0;
});
} );

this.focus( event, item );
} else {
Expand All @@ -613,10 +613,10 @@ return $.widget( "ui.menu", {
if ( this._hasScroll() ) {
base = this.active.offset().top;
height = this.element.height();
this.active.prevAll( ".ui-menu-item" ).each(function() {
this.active.prevAll( ".ui-menu-item" ).each( function() {
item = $( this );
return item.offset().top - base + height > 0;
});
} );

this.focus( event, item );
} else {
Expand Down Expand Up @@ -646,13 +646,13 @@ return $.widget( "ui.menu", {
return this.activeMenu
.find( this.options.items )

// Only match on items, not dividers or other content (#10571)
.filter( ".ui-menu-item" )
.filter(function() {
return regex.test(
$.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
});
// Only match on items, not dividers or other content (#10571)
.filter( ".ui-menu-item" )
.filter( function() {
return regex.test(
$.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
} );
}
});
} );

}));
} ) );