]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Refactor _createOverlay and _destroyOverlay to use widget methods and properties.
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 4 Dec 2012 00:17:00 +0000 (01:17 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 4 Dec 2012 00:17:00 +0000 (01:17 +0100)
ui/jquery.ui.dialog.js

index 77392cb1992e77ba193013c746a5f2438785173a..472d686a2ce8884f4d2362292eb72bee20bc6d96 100644 (file)
@@ -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();
        }