Added option to fix the position of picker.

Example: If the datetimepicker is being used on a fixed position popup,
then we can set fixed: true for the datetimepicker to fix the position
of the picker too.
This commit is contained in:
Mohammed Mansoor Ahmed 2014-05-30 11:37:02 +05:30
parent bc8ea874af
commit 5d19459a4c

View File

@ -241,6 +241,8 @@
style:'', style:'',
id:'', id:'',
fixed: false,
roundTime:'round', // ceil, floor roundTime:'round', // ceil, floor
className:'', className:'',
@ -1160,16 +1162,23 @@
} }
}); });
var setPos = function() { var setPos = function() {
var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left; var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left, position = "absolute";
if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() ) if (options.fixed) {
top = offset.top-datetimepicker[0].offsetHeight+1; top -= $(window).scrollTop();
if (top < 0) left -= $(window).scrollLeft();
top = 0; position = "fixed";
if( left+datetimepicker[0].offsetWidth>$(window).width() ) }else {
left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth; if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() )
top = offset.top-datetimepicker[0].offsetHeight+1;
if (top < 0)
top = 0;
if( left+datetimepicker[0].offsetWidth>$(window).width() )
left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth;
}
datetimepicker.css({ datetimepicker.css({
left:left, left:left,
top:top top:top,
position: position
}); });
}; };
datetimepicker datetimepicker