Permalink
Browse files

A better zIndex detection function, thanks Mark Larter.

  • Loading branch information...
1 parent 67a960f commit d277c4bc7461d4144c7732c8d56c07efa7303b1e @fgelinas committed Jan 30, 2013
Showing with 21 additions and 11 deletions.
  1. +3 −0 index.html
  2. +18 −11 jquery.ui.timepicker.js
View
@@ -907,6 +907,9 @@
<h2>Releases :</h2>
<dl>
+ <dt>0.3.3 - ????</dt>
+ <dd>Better zIndex detection - Thanks Mark Larter <a href="https://github.com/fgelinas/timepicker/issues/62">ref #62</a></dd>
+
<dt>0.3.2 - 25 January 2013</dt>
<dd>Updated to jQuery 1.9.0 and UI 1.10.0. Removed deprecated IE6 hacks.</dd>
<dd>Added support for Date object with the setTime and getTimeAsDate function - thanks AAverin.</dd>
View
@@ -1,7 +1,7 @@
/*
- * jQuery UI Timepicker 0.3.1
+ * jQuery UI Timepicker
*
- * Copyright 2010-2011, Francois Gelinas
+ * Copyright 2010-2013, Francois Gelinas
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
@@ -416,20 +416,27 @@
}
},
- // This is a copy of the zIndex function of UI core 1.8.??
- // Copied in the timepicker to stay backward compatible.
+ // This is an enhanced copy of the zIndex function of UI core 1.8.?? For backward compatibility.
+ // Enhancement returns maximum zindex value discovered while traversing parent elements,
+ // rather than the first zindex value found. Ensures the timepicker popup will be in front,
+ // even in funky scenarios like non-jq dialog containers with large fixed zindex values and
+ // nested zindex-influenced elements of their own.
_getZIndex: function (target) {
- var elem = $( target ), position, value;
- while ( elem.length && elem[ 0 ] !== document ) {
- position = elem.css( "position" );
- if ( position === "absolute" || position === "relative" || position === "fixed" ) {
- value = parseInt( elem.css( "zIndex" ), 10 );
- if ( !isNaN( value ) && value !== 0 ) {
- return value;
+ var elem = $(target);
+ var maxValue = 0;
+ var position, value;
+ while (elem.length && elem[0] !== document) {
+ position = elem.css("position");
+ if (position === "absolute" || position === "relative" || position === "fixed") {
+ value = parseInt(elem.css("zIndex"), 10);
+ if (!isNaN(value) && value !== 0) {
+ if (value > maxValue) { maxValue = value; }
}
}
elem = elem.parent();
}
+
+ return maxValue;
},
/* Refresh the time picker

0 comments on commit d277c4b

Please sign in to comment.