Index: dojo-release-1.3.2-src/dijit/Dialog.js =================================================================== --- dojo-release-1.3.2-src.orig/dijit/Dialog.js 2010-03-26 11:36:45.000000000 -0700 +++ dojo-release-1.3.2-src/dijit/Dialog.js 2010-04-09 07:19:55.000000000 -0700 @@ -12,17 +12,15 @@ dojo.require("dijit.layout.ContentPane"); dojo.requireLocalization("dijit", "common"); -/*===== -dijit._underlay = function(kwArgs){ - // summary: - // A shared instance of a `dijit.DialogUnderlay` - // - // description: - // A shared instance of a `dijit.DialogUnderlay` created and - // used by `dijit.Dialog`, though never created until some Dialog - // or subclass thereof is shown. -}; -=====*/ +// dijit._overlayStartingZIndex: Number +// summary: +// z-index that starts the overlays with. Note that the dijit._popup.zIndex is 1000. +dijit._overlayStartingZIndex = 900; + +// dijit._overlayStack: stack of _Widgets +// summary: +// Stack of widgets that are overlayed over the viewport. +dijit._overlayStack = []; dojo.declare( "dijit.Dialog", @@ -100,18 +98,38 @@ // Does this Dialog attempt to restore the width and height after becoming too small? _fixSizes: true, + // _underlay: dijit.DialogUnderlay + // Each Dialog gets her own underlay. + _underlay: null, + + // _underlayAttrs: kwArgs + // kwArgs for the underlay. + _underlayAttrs: null, + postMixInProperties: function(){ var _nlsResources = dojo.i18n.getLocalization("dijit", "common"); dojo.mixin(this, _nlsResources); + this._underlayAttrs = { + dialogId: this.id, + "class": dojo.map(this["class"].split(/\s/), function(s){ return s+"_underlay"; }).join(" ") + }; this.inherited(arguments); }, postCreate: function(){ + + this._underlay = new dijit.DialogUnderlay(this._underlayAttrs); + dojo.style(this._underlay.domNode, { + zIndex: (dijit._overlayStartingZIndex+dijit._overlayStack.length) + }); + dijit._overlayStack.push(this._underlay); + dojo.style(this.domNode, { visibility:"hidden", position:"absolute", display:"", - top:"-9999px" + top:"-9999px", + zIndex: (dijit._overlayStartingZIndex+dijit._overlayStack.length) }); dojo.body().appendChild(this.domNode); @@ -121,6 +139,7 @@ this.connect(this, "onCancel", "hide"); this._modalconnects = []; this._subscriptions = []; + dijit._overlayStack.push(this); }, onLoad: function(){ @@ -171,24 +190,15 @@ dojo.addClass(node,"dijitDialogFixed"); } - var underlayAttrs = { - dialogId: this.id, - "class": dojo.map(this["class"].split(/\s/), function(s){ return s+"_underlay"; }).join(" ") - }; - - var underlay = dijit._underlay; - if(!underlay){ - underlay = dijit._underlay = new dijit.DialogUnderlay(underlayAttrs); - } this._fadeIn = dojo.fadeIn({ node: node, duration: this.duration, - beforeBegin: function(){ - underlay.attr(underlayAttrs); - underlay.show(); - }, - onEnd: dojo.hitch(this, function(){ + beforeBegin: dojo.hitch(this, function(){ + this._underlay.attr(this._underlayAttrs); + this._underlay.show(); + }), + onEnd: dojo.hitch(this, function(){ if(this.autofocus){ // find focusable Items each time dialog is shown since if dialog contains a widget the // first focusable items can change @@ -201,11 +211,11 @@ this._fadeOut = dojo.fadeOut({ node: node, duration: this.duration, - onEnd: function(){ + onEnd: dojo.hitch(this, function(){ node.style.visibility="hidden"; node.style.top = "-9999px"; - dijit._underlay.hide(); - } + this._underlay.hide(); + }) }); }, @@ -220,7 +230,7 @@ this._fadeOut.stop(); } if(this.open || wasPlaying){ - dijit._underlay.hide(); + this._underlay.hide(); } if(this._moveable){ this._moveable.destroy(); @@ -271,6 +281,10 @@ // Handles the keyboard events for accessibility reasons // tags: // private + if(dijit._overlayStack[dijit._overlayStack.length-1] !== this){ + // not the top dialog. + return; + } if(evt.charOrCode){ var dk = dojo.keys; var node = evt.target; @@ -400,7 +414,7 @@ // tags: // private if(this.domNode.style.visibility != "hidden"){ - dijit._underlay.layout(); + this._underlay.layout(); this._position(); } }, @@ -416,6 +430,10 @@ }, destroy: function(){ + this.inherited(arguments); + dijit._overlayStack.pop(); + dijit._overlayStack.pop(); + this._underlay.destroy(); delete this._fadeIn; delete this._fadeOut; dojo.forEach(this._modalconnects, dojo.disconnect); @@ -423,7 +441,6 @@ if(this.refocus && this.open){ setTimeout(dojo.hitch(dijit,"focus",this._savedFocus), 25); } - this.inherited(arguments); }, _onCloseEnter: function(){