From f60779518dc65c6feff01879a45352fa6e77b033 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 20 Dec 2011 14:00:24 +0200 Subject: [PATCH] [popup] Make sure the screen and the container have a higher z-index than any other element on the page --- css/structure/jquery.mobile.popup.css | 3 +-- js/jquery.mobile.popup.js | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/css/structure/jquery.mobile.popup.css b/css/structure/jquery.mobile.popup.css index 5157cac5..b69d2af7 100644 --- a/css/structure/jquery.mobile.popup.css +++ b/css/structure/jquery.mobile.popup.css @@ -1,7 +1,6 @@ .ui-popup-container { display: inline-block; position: absolute; - z-index: 100 !important; padding: 0px; } @@ -13,4 +12,4 @@ position:absolute; top:-15px; right:-15px; -} \ No newline at end of file +} diff --git a/js/jquery.mobile.popup.js b/js/jquery.mobile.popup.js index 22ea227d..470d7d8e 100644 --- a/js/jquery.mobile.popup.js +++ b/js/jquery.mobile.popup.js @@ -204,8 +204,22 @@ $.widget("mobile.popup", $.mobile.widget, { if (!this._isOpen) { var self = this, coords = this._placementCoords( - (undefined === x ? window.innerWidth / 2 : x), - (undefined === y ? window.innerWidth / 2 : y)); + (undefined === x ? window.innerWidth / 2 : x), + (undefined === y ? window.innerHeight / 2 : y)), + zIndexMax = 0; + + $(document) + .find("*") + .each(function() { + var el = $(this), + zIndex = parseInt(el.css("z-index")); + + if (!(el.is(self._ui.container) || el.is(self._ui.screen) || isNaN(zIndex))) + zIndexMax = Math.max(zIndexMax, zIndex); + }); + + this._ui.screen.css("z-index", (zIndexMax + 1)); + this._ui.container.css("z-index", (zIndexMax + 2)); this._ui.screen .height($(document).height()) @@ -244,6 +258,7 @@ $.widget("mobile.popup", $.mobile.widget, { self._ui.screen.addClass("ui-screen-hidden"); self._isOpen = false; self.element.trigger("closed"); + self._ui.screen.removeAttr("style"); }; this._ui.container