aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.dialog.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-12-04 01:08:34 +0100
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-12-04 01:08:34 +0100
commit1e8baf568365f8edc833439315f76e5efe1ba9b6 (patch)
treea59e9ff03f729d46b18530621797ad65c77f87b5 /ui/jquery.ui.dialog.js
parentb9068c1523f39da8a04c799eebc9adc8b83c7279 (diff)
downloadjquery-ui-1e8baf568365f8edc833439315f76e5efe1ba9b6.tar.gz
jquery-ui-1e8baf568365f8edc833439315f76e5efe1ba9b6.zip
Dialog: Remove the instance-storing for the overlay, just create one whenever it is needed. Heavily simplifies the code, while the memorly leak should be hardly an issue anymore, since fixed positioning restricts the overlay size to the window dimensions. Fixes #6058 - Dialog overlays are not properly reused when multiple instances of a Dialog exist.
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r--ui/jquery.ui.dialog.js27
1 files changed, 7 insertions, 20 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 382008e08..77392cb19 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -661,13 +661,13 @@ $.widget("ui.dialog", {
if ( !this.options.modal ) {
return;
}
- if ( $.ui.dialog.overlay.instances.length === 0 ) {
+ if ( $.ui.dialog.overlayInstances === 0 ) {
// 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() {
// handle $(el).dialog().dialog('close') (see #4065)
- if ( $.ui.dialog.overlay.instances.length ) {
+ if ( $.ui.dialog.overlayInstances ) {
$( document ).bind( "focusin.dialog-overlay", function( event ) {
if ( !$( event.target ).closest( ".ui-dialog").length ) {
event.preventDefault();
@@ -678,40 +678,27 @@ $.widget("ui.dialog", {
}, 1 );
}
- // reuse old instances due to IE memory leak with alpha transparency (see #5185)
- var $el = this.overlay = ( $.ui.dialog.overlay.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay ui-front" ) );
-
+ var $el = this.overlay = $( "<div>" ).addClass( "ui-widget-overlay ui-front" );
$el.appendTo( this.document[ 0 ].body );
-
this._on( $el, {
mousedown: "_keepFocus"
});
-
- $.ui.dialog.overlay.instances.push( $el );
+ $.ui.dialog.overlayInstances += 1;
},
_destroyOverlay: function() {
if ( !this.options.modal ) {
return;
}
- var indexOf = $.inArray( this.overlay, $.ui.dialog.overlay.instances );
-
- if ( indexOf !== -1 ) {
- $.ui.dialog.overlay.oldInstances.push( $.ui.dialog.overlay.instances.splice( indexOf, 1 )[ 0 ] );
- }
-
- if ( $.ui.dialog.overlay.instances.length === 0 ) {
+ $.ui.dialog.overlayInstances -= 1;
+ if ( $.ui.dialog.overlayInstances === 0 ) {
$( [ document, window ] ).unbind( ".dialog-overlay" );
}
-
this.overlay.remove();
}
});
-$.ui.dialog.overlay = {
- instances: [],
- oldInstances: []
-};
+$.ui.dialog.overlayInstances = 0;
// DEPRECATED
if ( $.uiBackCompat !== false ) {