aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.popup.js')
-rw-r--r--ui/jquery.ui.popup.js48
1 files changed, 30 insertions, 18 deletions
diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js
index 508209a55..ce7a565db 100644
--- a/ui/jquery.ui.popup.js
+++ b/ui/jquery.ui.popup.js
@@ -22,6 +22,14 @@ $.widget( "ui.popup", {
position: {
my: "left top",
at: "left bottom"
+ },
+ show: {
+ effect: "slideDown",
+ duration: "fast"
+ },
+ hide: {
+ effect: "fadeOut",
+ duration: "fast"
}
},
_create: function() {
@@ -45,13 +53,14 @@ $.widget( "ui.popup", {
.attr( "aria-owns", this.element.attr( "id" ) );
this.element
- .addClass( "ui-popup" )
- this.close();
+ .addClass( "ui-popup" );
+ this._beforeClose();
+ this.element.hide();
this._bind(this.options.trigger, {
keydown: function( event ) {
// prevent space-to-open to scroll the page, only happens for anchor ui.button
- if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
+ if ( $.ui.button && this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
event.preventDefault();
}
// TODO handle SPACE to open popup? only when not handled by ui.button
@@ -72,16 +81,15 @@ $.widget( "ui.popup", {
// let it propagate to close
return;
}
- var that = this;
clearTimeout( this.closeTimer );
- setTimeout(function() {
- that.open( event );
+ this._delay(function() {
+ this.open( event );
}, 1);
}
});
- if ( !this.element.is( ":ui-menu" ) ) {
- //default use case, wrap tab order in popup
+ if ( !$.ui.menu || !this.element.is( ":ui-menu" ) ) {
+ // default use case, wrap tab order in popup
this._bind({ keydown : function( event ) {
if ( event.keyCode !== $.ui.keyCode.TAB ) {
return;
@@ -102,11 +110,10 @@ $.widget( "ui.popup", {
this._bind({
focusout: function( event ) {
- var that = this;
// use a timer to allow click to clear it and letting that
// handle the closing instead of opening again
- that.closeTimer = setTimeout( function() {
- that.close( event );
+ this.closeTimer = this._delay( function() {
+ this.close( event );
}, 100);
},
focusin: function( event ) {
@@ -133,7 +140,7 @@ $.widget( "ui.popup", {
this.close( event );
}
}
- })
+ });
},
_destroy: function() {
@@ -161,13 +168,14 @@ $.widget( "ui.popup", {
of: this.options.trigger
}, this.options.position );
+ this._show( this.element, this.options.show );
this.element
- .show()
.attr( "aria-hidden", "false" )
.attr( "aria-expanded", "true" )
.position( position );
- if (this.element.is( ":ui-menu" )) { //popup is a menu
+ // can't use custom selector when menu isn't loaded
+ if ( $.ui.menu && this.element.is( ":ui-menu" ) ) {
this.element.menu( "focus", event, this.element.children( "li" ).first() );
this.element.focus();
} else {
@@ -192,10 +200,8 @@ $.widget( "ui.popup", {
},
close: function( event ) {
- this.element
- .hide()
- .attr( "aria-hidden", "true" )
- .attr( "aria-expanded", "false" );
+ this._beforeClose();
+ this._hide( this.element, this.options.hide );
this.options.trigger.attr( "tabindex" , 0 );
if ( this.removeTabIndex ) {
@@ -203,6 +209,12 @@ $.widget( "ui.popup", {
}
this.isOpen = false;
this._trigger( "close", event );
+ },
+
+ _beforeClose: function() {
+ this.element
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" );
}
});