aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.dialog.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2013-08-06 15:06:08 -0400
committerScott González <scott.gonzalez@gmail.com>2013-08-07 08:57:36 -0400
commitc9815f13b487d027ef9b6095588dbb73141c9a09 (patch)
treee71e3d512cce33d39c6c868743135ddc81c60533 /ui/jquery.ui.dialog.js
parent92d54213958561ea1cfcdbaaaa53bbb6037a1e86 (diff)
downloadjquery-ui-c9815f13b487d027ef9b6095588dbb73141c9a09.tar.gz
jquery-ui-c9815f13b487d027ef9b6095588dbb73141c9a09.zip
Dialog: Search the correct document for focus trapping. Fixes #9439 - Dialog: Context is not respected for modals.
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r--ui/jquery.ui.dialog.js55
1 files changed, 32 insertions, 23 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index b94757505..4279d357c 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -724,22 +724,27 @@ $.widget( "ui.dialog", {
return;
}
- var that = this,
- widgetFullName = this.widgetFullName;
- if ( !$.ui.dialog.overlayInstances ) {
- // Prevent use of anchors and inputs.
- // We use a delay in case the overlay is created from an
- // event that we're going to be cancelling. (#2804)
- this._delay(function() {
- // Handle .dialog().dialog("close") (#4065)
- if ( $.ui.dialog.overlayInstances ) {
- this.document.bind( "focusin.dialog", function( event ) {
- if ( !that._allowInteraction( event ) ) {
- event.preventDefault();
- $(".ui-dialog:visible:last .ui-dialog-content")
- .data( widgetFullName )._focusTabbable();
- }
- });
+ // We use a delay in case the overlay is created from an
+ // event that we're going to be cancelling (#2804)
+ var isOpening = true;
+ this._delay(function() {
+ isOpening = false;
+ });
+
+ if ( !this.document.data( "ui-dialog-overlays" ) ) {
+
+ // Prevent use of anchors and inputs
+ this._on( this.document, {
+ focusin: function( event ) {
+ if ( isOpening ) {
+ return;
+ }
+
+ if ( !this._allowInteraction( event ) ) {
+ event.preventDefault();
+ this.document.find( ".ui-dialog:visible:last .ui-dialog-content" )
+ .data( this.widgetFullName )._focusTabbable();
+ }
}
});
}
@@ -750,7 +755,8 @@ $.widget( "ui.dialog", {
this._on( this.overlay, {
mousedown: "_keepFocus"
});
- $.ui.dialog.overlayInstances++;
+ this.document.data( "ui-dialog-overlays",
+ (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
},
_destroyOverlay: function() {
@@ -759,17 +765,20 @@ $.widget( "ui.dialog", {
}
if ( this.overlay ) {
- $.ui.dialog.overlayInstances--;
-
- if ( !$.ui.dialog.overlayInstances ) {
- this.document.unbind( "focusin.dialog" );
+ var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
+
+ if ( !overlays ) {
+ this.document
+ .off( "focusin" )
+ .removeData( "ui-dialog-overlays" );
+ } else {
+ this.document.data( "ui-dialog-overlays", overlays );
}
+
this.overlay.remove();
this.overlay = null;
}
}
});
-$.ui.dialog.overlayInstances = 0;
-
}( jQuery ) );