From b4c5a462330d9f2bf5a76d0d54a42156b3442b28 Mon Sep 17 00:00:00 2001 From: Paul Uithol Date: Thu, 19 May 2011 17:11:51 +0200 Subject: [PATCH] Add the possibility to use '$( ".selector" ).dialog( "option", "zIndex", 3999 );', as noted in the docs on http://jqueryui.com/demos/dialog/ . --- tests/unit/dialog/dialog_options.js | 27 +++++++++++++++++++++++++++ ui/jquery.ui.dialog.js | 3 +++ 2 files changed, 30 insertions(+) diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 5705da07907..041ca554b61 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -441,4 +441,31 @@ test("width", function() { el.remove(); }); +test("zIndex", function() { + expect(6); + + el = $('
').dialog( { autoOpen: false } ); + equals(dlg().css( 'zIndex' ), 1000, "default zIndex"); + el.dialog("open"); + equals(dlg().css( 'zIndex' ), $.ui.dialog.maxZ, "default zIndex"); + el.remove(); + + el = $('
').dialog(); + 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 = $('
').dialog({zIndex: 2932 }); + equals(dlg().css('zIndex'), 2932 + 1, "explicit zIndex"); + el.dialog('option', 'zIndex', 1748); + equals(dlg().css('zIndex'), 1748, 'explicit zIndex after init'); + el.remove(); + + // At the moment, an explicit zIndex option lower than $.ui.dialog.maxZ will be ignored since 'open' calls + // 'moveToTop'. Is this the desired behavior? + el = $('
').dialog({zIndex: 1584 }); + equals(dlg().css('zIndex'), $.ui.dialog.maxZ, "explicit zIndex, lower than $.ui.dialog.maxZ, is ignored"); + el.remove(); +}); + })(jQuery); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index dc2849155e0..e521d62a269 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -595,6 +595,9 @@ $.widget("ui.dialog", { $( ".ui-dialog-title", self.uiDialogTitlebar ) .html( "" + ( value || " " ) ); break; + case "zIndex": + uiDialog.css({ zIndex: value }); + break; } this._super( "_setOption", key, value );