Skip to content

Commit

Permalink
Popup: Rename _close to close and use it when selecting something wit…
Browse files Browse the repository at this point in the history
…hin a popup.
  • Loading branch information
jzaefferer committed May 4, 2011
1 parent bba4cb2 commit b96126b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions demos/tooltip/video-player.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
});
$(".set").buttonset();

// TODO hide the tooltip when clicking the button
$("ul").menu().popup({
$("ul").menu({
select: function() {
// would also execute some other action here
$(this).popup("close");
}
}).popup({
trigger: $(".menu")
});

Expand Down
2 changes: 1 addition & 1 deletion tests/visual/menu/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
var selected = {
select: function( event, ui ) {
$( "<div/>" ).text( "Selected: " + ui.item.text() ).appendTo( "#log" );
$(this).hide();
$(this).popup("close");
}
};

Expand Down
10 changes: 5 additions & 5 deletions tests/visual/menu/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $.widget( "ui.popup", {

this.element
.addClass("ui-popup")
this._close();
this.close();

this._bind(this.options.trigger, {
click: function( event ) {
Expand All @@ -53,15 +53,15 @@ $.widget( "ui.popup", {
this._bind(this.element, {
// TODO also triggered when open and clicking the trigger again
// figure out how to close in that case, while still closing on regular blur
//blur: "_close"
//blur: "close"
});

this._bind({
// TODO only triggerd on element if it can receive focus
// bind to document instead?
keyup: function( event ) {
if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) {
this._close( event );
this.close( event );
this.options.trigger.focus();
}
}
Expand All @@ -70,7 +70,7 @@ $.widget( "ui.popup", {
this._bind(document, {
click: function( event ) {
if (this.open && !$(event.target).closest(".ui-popup").length) {
this._close( event );
this.close( event );
}
}
})
Expand Down Expand Up @@ -114,7 +114,7 @@ $.widget( "ui.popup", {
this._trigger( "open", event );
},

_close: function( event ) {
close: function( event ) {
this.element
.hide()
.attr( "aria-hidden", true )
Expand Down

0 comments on commit b96126b

Please sign in to comment.