-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Menubar #829
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
Menubar #829
Changes from 2 commits
0f33062
82d0056
15bd67f
d4ca89b
f30c853
ec67b65
c57319c
36b5135
1a9f136
ab98a00
2fe73a1
baf9882
0700982
2500c96
bb87639
b74695a
706d882
8237fb2
1af1f8c
908fea5
bb8e2e0
0efe66e
fdc200d
aafdc17
1e8089b
09d51e8
a4a95cc
b2a3814
bab98f2
79b06b2
480de7f
56f6469
100f552
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,25 @@ test( "handle click on menu item", function() { | |
equal( logOutput(), "click,(1,2),afterclick,(2,1),(3,3),(1,2)", "Click order not valid." ); | ||
}); | ||
|
||
test( "hover over a menu item with no sub-menu should close open menu", function() { | ||
expect( 2 ); | ||
|
||
var element = $( "#bar1" ).menubar(); | ||
var links = $("#bar1 > li a"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing between parens and quotes |
||
|
||
var menuItemWithDropdown = links.eq(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't align operators. |
||
var menuItemWithoutDropdown = links.eq(0); | ||
|
||
menuItemWithDropdown.trigger('click', {}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double quotes, spacing, no second argument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for all calls to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scottgonzalez, should I be using .simulate in tests instead of .click() as a general rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikesherov We should probably be using |
||
menuItemWithoutDropdown.trigger('mouseenter', {}); | ||
|
||
equal( $(".ui-menu:visible").length, 0 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a message as the third parameter, so that the failure output is clear. Same for assertion below |
||
|
||
menuItemWithDropdown.trigger('click', {}); | ||
menuItemWithoutDropdown.trigger('click', {}); | ||
|
||
equal( $(".ui-menu:visible").length, 0 ); | ||
|
||
}); | ||
|
||
})( jQuery ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,12 +137,15 @@ $.widget( "ui.menubar", { | |
input.removeClass( "ui-button-text-only" ).addClass( "ui-button-text-icon-secondary" ); | ||
} | ||
} else { | ||
// TODO use _on | ||
input.bind( "click.menubar mouseenter.menubar", function( event ) { | ||
if ( ( that.open && event.type === "mouseenter" ) || event.type === "click" ) { | ||
that._close(); | ||
} | ||
}); | ||
that._on( input, { | ||
click: function( event ) { | ||
if ( that.open ){ that._close(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't being checked for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikesherov It seems to work the same ( |
||
}, | ||
|
||
mouseenter: function( event ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two spaces after the colon for some reason (happened above too). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simple, I double space after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sgharms, @scottgonzalez meant you shouldn't have two spaces there. |
||
if ( that.open ){ that._close(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if ( this.open ) {
this._close();
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above code, use |
||
} | ||
}); | ||
} | ||
|
||
input | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one
var
statement per function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wonder if this was JSHinted using
grunt
, as that should have caught the multiple vars.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was recently debated actually. The most important reason that I know of is to make the scope clear, but that would apply to many var statements at the top of the function as well.
As for grunt, you can run grunt or run the unit tests, both will lint the source files. It sounds like your editor isn't reading in our .jshintrc file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikesherov It's cute that you think we've gotten around to adding a contributing.md :-P I sense one coming from you very soon...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scottgonzalez @mikesherov : is there an editor that supports directory-specific jshint rules? I'm a Vim guy myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sublime Text 2 has a ton of plugins. One is to run JSHint and look for directory level .jshintrc files. That's what @scottgonzalez and I use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wycats Can you point @sgharms at a vim plugin that will find and use the correct .jshintrc based on the current file?