Skip to content
This repository
Browse code

A better zIndex detection function, thanks Mark Larter.

  • Loading branch information...
commit d277c4bc7461d4144c7732c8d56c07efa7303b1e 1 parent 67a960f
Francois Gelinas authored January 29, 2013
3  index.html
@@ -907,6 +907,9 @@
907 907
         <h2>Releases :</h2>
908 908
         <dl>
909 909
 
  910
+            <dt>0.3.3 - ????</dt>
  911
+            <dd>Better zIndex detection - Thanks Mark Larter <a href="https://github.com/fgelinas/timepicker/issues/62">ref #62</a></dd>
  912
+
910 913
             <dt>0.3.2 - 25 January 2013</dt>
911 914
             <dd>Updated to jQuery 1.9.0 and UI 1.10.0. Removed deprecated IE6 hacks.</dd>
912 915
             <dd>Added support for Date object with the setTime and getTimeAsDate function - thanks AAverin.</dd>
29  jquery.ui.timepicker.js
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2  
- * jQuery UI Timepicker 0.3.1
  2
+ * jQuery UI Timepicker
3 3
  *
4  
- * Copyright 2010-2011, Francois Gelinas
  4
+ * Copyright 2010-2013, Francois Gelinas
5 5
  * Dual licensed under the MIT or GPL Version 2 licenses.
6 6
  * http://jquery.org/license
7 7
  *
@@ -416,20 +416,27 @@
416 416
             }
417 417
         },
418 418
 
419  
-        // This is a copy of the zIndex function of UI core 1.8.??
420  
-        // Copied in the timepicker to stay backward compatible.
  419
+        // This is an enhanced copy of the zIndex function of UI core 1.8.?? For backward compatibility.
  420
+        // Enhancement returns maximum zindex value discovered while traversing parent elements,
  421
+        // rather than the first zindex value found. Ensures the timepicker popup will be in front,
  422
+        // even in funky scenarios like non-jq dialog containers with large fixed zindex values and
  423
+        // nested zindex-influenced elements of their own.
421 424
         _getZIndex: function (target) {
422  
-            var elem = $( target ), position, value;
423  
-            while ( elem.length && elem[ 0 ] !== document ) {
424  
-                position = elem.css( "position" );
425  
-                if ( position === "absolute" || position === "relative" || position === "fixed" ) {
426  
-                    value = parseInt( elem.css( "zIndex" ), 10 );
427  
-                    if ( !isNaN( value ) && value !== 0 ) {
428  
-                        return value;
  425
+            var elem = $(target);
  426
+            var maxValue = 0;
  427
+            var position, value;
  428
+            while (elem.length && elem[0] !== document) {
  429
+                position = elem.css("position");
  430
+                if (position === "absolute" || position === "relative" || position === "fixed") {
  431
+                    value = parseInt(elem.css("zIndex"), 10);
  432
+                    if (!isNaN(value) && value !== 0) {
  433
+                        if (value > maxValue) { maxValue = value; }
429 434
                     }
430 435
                 }
431 436
                 elem = elem.parent();
432 437
             }
  438
+
  439
+            return maxValue;
433 440
         },
434 441
 
435 442
         /* Refresh the time picker

0 notes on commit d277c4b

Please sign in to comment.
Something went wrong with that request. Please try again.