Skip to content
Permalink
Browse files

Dialog: Refactor _createOverlay and _destroyOverlay to use widget met…

…hods and properties.
  • Loading branch information...
jzaefferer committed Dec 4, 2012
1 parent 1e8baf5 commit 9bd44301d36103a951cd9026682b93b7ff0bdd2f
Showing with 9 additions and 7 deletions.
  1. +9 −7 ui/jquery.ui.dialog.js
@@ -665,17 +665,19 @@ $.widget("ui.dialog", {
// prevent use of anchors and inputs
// we use a setTimeout in case the overlay is created from an
// event that we're going to be cancelling (see #2804)
setTimeout(function() {
this._delay(function() {
// handle $(el).dialog().dialog('close') (see #4065)
if ( $.ui.dialog.overlayInstances ) {
$( document ).bind( "focusin.dialog-overlay", function( event ) {
if ( !$( event.target ).closest( ".ui-dialog").length ) {
event.preventDefault();
$( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable();
this._on( this.document, {
focusin: function( event ) {
if ( !$( event.target ).closest( ".ui-dialog").length ) {
event.preventDefault();
$( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable();
}
}
});
}
}, 1 );
});
}

var $el = this.overlay = $( "<div>" ).addClass( "ui-widget-overlay ui-front" );
@@ -692,7 +694,7 @@ $.widget("ui.dialog", {
}
$.ui.dialog.overlayInstances -= 1;
if ( $.ui.dialog.overlayInstances === 0 ) {
$( [ document, window ] ).unbind( ".dialog-overlay" );
this._off( this.document, "focusin" );
}
this.overlay.remove();
}

0 comments on commit 9bd4430

Please sign in to comment.
You can’t perform that action at this time.