Skip to content

Commit 1af1f8c

Browse files
author
Steven G. Harms
committed
meubar: formatting per JQuery style guide
* foo( "this" ) -> foo("this") * Ensure padding space around argument calls ( foo, bar )
1 parent 8237fb2 commit 1af1f8c

File tree

1 file changed

+66
-67
lines changed

1 file changed

+66
-67
lines changed

ui/jquery.ui.menubar.js

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $.widget( "ui.menubar", {
4747

4848
_initializeMenubarsBoundElement: function() {
4949
this.element
50-
.addClass( "ui-menubar ui-widget-header ui-helper-clearfix" )
50+
.addClass("ui-menubar ui-widget-header ui-helper-clearfix")
5151
.attr( "role", "menubar" );
5252
},
5353

@@ -68,15 +68,15 @@ $.widget( "ui.menubar", {
6868
clearTimeout( menubar.closeTimer );
6969
},
7070
focusout: function( event ) {
71-
menubar.closeTimer = setTimeout( function() {
71+
menubar.closeTimer = setTimeout (function() {
7272
menubar._close( event );
73-
}, 150);
73+
}, 150 );
7474
},
7575
"mouseleave .ui-menubar-item": function( event ) {
7676
if ( menubar.options.autoExpand ) {
7777
menubar.closeTimer = setTimeout( function() {
7878
menubar._close( event );
79-
}, 150);
79+
}, 150 );
8080
}
8181
},
8282
"mouseenter .ui-menubar-item": function( event ) {
@@ -91,12 +91,12 @@ $.widget( "ui.menubar", {
9191
seenFirstItem = false;
9292

9393
this.menuItems
94-
.addClass( "ui-menubar-item" )
94+
.addClass("ui-menubar-item")
9595
.attr( "role", "presentation" );
9696

9797
$.each( this.menuItems, function( index, menuItem ){
9898
menubar._initializeMenuItem( $( menuItem ), menubar, seenFirstItem );
99-
});
99+
} );
100100
},
101101

102102
_initializeMenuItem: function( $menuItem, menubar ) {
@@ -122,29 +122,29 @@ $.widget( "ui.menubar", {
122122
var subMenus = $menuItem.children( menubar.options.menuElement );
123123

124124
subMenus
125-
.menu({
126-
position: {
127-
within: this.options.position.within
128-
},
129-
select: function( event, ui ) {
130-
ui.item.parents( "ul.ui-menu:last" ).hide();
131-
menubar._close();
132-
// TODO what is this targetting? there's probably a better way to access it
133-
$( event.target ).prev().focus();
134-
menubar._trigger( "select", event, ui );
135-
},
136-
menus: this.options.menuElement
137-
})
138-
.hide()
139-
.attr({
140-
"aria-hidden": "true",
141-
"aria-expanded": "false"
142-
});
125+
.menu({
126+
position: {
127+
within: this.options.position.within
128+
},
129+
select: function( event, ui ) {
130+
ui.item.parents("ul.ui-menu:last").hide();
131+
menubar._close();
132+
// TODO what is this targetting? there's probably a better way to access it
133+
$( event.target ).prev().focus();
134+
menubar._trigger( "select", event, ui );
135+
},
136+
menus: this.options.menuElement
137+
})
138+
.hide()
139+
.attr({
140+
"aria-hidden": "true",
141+
"aria-expanded": "false"
142+
});
143143

144144
this._on( subMenus, {
145145
keydown: function( event ) {
146146
var menu = $( this );
147-
if ( menu.is( ":hidden" ) ) {
147+
if ( menu.is(":hidden") ) {
148148
return;
149149
}
150150
switch ( event.keyCode ) {
@@ -187,19 +187,19 @@ $.widget( "ui.menubar", {
187187
}
188188

189189
if ( menubar.options.menuIcon ) {
190-
$anItem.addClass( "ui-state-default" ).append( "<span class='ui-button-icon-secondary ui-icon ui-icon-triangle-1-s'></span>" );
191-
$anItem.removeClass( "ui-button-text-only" ).addClass( "ui-button-text-icon-secondary" );
190+
$anItem.addClass("ui-state-default").append("<span class='ui-button-icon-secondary ui-icon ui-icon-triangle-1-s'></span>");
191+
$anItem.removeClass("ui-button-text-only").addClass("ui-button-text-icon-secondary");
192192
}
193193
},
194194

195195
_applyDOMPropertiesOnItem: function( $item, menubar) {
196196
$item
197-
.addClass( "ui-button ui-widget ui-button-text-only ui-menubar-link" )
197+
.addClass("ui-button ui-widget ui-button-text-only ui-menubar-link")
198198
.attr( "role", "menuitem" )
199-
.wrapInner( "<span class='ui-button-text'></span>" );
199+
.wrapInner("<span class='ui-button-text'></span>");
200200

201201
if ( menubar.options.buttons ) {
202-
$item.removeClass( "ui-menubar-link" ).addClass( "ui-state-default" );
202+
$item.removeClass("ui-menubar-link").addClass("ui-state-default");
203203
}
204204
},
205205

@@ -213,7 +213,7 @@ $.widget( "ui.menubar", {
213213
event.preventDefault();
214214
// TODO can we simplify or extract this check? especially the last two expressions
215215
// there's a similar active[0] == menu[0] check in _open
216-
if ( event.type === "click" && menu.is( ":visible" ) && this.active && this.active[0] === menu[0] ) {
216+
if ( event.type === "click" && menu.is(":visible") && this.active && this.active[0] === menu[0] ) {
217217
this._close();
218218
return;
219219
}
@@ -296,34 +296,34 @@ $.widget( "ui.menubar", {
296296

297297
_destroy : function() {
298298
this.menuItems
299-
.removeClass( "ui-menubar-item" )
300-
.removeAttr( "role" );
299+
.removeClass("ui-menubar-item")
300+
.removeAttr("role");
301301

302302
this.element
303-
.removeClass( "ui-menubar ui-widget-header ui-helper-clearfix" )
304-
.removeAttr( "role" )
305-
.unbind( ".menubar" );
303+
.removeClass("ui-menubar ui-widget-header ui-helper-clearfix")
304+
.removeAttr("role")
305+
.unbind(".menubar");
306306

307307
this.items
308-
.unbind( ".menubar" )
309-
.removeClass( "ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default" )
310-
.removeAttr( "role" )
311-
.removeAttr( "aria-haspopup" )
308+
.unbind(".menubar")
309+
.removeClass("ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default")
310+
.removeAttr("role")
311+
.removeAttr("aria-haspopup")
312312
// TODO unwrap?
313-
.children( "span.ui-button-text" ).each(function( i, e ) {
313+
.children("span.ui-button-text").each(function( i, e ) {
314314
var item = $( this );
315315
item.parent().html( item.html() );
316316
})
317317
.end()
318-
.children( ".ui-icon" ).remove();
318+
.children(".ui-icon").remove();
319319

320-
this.element.find( ":ui-menu" )
321-
.menu( "destroy" )
320+
this.element.find(":ui-menu")
321+
.menu("destroy")
322322
.show()
323-
.removeAttr( "aria-hidden" )
324-
.removeAttr( "aria-expanded" )
325-
.removeAttr( "tabindex" )
326-
.unbind( ".menubar" );
323+
.removeAttr("aria-hidden")
324+
.removeAttr("aria-expanded")
325+
.removeAttr("tabindex")
326+
.unbind(".menubar");
327327
},
328328

329329
_close: function() {
@@ -341,8 +341,8 @@ $.widget( "ui.menubar", {
341341
});
342342
this.active
343343
.prev()
344-
.removeClass( "ui-state-active" )
345-
.removeAttr( "tabIndex" );
344+
.removeClass("ui-state-active")
345+
.removeAttr("tabIndex");
346346
this.active.closest( this.options.items ).removeClass("ui-state-active");
347347
} else {
348348
this.active
@@ -365,30 +365,30 @@ $.widget( "ui.menubar", {
365365
// TODO refactor, almost the same as _close above, but don't remove tabIndex
366366
if ( this.active.closest( this.options.items ).data("hasSubMenu") ) {
367367
this.active
368-
.menu( "collapseAll" )
368+
.menu("collapseAll")
369369
.hide()
370370
.attr({
371371
"aria-hidden": "true",
372372
"aria-expanded": "false"
373373
});
374374
this.active.closest(this.options.items)
375-
.removeClass( "ui-state-active" );
375+
.removeClass("ui-state-active");
376376
} else {
377-
this.active.removeClass( "ui-state-active" );
377+
this.active.removeClass("ui-state-active");
378378
}
379379
}
380380

381381
// set tabIndex -1 to have the button skipped on shift-tab when menu is open (it gets focus)
382-
button = menuItem.addClass( "ui-state-active" ).attr( "tabIndex", -1 );
382+
button = menuItem.addClass("ui-state-active").attr( "tabIndex", -1 );
383383

384384
this.active = menu
385385
.show()
386386
.position( $.extend({
387387
of: button
388388
}, this.options.position ) )
389-
.removeAttr( "aria-hidden" )
390-
.attr( "aria-expanded", "true" )
391-
.menu("focus", event, menu.children( ".ui-menu-item" ).first() )
389+
.removeAttr("aria-hidden")
390+
.attr("aria-expanded", "true")
391+
.menu("focus", event, menu.children(".ui-menu-item").first() )
392392
// TODO need a comment here why both events are triggered
393393
.focus()
394394
.focusin();
@@ -400,7 +400,7 @@ $.widget( "ui.menubar", {
400400
if ( this.open &&
401401
this.active.closest( this.options.items ).data("hasSubMenu") &&
402402
this.active.data("menu").active &&
403-
this.active.data( "menu" ).active.has( ".ui-menu" ).length ) {
403+
this.active.data("menu").active.has(".ui-menu").length ) {
404404
// Track number of open submenus and prevent moving to next menubar item
405405
this.openSubmenus++;
406406
return;
@@ -426,15 +426,15 @@ $.widget( "ui.menubar", {
426426

427427
if ( this.open ) {
428428
next = this.active.
429-
closest( ".ui-menubar-item" )[ direction + "All" ]( this.options.items )
430-
.first();
429+
closest(".ui-menubar-item")[ direction + "All" ]( this.options.items )
430+
.first();
431431
wrapItem = this.menuItems[ filter ]();
432432
} else {
433433
if ( event ) {
434-
next = $( event.target ).closest( ".ui-menubar-item" )[ direction + "All" ]( this.options.items ).children( ".ui-menubar-link" ).eq( 0 );
435-
wrapItem = this.menuItems[ filter ]().children( ".ui-menubar-link" ).eq( 0 );
434+
next = $( event.target ).closest(".ui-menubar-item")[ direction + "All" ]( this.options.items ).children(".ui-menubar-link").eq( 0 );
435+
wrapItem = this.menuItems[ filter ]().children(".ui-menubar-link").eq( 0 );
436436
} else {
437-
next = wrapItem = this.menuItems.children( "a" ).eq( 0 );
437+
next = wrapItem = this.menuItems.children("a").eq( 0 );
438438
}
439439
}
440440

@@ -449,9 +449,8 @@ $.widget( "ui.menubar", {
449449
this._submenuless_open( event, next );
450450
}
451451
} else {
452-
next.removeAttr( "tabIndex")[0].focus();
452+
next.removeAttr("tabIndex")[0].focus();
453453
}
454-
455454
},
456455

457456
_submenuless_open: function( event, next ) {
@@ -462,15 +461,15 @@ $.widget( "ui.menubar", {
462461
// TODO refactor, almost the same as _close above, but don't remove tabIndex
463462
if ( this.active.closest( this.options.items ) ) {
464463
this.active
465-
.menu( "collapseAll" )
464+
.menu("collapseAll")
466465
.hide()
467466
.attr({
468467
"aria-hidden": "true",
469468
"aria-expanded": "false"
470469
});
471470
}
472471
this.active.closest(this.options.items)
473-
.removeClass( "ui-state-active" );
472+
.removeClass("ui-state-active");
474473
}
475474

476475
// set tabIndex -1 to have the button skipped on shift-tab when menu is open (it gets focus)

0 commit comments

Comments
 (0)