@@ -19,6 +19,28 @@ var PROP_NAME = "datepicker",
1919 dpuuid = new Date ( ) . getTime ( ) ,
2020 instActive ;
2121
22+ function getZindex ( elem ) {
23+ var position , value ;
24+ while ( elem . length && elem [ 0 ] !== document ) {
25+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
26+ // This makes behavior of this function consistent across browsers
27+ // WebKit always returns auto if the element is positioned
28+ position = elem . css ( "position" ) ;
29+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
30+ // IE returns 0 when zIndex is not specified
31+ // other browsers return a string
32+ // we ignore the case of nested elements with an explicit value of 0
33+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
34+ value = parseInt ( elem . css ( "zIndex" ) , 10 ) ;
35+ if ( ! isNaN ( value ) && value !== 0 ) {
36+ return value ;
37+ }
38+ }
39+ elem = elem . parent ( ) ;
40+ }
41+
42+ return 0 ;
43+ }
2244/* Date picker manager.
2345 Use the singleton instance of this class, $.datepicker, to interact with the date picker.
2446 Settings for (groups of) date pickers are maintained in an instance object,
@@ -744,7 +766,7 @@ $.extend(Datepicker.prototype, {
744766 if ( ! inst . inline ) {
745767 showAnim = $ . datepicker . _get ( inst , "showAnim" ) ;
746768 duration = $ . datepicker . _get ( inst , "duration" ) ;
747- inst . dpDiv . zIndex ( $ ( input ) . zIndex ( ) + 1 ) ;
769+ inst . dpDiv . css ( "z-index" , getZindex ( $ ( input ) ) + 1 ) ;
748770 $ . datepicker . _datepickerShowing = true ;
749771
750772 if ( $ . effects && $ . effects . effect [ showAnim ] ) {
0 commit comments