diff options
author | Scott González <scott.gonzalez@gmail.com> | 2009-02-19 01:49:33 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2009-02-19 01:49:33 +0000 |
commit | 06a513b753f4964d79d81995a0040dd0677e103d (patch) | |
tree | aff06fded14e057cd6c3be863e81369c866b50b7 | |
parent | 967074f81178357bded0d0ab7e1538977ac1d763 (diff) | |
download | jquery-ui-06a513b753f4964d79d81995a0040dd0677e103d.tar.gz jquery-ui-06a513b753f4964d79d81995a0040dd0677e103d.zip |
Dialog: Refactored moveToTop, greatly improving performance for opening dialogs in IE. Partial fix for #2807 - dialog UI + modal mode = slow.
-rw-r--r-- | ui/ui.dialog.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ui/ui.dialog.js b/ui/ui.dialog.js index 4cec0f7f3..4448f34f3 100644 --- a/ui/ui.dialog.js +++ b/ui/ui.dialog.js @@ -177,21 +177,22 @@ $.widget("ui.dialog", { // position on open moveToTop: function(force, event) { - if ((this.options.modal && !force) + if ($.ui.dialog.topMostDialog == this + || (this.options.modal && !force) || (!this.options.stack && !this.options.modal)) { return this._trigger('focus', event); } - - var maxZ = this.options.zIndex, options = this.options; - $('.ui-dialog:visible').each(function() { - maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex); - }); - (this.overlay && this.overlay.$el.css('z-index', ++maxZ)); + + if (this.options.zIndex > $.ui.dialog.maxZ) { + $.ui.dialog.maxZ = this.options.zIndex; + } + $.ui.dialog.topMostDialog = this; + (this.overlay && this.overlay.$el.css('z-index', ++$.ui.dialog.maxZ)); //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. // http://ui.jquery.com/bugs/ticket/3193 var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; - this.uiDialog.css('z-index', ++maxZ); + this.uiDialog.css('z-index', ++$.ui.dialog.maxZ); this.element.attr(saveScroll); this._trigger('focus', event); }, @@ -501,6 +502,8 @@ $.extend($.ui.dialog, { getter: 'isOpen', uuid: 0, + maxZ: 0, + topMostDialog: null, getTitleId: function($el) { return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); |