From 6adf83f5f70cc0404e57cf2367c539c800387965 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Fri, 28 Aug 2009 17:15:54 +0100 Subject: [PATCH] Overlay: removing focus catcher - saving it for 1.7 --- manualtests/widgets/overlay/modal_duo.html | 106 --------------------- src/widgets/overlay/overlay.js | 57 +---------- 2 files changed, 4 insertions(+), 159 deletions(-) delete mode 100644 manualtests/widgets/overlay/modal_duo.html diff --git a/manualtests/widgets/overlay/modal_duo.html b/manualtests/widgets/overlay/modal_duo.html deleted file mode 100644 index 47cccfd..0000000 --- a/manualtests/widgets/overlay/modal_duo.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - glow.widgets.Overlay - - - - - - - - - - -

glow.widgets.Overlay

- -

Two modal panels

- - - -
-
- -
-
- -
- Panel 1 -

Lorem ipsum foo foo

-
- -
- Panel 2 -

Lorem ipsum foo foo

-
- - - - - - - \ No newline at end of file diff --git a/src/widgets/overlay/overlay.js b/src/widgets/overlay/overlay.js index e43c103..e58dafe 100644 --- a/src/widgets/overlay/overlay.js +++ b/src/widgets/overlay/overlay.js @@ -675,9 +675,7 @@ if (that.opts.focusOnShow) { that._focalPoint[0].focus(); } - - if (that.opts.modal) { addModalBehaviour.call(that); } - + return that; }, /** @@ -695,13 +693,11 @@ returnNodeName; if (this._blockActions || !that.isShown) { return that; } - + if (events.fire(that, "hide").defaultPrevented()) { return that; } - - if (that.opts.modal) { removeModalBehaviour.call(that); } - + //run the appropiate animation if (typeof animOpt == "string") { hideAnim = generatePresetAnimation(that, false); @@ -745,7 +741,6 @@ returnTo.attr("tabindex", "-1"); } - returnTo[0].focus(); } @@ -769,51 +764,7 @@ return that; } }; - - /** - @private - @description Enforce requirement that focus to stay within the topmost overlay. - @this {glow.widgets.Overlay} - */ - function addModalBehaviour() { - if (this._keepfocusEventId !== undefined) { return; } // already added this requirement - - var overlay = this, // this overlay - overlayZindex = null; // the z-index of this overlay - - overlayZindex = overlay.container.css('z-index'); // to be closured - - this._keepfocusEventId = events.addListener($('body'), 'focus', function(e) { - var parent = null, // the parent element of the source element that is a child of the body - parentZindex = null; // the zindex of that parent - - // calculate the zindex of the source elements parent - parent = e.source.parentNode; - while (parent) { - if (parent.parentNode == document.body) { break; } - parent = parent.parentNode; - } - parentZindex = $(parent).css('z-index'); - - // when the source element's zindex is less than ours, we take focus back - if (!parentZindex || parentZindex == "auto" || parentZindex < overlayZindex) { - overlay._focalPoint && overlay._focalPoint[0].focus(); - return false; - } - }); - } - - /** - @private - @description Leave environment clean of all changes made by addModalbehaviour(). - @this {glow.widgets.Overlay} - */ - function removeModalBehaviour() { - if (this._keepfocusEventId === undefined) { return; } // already removed this requirement - events.removeListener(this._keepfocusEventId); - delete this._keepfocusEventId; - } - + glow.widgets.Overlay = Overlay; } });