Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Take '$.ui.dialog.maxZ' and 'self.overlay' into account.

  • Loading branch information...
commit c0b88f30ab9687e432b72e69fcf5702c6ad38fe3 1 parent b4c5a46
@PaulUithol authored
Showing with 23 additions and 5 deletions.
  1. +9 −4 tests/unit/dialog/dialog_options.js
  2. +14 −1 ui/jquery.ui.dialog.js
View
13 tests/unit/dialog/dialog_options.js
@@ -442,7 +442,7 @@ test("width", function() {
});
test("zIndex", function() {
- expect(6);
+ expect(9);
el = $('<div></div>').dialog( { autoOpen: false } );
equals(dlg().css( 'zIndex' ), 1000, "default zIndex");
@@ -454,11 +454,16 @@ test("zIndex", function() {
equals(dlg().css( 'zIndex' ), $.ui.dialog.maxZ, "default zIndex");
el.remove();
- // The z-index will always be 1 higher than requested if 'moveToTop' gets called, such as when 'autoOpen' is true.
- el = $('<div></div>').dialog({zIndex: 2932 });
- equals(dlg().css('zIndex'), 2932 + 1, "explicit zIndex");
+ // The z-index will be 1 higher than requested if 'moveToTop' gets called, such as when 'autoOpen' is true.
+ newZIndex = $.ui.dialog.maxZ + 2932;
+ el = $('<div></div>').dialog({zIndex: newZIndex });
+ equals(dlg().css('zIndex'), newZIndex + 1, "explicit zIndex");
+ equals( el.dialog( 'option', 'zIndex' ), newZIndex, 'get works for zIndex' );
+ equals( newZIndex + 1, $.ui.dialog.maxZ, '$.ui.dialog.maxZ is updated to the new value' );
+
el.dialog('option', 'zIndex', 1748);
equals(dlg().css('zIndex'), 1748, 'explicit zIndex after init');
+ equals( el.dialog( 'option', 'zIndex' ), 1748 );
el.remove();
// At the moment, an explicit zIndex option lower than $.ui.dialog.maxZ will be ignored since 'open' calls
View
15 ui/jquery.ui.dialog.js
@@ -596,7 +596,20 @@ $.widget("ui.dialog", {
.html( "" + ( value || "&#160;" ) );
break;
case "zIndex":
- uiDialog.css({ zIndex: value });
+ if ( value > $.ui.dialog.maxZ ) {
+ $.ui.dialog.maxZ = value;
+
+ if ( self.overlay ) {
+ $.ui.dialog.maxZ += 1;
+ $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
+ }
+
+ value = $.ui.dialog.maxZ;
+ }
+
+ self.overlay && self.overlay.$el.css( "z-index", value > 0 ? value : 0 );
+ uiDialog.css( "z-index", value );
+
break;
}
Please sign in to comment.
Something went wrong with that request. Please try again.