Permalink
Browse files

Changes made per @scottgonzalez 's suggestions. Storing titleId as a …

…property on the dialog instance, storing the instance rather than select data, changed tests to use local variables, and moved updateMaxZ into dialog prototype.
  • Loading branch information...
1 parent b2eda4d commit b15c4193f7333831c2c392eaa81bed9fab7d88fe @Akkuma committed Oct 31, 2011
Showing with 8 additions and 15 deletions.
  1. +3 −3 tests/unit/dialog/dialog_tickets.js
  2. +5 −12 ui/jquery.ui.dialog.js
@@ -37,9 +37,9 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
test("#5388: Don't change z-index when already at the top", function() {
expect(8);
- d1 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false });
- d2 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false });
- d3 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false });
+ var d1 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false }),
+ d2 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false }),
+ d3 = $('<div></div>').appendTo(document.body).dialog({ modal: true, autoOpen: false });
for (var i=0; i < 10; i++) {
d1.dialog('open').dialog('close');
View
@@ -36,16 +36,12 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
},
dialogs = {};
- function getUIDialogUUID($uiDialog) {
- return $uiDialog.attr('aria-labelledby');
- }
-
function updateMaxZ($currentDialog) {
var self = this,
maxZ = self.options.zIndex;
$.each(dialogs, function() {
- if (this.uiDialog[0] !== self.uiDialog[0] && this.isOpen) {
+ if (this.uiDialog[0] !== self.uiDialog[0] && this._isOpen) {
thisZ = this.uiDialog.css('z-index');
if(!isNaN(thisZ)) {
maxZ = Math.max(maxZ, thisZ);
@@ -162,6 +158,8 @@ $.widget("ui.dialog", {
.html( title )
.prependTo( uiDialogTitlebar );
+ self.titleId = titleId;
+
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
this._hoverable( uiDialogTitlebarClose );
this._focusable( uiDialogTitlebarClose );
@@ -180,10 +178,7 @@ $.widget("ui.dialog", {
uiDialog.bgiframe();
}
- dialogs[titleId] = {
- 'uiDialog': uiDialog,
- isOpen: false
- };
+ dialogs[self.titleId] = this;
},
_init: function() {
@@ -199,7 +194,7 @@ $.widget("ui.dialog", {
self.overlay.destroy();
}
self.uiDialog.hide();
- delete dialogs[getUIDialogUUID(self.uiDialog)];
+ delete dialogs[self.titleId];
self.element
.removeClass( "ui-dialog-content ui-widget-content" )
@@ -229,7 +224,6 @@ $.widget("ui.dialog", {
}
self._isOpen = false;
- dialogs[getUIDialogUUID(self.uiDialog)].isOpen = false;
if ( self.overlay ) {
self.overlay.destroy();
@@ -341,7 +335,6 @@ $.widget("ui.dialog", {
hasFocus.eq( 0 ).focus();
self._isOpen = true;
- dialogs[getUIDialogUUID(uiDialog)].isOpen = true;
self._trigger('open');
return self;

0 comments on commit b15c419

Please sign in to comment.