mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Dialog: Refactored event delegation to cancel events for modal dialogs. Fixes #2807 - dialogUI + modal mode = slow.
This commit is contained in:
parent
835cbf1833
commit
3c7e1b3ff9
@ -187,7 +187,7 @@ $.widget("ui.dialog", {
|
|||||||
$.ui.dialog.maxZ = this.options.zIndex;
|
$.ui.dialog.maxZ = this.options.zIndex;
|
||||||
}
|
}
|
||||||
$.ui.dialog.topMostDialog = this;
|
$.ui.dialog.topMostDialog = this;
|
||||||
(this.overlay && this.overlay.$el.css('z-index', ++$.ui.dialog.maxZ));
|
(this.overlay && this.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = ++$.ui.dialog.maxZ));
|
||||||
|
|
||||||
//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
|
//Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
|
||||||
// http://ui.jquery.com/bugs/ticket/3193
|
// http://ui.jquery.com/bugs/ticket/3193
|
||||||
@ -516,6 +516,7 @@ $.extend($.ui.dialog, {
|
|||||||
|
|
||||||
$.extend($.ui.dialog.overlay, {
|
$.extend($.ui.dialog.overlay, {
|
||||||
instances: [],
|
instances: [],
|
||||||
|
maxZ: 0,
|
||||||
events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
||||||
function(event) { return event + '.dialog-overlay'; }).join(' '),
|
function(event) { return event + '.dialog-overlay'; }).join(' '),
|
||||||
create: function(dialog) {
|
create: function(dialog) {
|
||||||
@ -524,25 +525,9 @@ $.extend($.ui.dialog.overlay, {
|
|||||||
// we use a setTimeout in case the overlay is created from an
|
// we use a setTimeout in case the overlay is created from an
|
||||||
// event that we're going to be cancelling (see #2804)
|
// event that we're going to be cancelling (see #2804)
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$(document).bind($.ui.dialog.overlay.events, function() {
|
$(document).bind($.ui.dialog.overlay.events, function(event) {
|
||||||
// allow use of the element if inside a dialog and
|
var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0;
|
||||||
// - there are no modal dialogs
|
return (dialogZ > $.ui.dialog.overlay.maxZ);
|
||||||
// - there are modal dialogs, but we are in front of the topmost modal
|
|
||||||
var allow = false;
|
|
||||||
var $dialog = $(this).parents('.ui-dialog');
|
|
||||||
if ($dialog.length) {
|
|
||||||
var $overlays = $('.ui-dialog-overlay');
|
|
||||||
if ($overlays.length) {
|
|
||||||
var maxZ = parseInt($overlays.css('z-index'), 10);
|
|
||||||
$overlays.each(function() {
|
|
||||||
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
|
|
||||||
});
|
|
||||||
allow = parseInt($dialog.css('z-index'), 10) > maxZ;
|
|
||||||
} else {
|
|
||||||
allow = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return allow;
|
|
||||||
});
|
});
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user