Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dialog: Add the possibility to set dialog("option", "zIndex", 3999) #313

Closed
wants to merge 12 commits into from

3 participants

@PaulUithol

Add the possibility to use '$( ".selector" ).dialog( "option", "zIndex", 3999 );', as noted explicitly in the docs on http://jqueryui.com/demos/dialog/ :

Get or set the zIndex option, after init.

//getter
var zIndex = $( ".selector" ).dialog( "option", "zIndex" );
//setter
$( ".selector" ).dialog( "option", "zIndex", 3999 );

Also added some tests. I'd say this ticket is applicable: http://bugs.jqueryui.com/ticket/4975 .

@gnarf gnarf commented on the diff
ui/jquery.ui.dialog.js
@@ -595,6 +595,22 @@ $.widget("ui.dialog", {
$( ".ui-dialog-title", self.uiDialogTitlebar )
.html( "" + ( value || " " ) );
break;
+ case "zIndex":
+ if ( value > $.ui.dialog.maxZ ) {
@gnarf Owner
gnarf added a note

I think this maxZ should only be set when the dialog is currently displayed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@PaulUithol

Okay, I can easily fix that of course. Can you merge this update when I do?

Edit: alright, done and rebased; is it okay like this?

@jzaefferer jzaefferer referenced this pull request
Merged

Dialog Redesign #787

@jzaefferer
Owner

Don't need this anymore since 3829a37 landed.

@jzaefferer jzaefferer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 19, 2011
  1. @PaulUithol
Commits on May 20, 2011
  1. @PaulUithol
Commits on Jun 30, 2011
  1. @PaulUithol
  2. @PaulUithol
  3. @PaulUithol
  4. @PaulUithol

    Merge branch 'master' of github.com:PaulUithol/jquery-ui

    PaulUithol authored
    Conflicts:
    	ui/jquery.ui.dialog.js
Commits on Aug 2, 2011
  1. @PaulUithol
  2. @PaulUithol
  3. @PaulUithol
  4. @PaulUithol
  5. @PaulUithol

    Merge branch 'master' of github.com:PaulUithol/jquery-ui

    PaulUithol authored
    Conflicts:
    	tests/unit/dialog/dialog_options.js
    	ui/jquery.ui.dialog.js
Commits on Jan 3, 2012
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 0 deletions.
  1. +32 −0 tests/unit/dialog/dialog_options.js
  2. +19 −0 ui/jquery.ui.dialog.js
View
32 tests/unit/dialog/dialog_options.js
@@ -446,4 +446,36 @@ test("width", function() {
el.remove();
});
+test("zIndex", function() {
+ expect(9);
+
+ el = $('<div></div>').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 = $('<div></div>').dialog();
+ equals(dlg().css( 'zIndex' ), $.ui.dialog.maxZ, "default zIndex");
+ el.remove();
+
+ // 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
+ // 'moveToTop'. Is this the desired behavior?
+ el = $('<div></div>').dialog({zIndex: 1584 });
+ equals(dlg().css('zIndex'), $.ui.dialog.maxZ, "explicit zIndex at instantiation below $.ui.dialog.maxZ is ignored");
+ el.remove();
+});
+
})(jQuery);
View
19 ui/jquery.ui.dialog.js
@@ -605,6 +605,25 @@ $.widget("ui.dialog", {
$( ".ui-dialog-title", self.uiDialogTitlebar )
.html( "" + ( value || "&#160;" ) );
break;
+ case "zIndex":
+ if ( value > $.ui.dialog.maxZ ) {
@gnarf Owner
gnarf added a note

I think this maxZ should only be set when the dialog is currently displayed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ // Increment the 'maxZ' counters when this dialog is currently visible
+ if ( self.isOpen() ) {
+ $.ui.dialog.maxZ = value;
+
+ if ( self.overlay ) {
+ $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
+ $.ui.dialog.maxZ += 1;
+ }
+ }
+
+ value = $.ui.dialog.maxZ;
+ }
+
+ self.overlay && self.overlay.$el.css( "z-index", value - 1 );
+ uiDialog.css( "z-index", value );
+
+ break;
}
this._super( key, value );
Something went wrong with that request. Please try again.