Add TimePicker.placement = auto (only supports: top/bottom position) (#3927)
Fixes #3903. Credit to @w20k
This commit is contained in:
parent
c5bad06510
commit
445c549062
|
|
@ -188,7 +188,7 @@
|
|||
DatePicker.prototype.initTimePicker = function() {
|
||||
this.$timePicker.clockpicker({
|
||||
autoclose: 'true',
|
||||
placement: 'bottom',
|
||||
placement: 'auto',
|
||||
align: 'right',
|
||||
twelvehour: this.isTimeTwelveHour()
|
||||
// afterDone: this.proxy(this.onSelectTimePicker)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -171,7 +171,7 @@
|
|||
}
|
||||
|
||||
// Placement and arrow align - make sure they make sense.
|
||||
if ((options.placement === 'top' || options.placement === 'bottom') && (options.align === 'top' || options.align === 'bottom')) options.align = 'left';
|
||||
if ((options.placement === 'top' || options.placement === 'bottom' || options.placement === 'auto') && (options.align === 'top' || options.align === 'bottom')) options.align = 'left';
|
||||
if ((options.placement === 'left' || options.placement === 'right') && (options.align === 'left' || options.align === 'right')) options.align = 'top';
|
||||
|
||||
popover.addClass(options.placement);
|
||||
|
|
@ -392,10 +392,20 @@
|
|||
placement = this.options.placement,
|
||||
align = this.options.align,
|
||||
styles = {},
|
||||
self = this;
|
||||
self = this,
|
||||
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
|
||||
scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
|
||||
|
||||
popover.show();
|
||||
|
||||
if(placement === 'auto'){
|
||||
if (offset.top + popover.outerHeight() > viewportHeight + scrollTop) {
|
||||
placement = 'top';
|
||||
} else {
|
||||
placement = 'bottom';
|
||||
}
|
||||
}
|
||||
|
||||
// Place the popover
|
||||
switch (placement) {
|
||||
case 'bottom':
|
||||
|
|
|
|||
Loading…
Reference in New Issue