aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.dialog.js
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2012-10-03 22:37:03 +0200
committerFelix Nagel <info@felixnagel.com>2012-10-03 22:37:03 +0200
commitcca4e77a95eb7024c204f4d0719baa2ef6195ed2 (patch)
tree732a8e171647d9b25b1b2988f09dccc5d182bad7 /ui/jquery.ui.dialog.js
parent5e12c54be1813e1f627d3214c11d7520fb46c647 (diff)
parente8bdf468614e59309b4a02ad4f6c29c1d06083c1 (diff)
downloadjquery-ui-cca4e77a95eb7024c204f4d0719baa2ef6195ed2.tar.gz
jquery-ui-cca4e77a95eb7024c204f4d0719baa2ef6195ed2.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r--ui/jquery.ui.dialog.js46
1 files changed, 22 insertions, 24 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 66c7f4dff..77424047c 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -6,7 +6,7 @@
* Released under the MIT license.
* http://jquery.org/license
*
- * http://docs.jquery.com/UI/Dialog
+ * http://api.jqueryui.com/dialog/
*
* Depends:
* jquery.ui.core.js
@@ -170,6 +170,25 @@ $.widget("ui.dialog", {
if ( $.fn.bgiframe ) {
uiDialog.bgiframe();
}
+
+ // prevent tabbing out of modal dialogs
+ this._on( uiDialog, { keydown: function( event ) {
+ if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
+ return;
+ }
+
+ var tabbables = $( ":tabbable", uiDialog ),
+ first = tabbables.filter( ":first" ),
+ last = tabbables.filter( ":last" );
+
+ if ( event.target === last[0] && !event.shiftKey ) {
+ first.focus( 1 );
+ return false;
+ } else if ( event.target === first[0] && event.shiftKey ) {
+ last.focus( 1 );
+ return false;
+ }
+ }});
},
_init: function() {
@@ -197,7 +216,8 @@ $.widget("ui.dialog", {
}
next = oldPosition.parent.children().eq( oldPosition.index );
- if ( next.length ) {
+ // Don't try to place the dialog next to itself (#8613)
+ if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
next.before( this.element );
} else {
oldPosition.parent.append( this.element );
@@ -225,7 +245,6 @@ $.widget("ui.dialog", {
if ( this.overlay ) {
this.overlay.destroy();
}
- this._off( this.uiDialog, "keypress" );
if ( this.options.hide ) {
this.uiDialog.hide( this.options.hide, function() {
@@ -309,27 +328,6 @@ $.widget("ui.dialog", {
this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
this.moveToTop( true );
- // prevent tabbing out of modal dialogs
- if ( options.modal ) {
- this._on( uiDialog, { keydown: function( event ) {
- if ( event.keyCode !== $.ui.keyCode.TAB ) {
- return;
- }
-
- var tabbables = $( ":tabbable", uiDialog ),
- first = tabbables.filter( ":first" ),
- last = tabbables.filter( ":last" );
-
- if ( event.target === last[0] && !event.shiftKey ) {
- first.focus( 1 );
- return false;
- } else if ( event.target === first[0] && event.shiftKey ) {
- last.focus( 1 );
- return false;
- }
- }});
- }
-
// set focus to the first tabbable element in the content area or the first button
// if there are no tabbable elements, set focus on the dialog itself
hasFocus = this.element.find( ":tabbable" );